This requires you to be able to ssh into the instance using the root user account and that no services be running as users out of /home on the target machine.
The examples are from a default installation with no customation-you NEED to know what you're working with for volumes/partitions to not horribly break things.
By default, CentOS 7 uses XFS for the file system and Logical Volume Manager (LVM), creating 3 partitions: /,/home and
[root@cdpnodes ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 16G 9.0M 16G 1% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/mapper/centos-root 50G 1.5G 49G 3% /
/dev/mapper/centos-home 350G 1.5G 49G 1% /
/dev/sda1 1014M 154M 861M 16% /boot
tmpfs 3.2G 0 3.2G 0% /run/user/1000To backup the contents of /home, do the following:
cp -a /home /tmp/Once that is finished at your back at the prompt, you can proceed to step 2.
umount -fl /homeWe run the lvs command to display the attributes of the LVM volumes
lvsSample output:
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home centos -wi-a----- 93.24g
root centos -wi-ao---- 50.00g
swap centos -wi-ao---- 15.75g lvremove /dev/mapper/centos-home这里需要注意,如果遇到了‘contains a filesystem in use’,可能是前面的umount没有成功。可以再运行一遍,sudo umount -fl /dev/centos/home,然后再试试lvremove是否可以运行;实在不行,需要运行fuser -km /home 如果没有fuser,则需要yum install psmisc 同时注意不要在/home folder下运行 同时注意,运行完以后会断开当前的ssh连接,需要再次以root用户连接。所以注意下。 重新连接之后再运行 lvremove /dev/mapper/centos-home
Based on the output of lvs above, I can safely extend the root LVM by 90GiB.
lvextend -L+200G /dev/mapper/centos-rootxfs_growfs /dev/mapper/centos-root这一步对我的系统是
xfs_growfs /估算一下现在总计多少空间
lvcreate -L 230G -n /dev/mapper/centos-home
mkfs.xfs /dev/mapper/centos-home
mount /dev/mapper/centos-homecp -a /tmp/home /rm -rf /tmp可以参考https://blog.51cto.com/mflag/5357602
Using your preferred text editor, ensure you open /etc/fstab and remove the line for /dev/mapper/centos-home.
Run the following command to sync systemd up with the changes.
dracut --regenerate-all --force好像这一步会造成/home不能挂载。在Centos8上我遇到了。
磁盘空间不足的解决办法