LVM2:
LVM: Logical Volume Manager, Version: 2
dm: device mapper,将一个或多个底层块设备组织成一个逻辑设备的模块;
/dev/dm-#
/dev/mapper/VG_NAME-LV_NAME
/dev/mapper/vol0-root
/dev/VG_NAME/LV_NAME
/dev/vol0/root
pv管理工具:
pvs:简要pv信息显示
pvdisplay:显示pv的详细信息
[root@localhost ~]# pvdisplay --- Physical volume --- PV Name /dev/sda2 VG Name cl PV Size 79.00 GiB / not usable 3.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 20223 Free PE 1 Allocated PE 20222 PV UUID YdJrrk-EtCl-qvll-Iid5-kmrH-wnuz-vgRYD4
pvcreate /dev/DEVICE: 创建pv
[root@localhost ~]# pvcreate /dev/sde{1,2,3,4}
Physical volume "/dev/sde1" successfully created. Physical volume "/dev/sde2" successfully created. Physical volume "/dev/sde3" successfully created. Physical volume "/dev/sde4" successfully created.
vg管理工具:
vgs
例一:简要显示所有卷组
[root@localhost ~]# vgs VG #PV #LV #SN Attr VSize VFree cl 1 3 0 wz--n- 79.00g 4.00m
vgdisplay
例一:详细显示卷组信息
[root@localhost ~]# vgdisplay cl --- Volume group --- VG Name cl System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 3 Open LV 3 Max PV 0 Cur PV 1 Act PV 1 VG Size 79.00 GiB PE Size 4.00 MiB Total PE 20223 Alloc PE / Size 20222 / 78.99 GiB Free PE / Size 1 / 4.00 MiB VG UUID ARFDVR-uqsI-LwWg-VAXy-Ea9X-t40F-xdYA00
vgcreate [-s #[kKmMgGtTpPeE]] VolumeGroupName PhysicalDevicePath [PhysicalDevicePath…]创建
例一:创建VG
[root@localhost ~]# vgcreate mmm /dev/sde{2,3,4} Volume group "mmm" successfully created
vgextend VolumeGroupName PhysicalDevicePath [PhysicalDevicePath…] 扩展
[root@localhost ~]# vgextend mmm /dev/sde1 Volume group "mmm" successfully extended
vgreduce VolumeGroupName PhysicalDevicePath [PhysicalDevicePath…]删除
[root@localhost ~]# vgreduce mmm /dev/sde1 Removed "/dev/sde1" from volume group "mmm"
先做pvmove
vgremove
lv管理工具:
lvs
例一:查看现有的逻辑卷
[root@localhost ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert home cl -wi-ao---- 26.99g root cl -wi-ao---- 50.00g swap cl -wi-ao---- 2.00g
lvdisplay
例一:查看逻辑卷的详细信息
[root@localhost ~]# lvdisplay --- Logical volume --- LV Path /dev/cl/swap LV Name swap VG Name cl LV UUID 2KCdHx-9K6O-qUvx-cHFC-ffZE-2v4x-01UD3H LV Write Access read/write LV Creation host, time localhost.localdomain, 2017-05-05 06:23:15 +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
例二:查看指定逻辑卷
[root@localhost ~]# lvdisplay /dev/cl/root --- Logical volume --- LV Path /dev/cl/root LV Name root VG Name cl LV UUID 0clOxW-1IQi-7uDj-CLLh-Pkzu-SWAz-nsW9y9 LV Write Access read/write LV Creation host, time localhost.localdomain, 2017-05-05 06:23:16 +0800 LV Status available # open 1 LV Size 50.00 GiB Current LE 12800 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 lvcreate -L #[mMgGtT] -n NAME VolumeGroup
例一:创建一个lv
[root@localhost ~]# lvcreate -L 2G -n kkk mmm Logical volume "kkk" created.
lvremove /dev/VG_NAME/LV_NAME
扩展逻辑卷:
# lvextend -L [+]#[mMgGtT] /dev/VG_NAME/LV_NAME[root@localhost baskup]#
例一:扩展逻辑卷
lvextend -L 6G /dev/mmm/kkk
Size of logical volume mmm/kkk changed from 2.00 GiB (512 extents) to 6.00 GiB (1536 extents).
Logical volume mmm/kkk successfully resized.
# resize2fs /dev/VG_NAME/LV_NAME
例一:重新识别逻辑卷
[root@localhost baskup]# resize2fs /dev/kkk/mmm
resize2fs 1.42.9 (28-Dec-2013)
缩减逻辑卷:
# umount /dev/VG_NAME/LV_NAME
# e2fsck -f /dev/VG_NAME/LV_NAME
# resize2fs /dev/VG_NAME/LV_NAME #[mMgGtT]
# lvreduce -L [-]#[mMgGtT] /dev/VG_NAME/LV_NAME
# mount
原创文章,作者:kang,如若转载,请注明出处:http://www.178linux.com/76282