Linux LVM逻辑卷管理(2)

显示系统中各卷组的详细信息

[root@localhost ~]# vgdisplay --- Volume group --- VG Name class 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 39.99 GiB PE Size 4.00 MiB Total PE 10238 Alloc PE / Size 0 / 0 Free PE / Size 10238 / 39.99 GiB VG UUID ZtQvGX-YOdy-U8wj-mGQs-TT1e-1PBR-dBNKAG --- 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 <19.00 GiB PE Size 4.00 MiB Total PE 4863 Alloc PE / Size 4863 / <19.00 GiB Free PE / Size 0 / 0 VG UUID bLPJGb-SQQ3-KcUb-OSdo-qaMR-9hJE-MTkc7a vgremove#

删除指定的卷组

TIPS:卷组下面的逻辑卷没有被挂载使用,卷组删除时会一并删除下面的逻辑卷。

[root@localhost ~]# vgremove class Volume group "class" successfully removed vgextend#

添加新的物理卷,动态扩展卷组的磁盘空间

[root@localhost ~]# vgextend class /dev/sdd1 Volume group "class" successfully extended vgreduce#

删除卷组中的物理卷,减少卷组容量,

-a:如果命令行中没有指定要删除的物理卷,则删除所有的空物理卷。(all)

TIPS:删除啊前确保对应的物理卷没有在使用,就是下面没有逻辑卷,否则删除不了。

[root@localhost ~]# vgreduce class /dev/sdd1 Removed "/dev/sdd1" from volume group "class" [root@localhost ~]# vgreduce -a class Physical volume "/dev/sdb1" still in use Physical volume "/dev/sdc1" still in use Removed "/dev/sdd1" from volume group "class" LV 管理# lvscan#

扫描系统中已建立的LVM逻辑卷

[root@localhost ~]# lvscan ACTIVE '/dev/class/stu01' [25.00 GiB] inherit ACTIVE '/dev/class/stu02' [14.99 GiB] inherit ACTIVE '/dev/centos/swap' [2.00 GiB] inherit ACTIVE '/dev/centos/root' [<17.00 GiB] inherit lvcreate#

从指定的卷组中分割空间,创建新的逻辑卷

-L:指定逻辑卷的大小,单位为KMGT
-l:指定百分比创建,如50%vg卷组的一半空间、100%free所有剩下的。
-n:指定逻辑卷的名称

[root@localhost ~]# lvcreate -L 15G -n stu01 class Logical volume "stu01" created. [root@localhost ~]# lvcreate -l 100%free -n stu02 class Logical volume "stu02" created. lvdisplay#

显示逻辑卷的详细信息

[root@localhost ~]# lvdisplay --- Logical volume --- LV Path /dev/class/stu01 LV Name stu01 VG Name class LV UUID XUP7dq-IM9f-PdKk-XpDH-J1hx-kkuB-cOu3Qx LV Write Access read/write LV Creation host, time localhost.localdomain, 2019-08-24 09:42:35 +0800 LV Status available # open 0 LV Size 25.00 GiB Current LE 6400 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2 --- Logical volume --- LV Path /dev/class/stu02 LV Name stu02 VG Name class LV UUID P7iMC1-X0oT-6TCH-vLYj-HW2j-6QMu-rS7Jyp LV Write Access read/write LV Creation host, time localhost.localdomain, 2019-08-24 09:59:30 +0800 LV Status available # open 0 LV Size 14.99 GiB Current LE 3838 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:3 --- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID NXiaXT-T6yv-ktM2-plyS-j6Hg-hkvu-1JQ2eL LV Write Access read/write LV Creation host, time localhost, 2019-08-16 17:12:19 +0800 LV Status available # open 2 LV Size 2.00 GiB Current LE 512 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1 --- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID 7FnsfT-B8xi-3vgu-8N0k-nzNn-8Rra-eoE4iC LV Write Access read/write LV Creation host, time localhost, 2019-08-16 17:12:19 +0800 LV Status available # open 1 LV Size <17.00 GiB Current LE 4351 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 lvremove#

删除指定的逻辑卷

TIPS:备份数据,解挂载,删除。

[root@localhost ~]# umount /mnt/stu02/ [root@localhost ~]# lvremove /dev/class/stu02 lvextend#

动态扩展LVM逻辑卷的空间大小

-L:指定扩展逻辑卷的大小,单位为KMGT
-l:指定百分比扩建,如100%free所有剩下的。

[root@localhost ~]# lvextend -L +8G /dev/class/stu01 [root@localhost ~]# lvextend -L +8G /dev/class/stu02

TIPS:已挂载,使用在线调整大小,xfs使用xfs_growfs,ext4使用resize2fs。

[root@localhost ~]# xfs_growfs /dev/class/stu01 [root@localhost ~]# resize2fs /dev/class/stu02 lvreduce#

减少LVM逻辑卷的空间大小,

-L:指定逻辑卷的大小,单位为KMGT

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/11717.html