The default installation of RHEL 6 and CentOS 6 will create separate LVM volumes for /home. This means much of your disk is allocated to /home when it could be used for something else. Keeping /home on a separate partition is a good idea for multi-user systems, but for machines that act as a service box, it may be wasted disk space. For example, here's a system that has 50G partitioned for /home when it's really not needed.

$ df -h
Filesystem                  Size  Used Avail Use% Mounted on
/dev/mapper/vg_repo-lv_root 148G  113G   29G  80% /
tmpfs                       499M     0  499M   0% /dev/shm
/dev/sda1                   485M  156M  304M  34% /boot
/dev/mapper/vg_repo-lv_home 47G  181M   45G   1%  /home

To remove the logical volume that stores /home and add the free space to the root partition, follow these steps:

Note: Make sure you're logged into the system at the console as a user whose homedir isn't in /home. Logging in as root usually works.

cd /
cp -Ra /home /home.bak  # Make a backup of home
umount /home
lvm lvremove /dev/vg_<hostname>/lv_home  # Remove the logical volume for home
lvm lvresize -l+100%FREE /dev/vg_<hostname>/lv_root  # Resize the root logical volume so it uses 100% of the now free space
resize2fs /dev/vg_<hostname>/lv_root  # Resize the filesystem to use the whole logical volume
mv /home.bak /home  # Restore the backup.

More Notes:

This can be done on a live system as long as /home is not in use when you try to unmount it. You can also follow these steps to resize another logical volume if it has another name and isn't in use. This may work with some adjustments on a RHEL/CentOS 5 system, I haven't tried it though.


This article was last modified: Aug. 7, 2019, 1:35 p.m.

0 Comments

Please log in to leave a comment.

Add or change tags.

A comma-separated list of tags.

Share

Hacker News

Top