CentOS7 分区合并
[root@yunwei-machine /]# df -h
文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root 50G 5.0G 46G 10% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 13M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda1 1014M 179M 836M 18% /boot /dev/mapper/centos-home 245G 40M 245G 1% /home tmpfs 378M 8.0K 378M 1% /run/user/42 tmpfs 378M 32K 378M 1% /run/user/0 /dev/sr0 4.3G 4.3G 0 100% /run/media/root/CentOS 7 x86_64
#卸载/home分区 [root@yunwei-machine /]# umount /home [root@yunwei-machine /]# df -h
文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root 50G 5.0G 46G 10% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 13M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda1 1014M 179M 836M 18% /boot tmpfs 378M 8.0K 378M 1% /run/user/42 tmpfs 378M 32K 378M 1% /run/user/0 /dev/sr0 4.3G 4.3G 0 100% /run/media/root/CentOS 7 x86_64
[root@yunwei-machine /]# #删除/home分区 [root@yunwei-machine /]# lvremove /dev/centos/home Do you really want to remove active logical volume centos/home? [y/n]: y Logical volume “home” successfully removed [root@yunwei-machine /]# 扩展/root 逻辑卷 [root@yunwei-machine /]# lvextend -L +245G /dev/centos/root
Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 295.00 GiB (75520 extents).
Logical volume centos/root successfully resized.
#重新划分/root 分区磁盘空间
[root@yunwei-machine /]# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=3276800 blks = sectsz=512 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=1 log =internal bsize=4096 blocks=6400, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 13107200 to 77332480
查看现有分区
[root@yunwei-machine /]# df -h
文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root 295G 5.0G 291G 2% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 13M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda1 1014M 179M 836M 18% /boot tmpfs 378M 8.0K 378M 1% /run/user/42 tmpfs 378M 32K 378M 1% /run/user/0 /dev/sr0 4.3G 4.3G 0 100% /run/media/root/CentOS 7 x86_64
[root@yunwei-machine /]#
[root@yunwei-machine /]# mkdir -p /home && cd /home
[root@yunwei-machine home]#
#大功告成