Resizing LVM Mounts

A common problem for me has been needing to resize an LVM partition. This works fine if you’re dealing with a non-critical mount point like /home that you can afford to take down while the system is online, but what if you need to resize /usr or /var for instance? The easiest method I found is to utilize the CentOS 6.2 LiveCD – it has all of the tools you need out of the box so there’s no need to install extra packages to make it work. Say you wish to steal 1G from /var and add it to your / partition. You’ll need to note the physical location of those mount points (a quick cat of /etc/fstab will yield you that). For me, / was mounted to /dev/mapper/VolGroup00-LogVol00 and /var was mounted to /dev/mapper/VolGroup00-LogVol03. Boot in through the LiveCD and run the following as root:

e2fsck -f /dev/mapper/VolGroup00-LogVol03
resize2fs /dev/mapper/VolGroup00-LogVol03 1G
lvreduce -L -1G /dev/mapper/VolGroup00-LogVol03
lvextend -L +1G /dev/mapper/VolGroup00-LogVol00
e2fsck -f /dev/mapper/VolGroup00-LogVol00
resize2fs /dev/mapper/VolGroup00-LogVol00

Copyright © All Rights Reserved · Green Hope Theme by Sivan & schiy · Proudly powered by WordPress