linux8在线扩容/home目录
虚机新增1T磁盘
[root@rsb ~]# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.8 (Ootpa)
[root@rsb ~]# vgs
VG #PV #LV #SN Attr VSize VFree
ol 2 3 0 wz--n- <2.00t 0
[root@rsb ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home ol -wi-ao---- <1.90t
root ol -wi-ao---- 70.00g
swap ol -wi-ao---- <31.51g
[root@rsb ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb3 ol lvm2 a-- 1022.41g 0
/dev/sdb4 ol lvm2 a-- <1024.00g 0
[root@rsb ~]# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
devtmpfs devtmpfs 32G 0 32G 0% /dev
tmpfs tmpfs 32G 0 32G 0% /dev/shm
tmpfs tmpfs 32G 9.3M 32G 1% /run
tmpfs tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/mapper/ol-root xfs 70G 6.5G 64G 10% /
/dev/sdb2 xfs 1014M 338M 677M 34% /boot
/dev/sdb1 vfat 599M 5.1M 594M 1% /boot/efi
/dev/mapper/ol-home xfs 1.9T 1.4T 593G 70% /home
tmpfs tmpfs 6.3G 12K 6.3G 1% /run/user/42
tmpfs tmpfs 6.3G 0 6.3G 0% /run/user/0
[root@rsb ~]# vgs
VG #PV #LV #SN Attr VSize VFree
ol 2 3 0 wz--n- <2.00t 0
[root@rsb ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb3 ol lvm2 a-- 1022.41g 0
/dev/sdb4 ol lvm2 a-- <1024.00g 0
[root@rsb ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home ol -wi-ao---- <1.90t
root ol -wi-ao---- 70.00g
swap ol -wi-ao---- <31.51g
[root@rsb ~]# lsblk|grep sd
sda 8:0 0 1T 0 disk
sdb 8:16 0 2T 0 disk
├─sdb1 8:17 0 600M 0 part /boot/efi
├─sdb2 8:18 0 1G 0 part /boot
├─sdb3 8:19 0 1022.4G 0 part
└─sdb4 8:20 0 1T 0 part
[root@rsb ~]# pvcreate /dev/sda
Physical volume "/dev/sda" successfully created.
[root@rsb ~]# vgextend ol /dev/sda
Volume group "ol" successfully extended
[root@rsb ~]# vgs
VG #PV #LV #SN Attr VSize VFree
ol 3 3 0 wz--n- <3.00t <1024.00g
[root@rsb ~]# lvdisplay|grep ol
--- Logical volume ---
LV Path /dev/ol/swap
VG Name ol
--- Logical volume ---
LV Path /dev/ol/home
VG Name ol
--- Logical volume ---
LV Path /dev/ol/root
VG Name ol
[root@rsb ~]# lvextend -l +100%free /dev/ol/home
Size of logical volume ol/home changed from <1.90 TiB (497894 extents) to <2.90 TiB (760037 extents).
Logical volume ol/home successfully resized.
[root@rsb ~]# vgs
VG #PV #LV #SN Attr VSize VFree
ol 3 3 0 wz--n- <3.00t 0
[root@rsb ~]# df -hT /home
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/mapper/ol-home xfs 1.9T 1.4T 593G 70% /home
[root@rsb ~]# xfs_growfs /dev/ol/home
meta-data=/dev/mapper/ol-home isize=512 agcount=9, agsize=60352256 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=0 inobtcount=0
data = bsize=4096 blocks=509843456, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=117875, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 509843456 to 778277888
[root@rsb ~]# df -hT /home
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/mapper/ol-home xfs 2.9T 1.4T 1.6T 46% /home
相关参考:
快速实战:linux7.x在线扩容根盘lvm - 墨天轮