I made the mistake of accepting the default LVM options during a Debian Lenny installation, only to find out that the root / had filled up quite quickly, having started out with only around 300mb.
I wanted to transfer some free space from /home to /; so did as follows:
Select filesystem (e.g. /dev/mapper/debian-home ... 2.5G) to shrink from Filesystem column in df -h
I chose /home, so must be ssh'd as root; use 'who' command to verify no other users are logged in and have the home dir open.
Resize /home:
#umount /dev/mapper/debian-home
#e2fsck -f /dev/mapper/debian-home
#resize2fs /dev/mapper/debian-home 1G
select the corresponding volume to shrink from lvdisplay, i.e., the LV Name field (e.g. /dev/debian/home)
#lvreduce -L -1.3G /dev/debian/home
Extend root volume (/):
verify there is Free PE in vgdisplay. Check this value against the following lvextend command size option
To extend root volume (/), find it's coresponding name by looking up [LV Name] (e.g.
/dev/debian/root) containing 'root' in lvdisplay
then:
#lvextend -L +1G /dev/debian/root
resize the root file system. Find out the Filesystem name for the / mount by checking df
# resize2fs /dev/mapper/debian-root
check df to verify / is resized.
remount home:
#mount /dev/mapper/debian-home
Warning! This procedure is very risky. A full backup of the system immediately before resizing volumes is strongly advised on production systems. After the volumes are resized, run fsck to fix any errors.
refs:
ref for shrinking: http://www.linuxquestions.org/questions/linux-enterprise-47/shrink-lvm-without-dataloss-557746/
ref for extending /: http://www.linuxquestions.org/questions/linux-general-1/lvm-resizing-the-root-partition-361663/
Replace nested-if's with proper exception-handling
-
" Why handle exceptions separately:
■ Handling exceptions separately enables you to define the main logic of
your
code together.
■ Without the use of sepa...
2 years ago