Resizing the root partition in CentOS

Resizing the root partition in CentOS

There are good reasons to have your home directory on a separate partition in CentOS, which is the default when you install. However sometimes, you just need the entire drive on the same partition. I ran into this while installing OpenStack, and it's one of the first things I do to prep an RDO packstack installation.

First you'll need to unmount the home directory:

root@centos:~# umount home

Then you can list your logical volumes:

root@centos:~# lvdisplay

Then you'll need to remove the partition. In my case, it was called /dev/mapper/centos-home so:

root@centos:~# lvremove /dev/mapper/centos-home

Finally, you can extend the root partition to fill the partition:

root@centos:~# lvextend -r /dev/mapper/centos-root /dev/sda2

IMPORTANT: Don't forget to remove the /home entry from /etc/fstab or it won't boot!!

Posted by in IT Consulting on Sep 01, 2017

Comments