Being st00pid with LVM

Well, this is the first entry in my st00pid category. I make quite a few mistakes when using Linux, mistakes that take time and effort to fix. From now on I’ll swallow my pride and write down, in a public place like this, about what st00pid things I do. Most importantly I’ll also write down what I did to get my Linux system back to the state it was before my brain temporarily popped out for a coffee.

I like keeping my Debian systems minimal. When running Sid there ends up being quite a few upgrades to download and when dependencies change your system ends up having “orphaned” packages, i.e. packages that were pulled in to satisfy a dependency but by now the dependent package has since moved on (or been deleted). This is of course a worrying thought, packages are installed that don’t actually need to be present on the system. My stomach’s turning. Some people use aptitude to handle this, personally I’ve never really like aptitude and I use debfoster.

Yesterday, after a sizable upgrade of my system at work I ran debfoster to prune orphaned packages. This was in fact the first time I ran it after setting up the system which resulted in quite a few questions regarding whether to keep specific packages or not. This is about the time when my brain popped out for a coffee. When asked if I wanted to keep lvm2 or not there was no brain to consult and I answered no. Had the brain been around it would have reminded me that I opted to use logical volumes on that particular machine (for two reasons, 1) I had never done it before and it’s damn cool, and 2) it makes the system a bit more flexible and future proof).

After a reboot I was sitting there with a system that was fairly useless since the root partition couldn’t be mounted. A quick calculation of just how long it’d take me to re-install later, I popped in the only live CD I had available at work–Ubuntu 5.04, Hoary Hedgehog. Using that I found a page on the Knoppix Wiki on how to use LVM2 with Knoppix. Now armed with something that looked like a workable plan I did the following in a terminal

$ sudo su -
# modprobe dm-mod
# vgscan
# vgchange -a y
# cd /mnt; mkdir debsys

Then I went ahead and mounted the root partition on /mnt/debsys. I also mounted the other partitions I have on my installed system, /var, etc. Then to get into it and fix it I

# chroot /debsys
# apt-get install lvm2 lvm-common

Except lvm2 refused to install, it complained about the kernel being too old. Not surprising since Hoary is getting really old by now. to get around that I downloaded the source for lvm2, modified debian/preinst so that the kernel version check was skipped, re-built the package, and installed it. Worked like a charm.