Skip to content

Instantly share code, notes, and snippets.

@iamthemovie
Last active August 29, 2015 14:03
Show Gist options
  • Save iamthemovie/a1176a1d7bf570828b93 to your computer and use it in GitHub Desktop.
Save iamthemovie/a1176a1d7bf570828b93 to your computer and use it in GitHub Desktop.
lvm-resize-root-remove-home
# This is a quick guide on how to resize your lvm_root to the full size
# of your disk by removing the lvm_home partition.
#
# This assumes you have just done a fresh install CentOS6 / RHEL6
# and therefore there should be no data in /home.
#
# MAKE SURE YOU BACK ANYTHING IMPORTANT UP
#
# This can cause filesystem issues if you get this wrong
# so please be careful.
#
# Replace {name} with the appropriate path
# to find this run:
#
# $ ls /dev/vg_*
#
# Look for vg_{hostname}
#
# MUST BE SUDO
#
# Unmount
unmount /home
# Remove the home logical volume
lvm lvremove /dev/vg_{name}/lv_home
# Resize our root logical volume
lvm lvresize -l+100%FREE /dev/vg_{name}/lv_root
# Resize the file system
resize2fs /dev/vg_{name}/lv_root
# IF YOU DO NOT DO THE BELOW YOUR MACHINE WILL BOOT AND MOUNT A READONLY FILESYSTEM
#
# IMPORTANT: Ensure you edit your FSTAB and remove the directive that mounts lvm_home
#
# If you forget, then just mount the filesystem as writeable and edit the FSTAB then reboot.
vi /etc/fstab # Use nano or whatever else that makes you feel happy
# Comment out the line which looks like this
THIS: /dev/mapper/vg_{name}-lv_home /home ext4 defaults 1 2
TO THIS: # /dev/mapper/vg_{name}-lv_home /home ext4 defaults 1 2
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment