Guided LVM in Debian

I recently reinstalled one of the boxes here, Lorien, from scratch. It was a brand new SATA disk and I used the Debian Lenny beta 2 installer. I’d never tried LVM before, I’d always used “normal” partitioning, but for some reason I figured I’d give this a shot. It all worked ok, but it left one problem. The amount of space Debian allocated to the root partition was pitifully small (less than 300 megabytes), and I hit a snag when a kernel upgrade came through, and wanted to install lots of stuff in that partition. So, first of all a warning, the guided partitioning is, and always has been in my opinion, not too optimal in the way it picks spaces for partitions. Secondly, here is how I fixed it, which is a slight pain since you can’t have the root partition mounted.

Since I was going to have to resize my root partition, I used my Debian install CD again, but this time in rescue mode (just type rescue at the prompt).

Then you can get a terminal up. I had inadvertently mounted my root partition as /target, so I began by unmounting it.

umount /target

Next we need to reduce a partition. I chose to resize my home partition, original 200G to 199G, since I reckoned an extra gigabyte would be more than enough on the root partition.

# Check the filesystem
e2fsck -f /dev/lorien/home
# Make it slightly smaller
resize2fs /dev/lorien/home 199G
# We are about to play with LVM
lvchange -a n /dev/lorien/home
# Tell it to reduce the size by 1 Gigabyte
lvreduce -L-1g /dev/lorien/home
# Done with LVM
lvchange -a y /dev/lorien/home
# Check the filesystem again
e2fsck -f /dev/lorien/home

Finally, increase the size of the root partition.

# Playing with LVM
lvchange -a n /dev/lorien/root
# Increase the LV by 1 G
lvextend -L+1g /dev/lorien/root
# Finished with LVM
lvchange -a y /dev/lorien/root
# Check the file system
e2fsck -f /dev/lorien/root
# resize it
resize2fs /dev/lorien/root
# Check one last time.
e2fsk -f /dev/lorien/root
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Leave a Reply

Your email address will not be published. Required fields are marked *