文章目录
-
- 磁盘分区(可选)
- 刷新分区表
- 创建PV物理卷
- 创建VG逻辑卷组
- 创建LV逻辑卷
-
- 扩容LV逻辑卷
[root@localhost ~]
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 99G 0 part
├─centos-root 253:0 0 95G 0 lvm /
└─centos-swap 253:1 0 4G 0 lvm [SWAP]
sdb 8:16 0 20G 0 disk
sr0 11:0 1 1024M 0 rom
磁盘分区(可选)
[root@localhost ~]
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x5d15236d.
Command (m for help): p
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x5d15236d
Device Boot Start End Blocks Id System
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +10G
Partition 1 of type Linux and of size 10 GiB is set
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number (2-4, default 2):
First sector (20973568-41943039, default 20973568):
Using default value 20973568
Last sector, +sectors or +size{K,M,G} (20973568-41943039, default 41943039):
Using default value 41943039
Partition 2 of type Linux and of size 10 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
刷新分区表
[root@localhost ~]
[root@localhost ~]
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 99G 0 part
├─centos-root 253:0 0 95G 0 lvm /
└─centos-swap 253:1 0 4G 0 lvm [SWAP]
sdb 8:16 0 20G 0 disk
├─sdb1 8:17 0 10G 0 part
└─sdb2 8:18 0 10G 0 part
sr0 11:0 1 1024M 0 rom
创建PV物理卷
[root@localhost ~]
Physical volume "/dev/sdb1" successfully created.
Physical volume "/dev/sdb2" successfully created.
[root@localhost ~]
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- <99.00g 0
/dev/sdb1 lvm2 --- 10.00g 10.00g
/dev/sdb2 lvm2 --- <10.00g <10.00g
创建VG逻辑卷组
[root@localhost ~]
Volume group "vg-sdb" successfully created
[root@localhost ~]
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size <99.00 GiB
PE Size 4.00 MiB
Total PE 25343
Alloc PE / Size 25343 / <99.00 GiB
Free PE / Size 0 / 0
VG UUID Z1h9Gu-7UmL-80jT-MqyZ-rU8p-ys6a-Eg6Mcu
--- Volume group ---
VG Name vg-sdb
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 19.99 GiB
PE Size 4.00 MiB
Total PE 5118
Alloc PE / Size 0 / 0
Free PE / Size 5118 / 19.99 GiB
VG UUID FIk0Yn-leBU-XUWE-nqtv-Odi2-oSFC-Qscyu7
创建LV逻辑卷
[root@localhost ~]
Logical volume "lv-sdb" created.
[root@localhost ~]
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- <95.00g
swap centos -wi-ao---- 4.00g
lv-sdb vg-sdb -wi-a----- 10.00g
[root@localhost ~]
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2151677952
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
挂载磁盘
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 95G 16G 80G 17% /
devtmpfs devtmpfs 979M 0 979M 0% /dev
tmpfs tmpfs 991M 0 991M 0% /dev/shm
tmpfs tmpfs 991M 9.6M 981M 1% /run
tmpfs tmpfs 991M 0 991M 0% /sys/fs/cgroup
/dev/sda1 xfs 1014M 133M 882M 14% /boot
tmpfs tmpfs 199M 0 199M 0% /run/user/0
/dev/mapper/vg--sdb-lv--sdb ext4 9.8G 37M 9.2G 1% /mnt/lv-sdb
扩容LV逻辑卷
[root@localhost ~]
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size <99.00 GiB
PE Size 4.00 MiB
Total PE 25343
Alloc PE / Size 25343 / <99.00 GiB
Free PE / Size 0 / 0
VG UUID Z1h9Gu-7UmL-80jT-MqyZ-rU8p-ys6a-Eg6Mcu
--- Volume group ---
VG Name vg-sdb
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 19.99 GiB
PE Size 4.00 MiB
Total PE 5118
Alloc PE / Size 2560 / 10.00 GiB
Free PE / Size 2558 / 9.99 GiB
VG UUID FIk0Yn-leBU-XUWE-nqtv-Odi2-oSFC-Qscyu7
[root@localhost ~]
Rounding size to boundary between physical extents: 9.90 GiB.
Size of logical volume vg-sdb/lv-sdb changed from 10.00 GiB (2560 extents) to 19.90 GiB (5095 extents).
Logical volume vg-sdb/lv-sdb successfully resized.
[root@localhost ~]
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- <95.00g
swap centos -wi-ao---- 4.00g
lv-sdb vg-sdb -wi-ao---- 19.90g
[root@localhost ~]
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/vg-sdb/lv-sdb is mounted on /mnt/lv-sdb; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 3
The filesystem on /dev/vg-sdb/lv-sdb is now 5217280 blocks long.
[root@localhost ~]
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 95G 16G 80G 17% /
devtmpfs devtmpfs 979M 0 979M 0% /dev
tmpfs tmpfs 991M 0 991M 0% /dev/shm
tmpfs tmpfs 991M 9.6M 981M 1% /run
tmpfs tmpfs 991M 0 991M 0% /sys/fs/cgroup
/dev/sda1 xfs 1014M 133M 882M 14% /boot
tmpfs tmpfs 199M 0 199M 0% /run/user/0
/dev/mapper/vg--sdb-lv--sdb ext4 20G 44M 19G 1% /mnt/lv-sdb