系统安装完成以后,根目录的磁盘空间只有70G,剩余的大部分空间会分配到/home目录下面。使用过程中很少使用到/home目录,所以我们来把/home目录的磁盘空间分配一些给根目录
扩容之前备份
查看磁盘使用情况
[root@itranCentOS /]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 28G 0 28G 0% /dev
tmpfs 28G 0 28G 0% /dev/shm
tmpfs 28G 18M 28G 1% /run
tmpfs 28G 0 28G 0% /sys/fs/cgroup
/dev/mapper/cl_itrancentos-root 70G 5.2G 65G 8% /
/dev/sda2 1014M 238M 777M 24% /boot
/dev/mapper/cl_itrancentos-home 1.8T 13G 1.8T 1% /home
/dev/sda1 599M 7.3M 592M 2% /boot/efi
tmpfs 5.5G 36K 5.5G 1% /run/user/1000
卸载/home目录
umount /home 或者 umount /dev/mapper/vg_rogear-lv_home
[root@itranCentOS /]# umount /home
umount: /home: target is busy.
[root@itranCentOS /]# umount /dev/mapper/cl_itrancentos-root
umount: /: target is busy.
如果出现以上信息,表明还有进程在占用home分区,执行如下命令
[root@itranCentOS /]# fuser -m /home/
/home: 7243m 7261c 7265cm 7294c 7386cm 7418c 7423c 7475cm 7480c 7483c 7572cm 7666c 7670cm 7671cm 7674c 7676c 7679c 7693cm 7704cm 7
711cm 7722c 7726c 7729cm 7733c 7738c 7749c 7759cm 7761c 7762c 7763c 7764cm 7770cm 7775cm 7777cm 7778c 7792cm 7797cm 7798cm 7799c 7800cm 7803cm
7807cm 7808cm 7809cm 7849cm 7866cm 7867cm 7870cm 7886c 7899c 7905cm 7934c 7989cm 8024c 8033cm 8056cm 8199cm 8209c 8246cm 8319cm 8477c 8487cm 8
500c 40805c
复制上面所有数据列,将其中的m,c等去掉,只保留干净的pid集合,然后统一kill掉。
[root@itranCentOS /]# kill -9 7243
[root@itranCentOS /]# kill -9 7261
[root@itranCentOS /]# kill -9 7265
[root@itranCentOS /]# kill -9 7294
[root@itranCentOS /]# kill -9 7386
[root@itranCentOS /]# kill -9 7418
kill掉之后卸载home
[root@itranCentOS /]# fuser -m /home/
[root@itranCentOS /]# umount /home
#删除/home所在的lv
[root@itranCentOS /]# lvremove /dev/mapper/cl_itrancentos-home
Do you really want to remove active logical volume cl_itrancentos/home? [y/n]: y
Logical volume "home" successfully removed
扩容/dev/mapper/cl_itrancentos-root
[root@itranCentOS /]# lvextend -L +1024G /dev/mapper/cl_itrancentos-root
Size of logical volume cl_itrancentos/root changed from 70.00 GiB (17920 extents) to <1.07 TiB (280064 extents).
Logical volume cl_itrancentos/root successfully resized.
[root@itranCentOS disk]# lvextend -L +258G /dev/mapper/cl_itrancentos-root
Size of logical volume cl_itrancentos/root changed from <1.07 TiB (280064 extents) to 1.32 TiB (346112 extents).
Logical volume cl_itrancentos/root successfully resized.
扩展/dev/mapper/cl_itrancentos-root文件系统
[root@itranCentOS /]# xfs_growfs /dev/mapper/cl_itrancentos-root
meta-data=/dev/mapper/cl_itrancentos-root isize=512 agcount=4, agsize=4587520 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=18350080, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=8960, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 18350080 to 286785536
[root@itranCentOS /]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 28G 0 28G 0% /dev
tmpfs 28G 0 28G 0% /dev/shm
tmpfs 28G 18M 28G 1% /run
tmpfs 28G 0 28G 0% /sys/fs/cgroup
/dev/mapper/cl_itrancentos-root 1.1T 13G 1.1T 2% /
/dev/sda2 1014M 238M 777M 24% /boot
/dev/sda1 599M 7.3M 592M 2% /boot/efi
tmpfs 5.5G 16K 5.5G 1% /run/user/42
重新创建home
重新创建home LV【cl是VG Name,据实际情况而定】
[root@itranCentOS disk]# lvcreate -L 500G -n home cl_itrancentos
Logical volume "home" created.
创建文件系统
[root@itranCentOS disk]# mkfs.xfs /dev/mapper/cl_itrancentos-home
meta-data=/dev/mapper/cl_itrancentos-home isize=512 agcount=4, agsize=32768000 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=131072000, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=64000, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
重新挂载home
[root@itranCentOS disk]# mount /dev/mapper/cl_itrancentos-home /home/
[root@itranCentOS disk]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 28G 0 28G 0% /dev
tmpfs 28G 0 28G 0% /dev/shm
tmpfs 28G 18M 28G 1% /run
tmpfs 28G 0 28G 0% /sys/fs/cgroup
/dev/mapper/cl_itrancentos-root 1.1T 13G 1.1T 2% /
/dev/sda2 1014M 238M 777M 24% /boot
/dev/sda1 599M 7.3M 592M 2% /boot/efi
tmpfs 5.5G 16K 5.5G 1% /run/user/42
/dev/mapper/cl_itrancentos-home 500G 3.6G 497G 1% /home
至此,扩容已完成。手痒的话,动动手尝试一下。