Recently I ran across a bit of an issue in my installation of CentOS 7, where I needed to increase the size of ROOT partition by reducing the size of HOME logical volume. I’ve resolved the problem by moving free space from HOME to ROOT volume.
So originally the situation looked like this:
or in Webmin (under Logical Volume Management tab) like this:
This is what I wanted to achieve:
- Reduce size of HOME from 180 GB to 5 GB
- Extend size of ROOT by 175 GB from 50 GB to 225 GB
Without much of thinking, first step I took was to go to Webmin LVM tab, clicked on Logical Volumes, selected HOME a decided to change the volume size to 5GB, like this:
Upon saving, this resulted in an error saying: “The filesystem on this logical volume cannot be shrunk while it is mounted”.
Realizing above wouldn’t work, I followed by taking these steps:
Created a new temporary HOME 2 directory /home:
Then copied content of HOME to HOME2 directory by running following command:
cp -r /home/* /home2
Then un-mounted HOME:
Then removed HOME logical volume entirely:
Once this was done, I went back to Webmin LVM tab, clicked on Logical Volumes and towards the bottom, I’ve clicked on ‘Create a logical volume in centos’ option, I’ve created a new HOME logical volume and assigned to it 5GB. So it looked like this:
Next step was to copy content of HOME2 to HOME directory:
cp -r /home2/* /home
And deleting home2 directory:
rm -r /home2
As a last step, all I needed to do was to go back to Webmin LVM tab, click on Logical Volumes, select ROOT logical volume and change the volume size from 50GB to maximum available space. This can be done without any manual calculation by using option: ‘Use all free VG space‘ and pressing the SAVE button.
Once done, resulting volumes are re-sized exactly as I wished:
I hope this gives you some idea how to go about the process on your own.