部署CentOS7的時候分配的動態擴充虛擬磁盤,共1T大小,在安裝Centos時默認分區,系統僅給/分配50G,而大量空間都掛載到/home下,最近CentOS7使用中發現空間已不足夠,因此就想如何將/home下的空間從新分配擴容到/下。node
配置過程centos
df -h 或者lsblkapp
[root@localhost ~]# df -h文件系統 容量 已用 可用 已用% 掛載點/dev/mapper/centos-root 50G 49G 1.6G 97% / /dev/mapper/centos-home 965G 33M 965G 1% /home
卸載前記得備份cp -r /home /home-bakide
[root@localhost ~]# umount /home[root@localhost ~]# df -h文件系統 容量 已用 可用 已用% 掛載點/dev/mapper/centos-root 50G 49G 1.6G 97% /
[root@localhost ~]# lvremove /dev/mapper/centos-home Do you really want to remove active logical volume centos/home? [y/n]: y Logical volume "home" successfully removed
這裏咱們增長500G空間 [root@localhost ~]# lvextend -L +500G /dev/mapper/centos-root Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 550.00 GiB (140800 extents). Logical volume centos/root successfully resized.
[root@localhost ~]# df -hT文件系統 類型 容量 已用 可用 已用% 掛載點/dev/mapper/centos-root xfs 50G 49G 1.6G 97% /
[root@localhost ~]# xfs_growfs /dev/mapper/centos-root meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=3276800 blks = sectsz=4096 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=13107200, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1log =internal bsize=4096 blocks=6400, version=2 = sectsz=4096 sunit=1 blks, lazy-count=1realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 13107200 to 144179200
[root@localhost ~]# df -h文件系統 容量 已用 可用 已用% 掛載點/dev/mapper/centos-root 550G 49G 502G 9% /
[root@localhost ~]# vgdisplay --- Volume group --- VG Name centos System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 7 VG Access read/write VG Status resizable MAX LV 0 Cur LV 3 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size <1023.00GiB PE Size 4.00 MiB Total PE 261887 Alloc PE / Size 168416 /<657.88GiB Free PE / Size 93471 / 365.12 GiB VG UUID TDRsyJ-GZ2H-ZRWr-Gfje-LNe1-ggpz-0pJ7jx
[root@localhost ~]# lvcreate -L 100G -n home centos Logical volume "home" created.
[root@localhost ~]# mkfs.xfs /dev/centos/homemeta-data=/dev/centos/home isize=512 agcount=4, agsize=6553600 blks = sectsz=4096 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=26214400, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1log =internal log bsize=4096 blocks=12800, version=2 = sectsz=4096 sunit=1 blks, lazy-count=1realtime =none extsz=4096 blocks=0, rtextents=0
[root@localhost ~]# mount /dev/centos/home /home
[root@localhost ~]# df -h文件系統 容量 已用 可用 已用% 掛載點/dev/mapper/centos-root 550G 49G 502G 9% / /dev/mapper/centos-home 100G 33M 100G 1% /home