0

Basically, I need to remove the /home mount point, and just use the / mount point.

Filesystem Size Used Avail Use% Mounted on  
/dev/mapper/rhel-root 50G 5.6G 45G 12% /
devtmpfs 7.8G 0 7.8G 0% /dev  
tmpfs 7.8G 144K 7.8G 1% /dev/shm  
tmpfs 7.8G 20M 7.8G 1% /run  
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup  
/dev/mapper/rhel-home 142G 50M 142G 1% /home
/dev/sda1 497M 157M 340M 32% /boot  
tmpfs 1.6G 20K 1.6G 1% /run/user/0  
tmpfs 1.6G 0 1.6G 0% /run/user/1000

I'm running Red Hat 7. Is there a way to do it?

3
  • Just to verify, these are logical volumes, yes? I presume so by the mapper, but want to be sure.
    – KevinO
    Nov 12, 2018 at 3:20
  • What kind of filesystem is / on? Xfs? Ext3/4?
    – Jeff Schaller
    Nov 12, 2018 at 3:22
  • filesystem is xfs
    – user235984
    Nov 12, 2018 at 4:08

1 Answer 1

6

With all warnings about having backups, use everything at one's own risk, etc. I believe the following will work, based upon LVMs and xfs.

  • Ensure all users are logged out
  • Change to the console window via Ctrl-Alt-F2
  • Login as root. Do not be a normal user and attempt to sudo, you must be root.
  • On the / drive, mkdir /tmp-home
  • cp -a /home/* /tmp-home
  • Verify that the directories have been copied
  • Edit the /etc/fstab and comment out the entry for /home
  • Unmount the /home directory: umount /home
  • Move the current /home mount point directory: mv /home /home-LVM
  • Move the tmp-home directory: mv /tmp-home /home
  • Restore the SELinux permissions: restorecon -Rv /home
  • Reboot the system

NOTE: At this point, if you have an error, you can, as root again, move the /home to a backup name (e.g., mv /home /home-failed), restore the previous mount point (mv /home-LVM /home), edit the fstab to restore the mount, and reboot, and you will be back to where you were.

(some parts of the above approach are also described here)

At this point, you will have the /home on the / LVM volume directly, and the former /home will not be mounted. Verify this situation is correct by examining mount as well as cd /home and ensure that, e.g., df -h . shows the / drive. If all is well, then you can do rmdir /home-LVM to remove the previous mount point directory. Also, you can cleanup the /etc/fstab and remove the commented entry.

You can then use the LVM commands to delete the existing /home volume, and allocate the space to the / volume.

Deleting the LVM:

  • Use vgs and lvs to list the logical volumes
  • lvremove /dev/VOLUME_GROUP/rhel-home where VOLUME_GROUP is the appropriate group
  • pvs should now show additional available space.

Allocating space to the / LVM and growing partition:

  • lvextend -L+SIZE /dev/VOLUME_GROUP/rhel-root where SIZE is the amount of space by which to increase the LVM. It looks like you could do up to -L+142G based upon the display.
  • xfs_growfs /dev/VOLUME_GROUP/rhel-root
2
  • At mv /tmp-home /home, the mountpoint is still there, so maybe that needs to be mv /tmp-home/* /home instead? Great answer, you covered everything!
    – filbranden
    Nov 12, 2018 at 10:53
  • @FilipeBrandenburger, you are correct. I'll post an edit shortly. Thank you!
    – KevinO
    Nov 12, 2018 at 13:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .