How to unscrew your LVM

I had a system with a single 40Gb PATA drive in it. It had two 160GB SATA drives in it too, but the SATA controller on the motherboard was not supported yet by Fedora Core 5. (It’s a VIA controller. VIA has drivers, but they aren’t stable yet)

I got a 2-port Adaptec SATA controller, hooked it up while moving the machine to a 3U case, and booted. Great, everything works.

I then added the two new volumes to my “VolGroup00”, and took the system down to the colo. Oh. shit. It won’t boot.

Why? because the initrd for the system didn’t have the Adaptec controller, so the system couldn’t see the extra physical volumes, so it couldn’t construct the logical volume group, so it couldn’t find the “root” disk.

DAMN.

I booted a Fedora Core 5 rescue CD. (I am, btw, looking for a 30-50Mb image that I can stick on /boot, and invoke from grub, which would be a serial-console happy rescue image. It should have sshd, and be able to dhcp an address ideally…. I was going to take apart some CD-based .iso, but I haven’t done hat yet)

I then fixed this by running mkinitrd properly, and the system found the right disks, and booted.

I thought: I don’t want all my disks in the same volume group if a screw up will prevent the system from booting.

I came across the command “pvremove”, which I proceeded to run on /dev/sda1 and /dev/sdb1. OOPS. System won’t boot again, because I actually destroyed the physical volumes (from LVM’s point of view), not removed them.

Another run through with the rescue CD. Need to figure out what to do. The command “lvm” is nice, because as a wrapper around all the commands, it also tells you quickly what are actual commands and not.

The solution:

lvm> vgreduce VolGroup00 --removemissing Couldn't find device with uuid 'nwprFB-HWF3-GRL7-ow4P-JUXO-Zp2J-ckZ8fe'. Couldn't find all physical volumes for volume group VolGroup00. Couldn't find device with uuid 'nwprFB-HWF3-GRL7-ow4P-JUXO-Zp2J-ckZ8fe'. Couldn't find all physical volumes for volume group VolGroup00. Couldn't find device with uuid 'nwprFB-HWF3-GRL7-ow4P-JUXO-Zp2J-ckZ8fe'. Couldn't find device with uuid 'tLpEoy-X3jh-7QgU-oWTY-dmrh-4dKx-jCOLVm'. Wrote out consistent volume group VolGroup00

Now, I have:

trout-[~] root 1 #lvs LV VG Attr LSize Origin Snap% Move Log Copy% FlorinRoot GuestGroup00 -wi-a- 5.00G LogVol00 VolGroup00 -wi-ao 35.19G LogVol01 VolGroup00 -wi-ao 1.94G trout-[~] root 2 #pvs PV VG Fmt Attr PSize PFree /dev/hdb2 VolGroup00 lvm2 a- 37.16G 32.00M /dev/sda1 GuestGroup00 lvm2 a- 149.05G 144.05G /dev/sdb1 GuestGroup00 lvm2 a- 149.05G 149.05G trout-[~] root 3 #vgs VG #PV #LV #SN Attr VSize VFree GuestGroup00 2 1 0 wz--n- 298.09G 293.09G VolGroup00 1 2 0 wz--n- 37.16G 32.00M