LVM 扩容 - 添加新硬盘
vmware虚拟机空间不足,进行扩容
VMware挂载硬盘
挂载之后,默认不会被系统发现,需要执行命令添加
ls /sys/class/scsi_host/
echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan
查看当前状况
- 查看物理卷
$ pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 49.51g 0
/dev/sdb1 centos lvm2 a-- 50.00g 40.00m
$ pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos
PV Size 49.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 12674
Free PE 0
Allocated PE 12674
PV UUID 5ocR0z-ZfDF-sjE6-llnD-ilcJ-BNTE-G1MAhe
--- Physical volume ---
PV Name /dev/sdb1
VG Name centos
PV Size 50.00 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 12799
Free PE 10
Allocated PE 12789
PV UUID nCUaT0-IPJy-zeCK-ITj1-un2I-FQIc-aYmj3V
- 查看逻辑卷组
$ vgs
VG #PV #LV #SN Attr VSize VFree
centos 2 2 0 wz--n- 99.50g 40.00m
$ vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 99.50 GiB
PE Size 4.00 MiB
Total PE 25473
Alloc PE / Size 25463 / 99.46 GiB
Free PE / Size 10 / 40.00 MiB
VG UUID v9I5Jd-OOFk-0VUV-Yhq4-eAnC-CHKO-DQ9mlx
- 查看逻辑卷
$ lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 97.46g
swap centos -wi-ao---- 2.00g
$ lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID QEWL0J-KDEi-A6uH-OgGl-65hZ-NZhh-dCO3YQ
LV Write Access read/write
LV Creation host, time dragon.dsky, 2016-12-06 11:13:40 +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 dRtNvW-Tm7Q-gkzQ-2uhR-N6Gg-0I2V-6Bh9CM
LV Write Access read/write
LV Creation host, time dragon.dsky, 2016-12-06 11:13:41 +0800
LV Status available
# open 1
LV Size 97.46 GiB
Current LE 24951
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
创建新硬盘为物理卷
$ pvcreate /dev/sdb1
扩容逻辑卷组 - 加入新物理卷
$ vgextend centos /dev/sdb1
扩容逻辑卷
$ lvextend -L +50G /dev/mapper/centos-root
刷新逻辑卷大小
- ext4 文件系统
$ resize2fs /dev/mapper/centos-root
- xfs 文件系统
$ xfs_growfs /dev/mapper/centos-root