Implementation method of reallocating partition size in centos7


Yesterday, I installed a system for people. I forgot to slide the automatic partition. The size of the automatic partition is speechless and not suitable for daily use.

Execute command:df -h

We can see that the system automatically allocates all the remaining space to the home partition, but we usually use the space under the root partition, so we have to move more space under home to the root partition

First, you need to back up the contents of the home folder and execute the command:cp -r /home/ homebak/(if the new system does not create other accounts, it can not be backed up.)

Uninstall home: umount /home (if there is a “home” process, use “fuser – M – V – I – K / home” to terminate the process under “home”, and finally use “umount / home” to unload / home.)

Delete home sector:lvremove /dev/mapper/centos-home

Add 100g to the sector where root is locatedlvextend -L +100G /dev/mapper/centos-root

Expand the root file system:xfs_growfs /dev/mapper/centos-root

Re create Home Lv:lvcreate -L 64G -n home centos(the 64g here is the original minus the removed space, not random filling)

To create a file system:mkfs.xfs /dev/centos/home

Mount @ home:mount /dev/centos/home /home

Return the backup to home and delete the backup;

The above is the whole content of this article, I hope to help you learn, and I hope you can support developer more.