Merge (or Resize) the /home partition on CentOS 7

CentOS7 by default partitions your storage by putting a large amount of space in the /home directory partition. For most use-cases, this is perfectly fine. However, if you're working with limited space, and have already installed a default install of CentOS, you may find you need to reclaim some of the space in your /home parition for use with other partitions.

Before continuing, you will want to MAKE A BACKUP OF YOUR /HOME DIRECTORY if there's anything in it you want to keep. Once you've got your files backed up, you can merge your /home partition with your /root partition using the following commands. I'll show you the output as well so you can know what to expect.

[root@localhost ~]# umount /home

[root@localhost ~]# lvremove /dev/centos/home
Do you really want to remove active logical volume centos/home? [y/n]: y
  Logical volume "home" successfully removed

[root@localhost ~]# lvextend -l +100%FREE /dev/centos/root
  Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to <444.81 GiB (113871 extents).
  Logical volume centos/root successfully resized.

[root@localhost ~]# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=3276800 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=13107200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=6400, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 13107200 to 116603904

[root@localhost ~]#

Next you'll need to edit your /etc/fstab file so that CentOS doesn't try to mount a /home partition that no longer exists. Just edit /etc/fstab in your preferred editor and remove or comment out the following line:

/dev/mapper/centos-home /home                   xfs     defaults        1 2

That's it! Your root directory should now have all the space that used to be allocated to your /home directory and you should be good on your next reboot as well.

Hope this helps.


Write your comment

(it will not be displayed)

Leave this field empty: