1. 在线扫描虚拟机SCSI新增的容量
# for i in `find /sys/class/scsi_host/host*`;do echo "- - -" > $i/scan; done
# for i in `find /sys/class/scsi_device/*`;do echo 1 > $i/device/rescan; done
2. 变更LVM容量
pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 cl lvm2 a-- 99.51g 0
/dev/sdb vg_data lvm2 a-- 300.00g 80.00g
# pvresize /dev/sdb
Physical volume "/dev/sdb" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 cl lvm2 a-- 99.51g 0
/dev/sdb vg_data lvm2 a-- 320.00g 100.00g
# vgs
VG #PV #LV #SN Attr VSize VFree
cl 1 2 0 wz--n- 99.51g 0
vg_data 1 1 0 wz--n- 320.00g 100.00g
# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root cl -wi-ao---- 79.98g
swap cl -wi-ao---- 19.53g
lv_data vg_data -wi-ao---- 220.00g
# lvextend -L +50G /dev/vg_data/lv_data
Size of logical volume vg_data/lv_data changed from 220.00 GiB (56320 extents) to 270.00 GiB (69120 extents).
Logical volume vg_data/lv_data successfully resized.
# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root cl -wi-ao---- 79.98g
swap cl -wi-ao---- 19.53g
lv_data vg_data -wi-ao---- 270.00g
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 80G 1.7G 79G 3% /
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs 7.8G 8.5M 7.8G 1% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/sda1 477M 109M 339M 25% /boot
tmpfs 1.6G 0 1.6G 0% /run/user/0
/dev/mapper/vg_data-lv_data 220G 33M 220G 1% /data
3. 扩展文件系统的容量
# xfs_growfs /dev/vg_data/lv_data
meta-data=/dev/mapper/vg_data-lv_data isize=512 agcount=5, agsize=13106944 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=57671680, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=25599, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 57671680 to 70778880
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 80G 1.7G 79G 3% /
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs 7.8G 8.5M 7.8G 1% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/sda1 477M 109M 339M 25% /boot
tmpfs 1.6G 0 1.6G 0% /run/user/0
/dev/mapper/vg_data-lv_data 270G 33M 270G 1% /data