*** This might be needed when you spin up a CentOS VM with the default file system partitioning and you want to combine ‘/home’ into ‘/’

  1. Make a new directory on the root partition
    • mkdir /home-new
  1. Sync ‘/home’ to the new directory
    • rsync -av /home/ /home-new
  1. Comment out the ‘/home’ line in /etc/fstab to prevent it from trying to mount on boot
    • vim /etc/fstab (comment out /home)
  1. Reboot server into single user or rescue mode
    • In single user mode, remove the ‘/home’ partition
    • lvremove /dev/mapper/centos-home
  1. Once the ‘/home’ partition is removed, expand the root partition
    • lvextend -l +100%FREE -r /dev/mapper/centos-root
  1. The ‘/’ logical volume has now been expanded. Expand the filesystem to fill the rest of the space
    • xfs_growfs /   (if xfs file system)
  1. Sync the directory that contains the ‘/home’ data back to ‘/home’ (it will now be on the root partition)
    • rsync -av /home-new /home
  1. Reboot
    • reboot now
  1. Once you verify functionality and validity of the /home directory, you can remove the backup directory\
    • rmdir /home-new

Leave a Reply

Your email address will not be published. Required fields are marked *