记录对 /root 目录的扩容
问题:/root
的空间用满了
本来打算直接动态扩容,也就是按鸟哥写的放大LV容量,把 /home
的空间分点给 /root
。结果发现 xfs 文件系统只支持动态增加,不能减少。因此咱只能备份重装了。
解决:
1 我的版本
$ cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core)
|
2 分区情况
CentOS 的 /root
和 /home
目录使用了LVM(逻辑卷分区)
我准备给 /root
加100G,把 /home
改为700G,预留 50G
$ df -hl Filesystem Size Used Avail Use% Mounted on /dev/mapper/cl-root 50G 46G 5.0G 91% / ... /dev/mapper/cl-home 849G 220G 629G 26% /home ...
$ lvdisplay ... --- Logical volume --- LV Path /dev/cl/home LV Name home VG Name cl ... LV Size <849.07 GiB Current LE 217361
--- Logical volume --- LV Path /dev/cl/root LV Name root VG Name cl ... LV Size 50.00 GiB Current LE 12800
|
3 备份 /home
$ tar cvpfz /mnt/data/homeback.tgz /home
|
4 删除 /home
$ fuser -km /home/
$ umount /home
$ lvremove /dev/mapper/cl-home
|
5 扩容 /root
$ lvextend -L +100G /dev/mapper/cl-root
$ xfs_growfs /dev/mapper/cl-root
|
6 恢复 /home
$ lvcreate -L 700G -n /dev/mapper/cl-home
$ mkfs.xfs /dev/mapper/cl-home
$ mount /dev/mapper/cl-home /home
$ tar xvpfz /mnt/data/homeback.tgz -C /
|
7 检查结果
$ df -hl Filesystem Size Used Avail Use% Mounted on /dev/mapper/cl-root 150G 46G 105G 31% / ... /dev/mapper/cl-home 700G 220G 480G 32% /home
$ vgdisplay --- Volume group --- VG Name cl Cur LV 3 ... VG Size <930.51 GiB PE Size 4.00 MiB Total PE 238210 Alloc PE / Size 225648 / <881.44 GiB Free PE / Size 12562 / 49.07 GiB
$ lvdisplay --- Logical volume --- LV Path /dev/cl/root LV Name root VG Name cl ... LV Size 150.00 GiB Current LE 38400
--- Logical volume --- LV Path /dev/cl/home LV Name home VG Name cl ... LV Size 700.00 GiB Current LE 179200
|