Removing LVM2 Partitions and RAID Devices

LVM Partitions

If you decide to start your installation from the beginning (or installing another OS), you will first need to remove the LVM2 partitions and the RAID devices.

To do that, boot into a Gentoo Live DVD, at the boot menu, navigate to Gentoo x86 amd64 and press tab. At the end of the boot options, add dolvm domdadm.

Once within the LiveDVD, run something similar to the below, replacing the names to match yours. Note, you should not attempt his while any of the partitions are mounted!

lvremove -v /dev/vgssd/{lvboot,lvroot} && lvremove -v /dev/vghdd/{lvhome,lvusrportage,lvvar,lvvhdd}

Spoiler

Gentoo-20121221 ~ # lvremove -v /dev/vgssd/{lvboot,lvroot} && lvremove -v /dev/vghdd/{lvhome,lvusrportage,lvvar,lvvhdd}
Using logical volume(s) on command line
Do you really want to remove active logical volume lvboot? [y/n]: y
Creating directory “/etc/lvm/archive”
Archiving volume group “vgssd” metadata (seqno 3).
Found volume group “vgssd”
Removing vgssd-lvboot (253:4)
Releasing logical volume “lvboot”
Creating directory “/etc/lvm/backup”
Creating volume group backup “/etc/lvm/backup/vgssd” (seqno 4).
Logical volume “lvboot” successfully removed
Do you really want to remove active logical volume lvroot? [y/n]: y
Archiving volume group “vgssd” metadata (seqno 4).
Found volume group “vgssd”
Removing vgssd-lvroot (253:5)
Releasing logical volume “lvroot”
Creating volume group backup “/etc/lvm/backup/vgssd” (seqno 5).
Logical volume “lvroot” successfully removed
Using logical volume(s) on command line
Do you really want to remove active logical volume lvhome? [y/n]: y
Archiving volume group “vghdd” metadata (seqno 5).
Found volume group “vghdd”
Removing vghdd-lvhome (253:0)
Releasing logical volume “lvhome”
Creating volume group backup “/etc/lvm/backup/vghdd” (seqno 6).
Logical volume “lvhome” successfully removed
Do you really want to remove active logical volume lvvhdd? [y/n]: y
Archiving volume group “vghdd” metadata (seqno 6).
Found volume group “vghdd”
Removing vghdd-lvvhdd (253:1)
Releasing logical volume “lvvhdd”
Creating volume group backup “/etc/lvm/backup/vghdd” (seqno 7).
Logical volume “lvvhdd” successfully removed
Do you really want to remove active logical volume lvvar? [y/n]: y
Archiving volume group “vghdd” metadata (seqno 7).
Found volume group “vghdd”
Removing vghdd-lvvar (253:2)
Releasing logical volume “lvvar”
Creating volume group backup “/etc/lvm/backup/vghdd” (seqno 8).
Logical volume “lvvar” successfully removed
Do you really want to remove active logical volume lvusrportage? [y/n]: y
Archiving volume group “vghdd” metadata (seqno 8).
Found volume group “vghdd”
Removing vghdd-lvusrportage (253:3)
Releasing logical volume “lvusrportage”
Creating volume group backup “/etc/lvm/backup/vghdd” (seqno 9).
Logical volume “lvusrportage” successfully removed
Gentoo-20121221 ~ #

[collapse]

vgremove -v vghdd vgssd

Spoiler

Gentoo-20121221 ~ # vgremove -v vgssd vghdd
Using volume group(s) on command line
Finding volume group “vgssd”
Archiving volume group “vgssd” metadata (seqno 5).
Removing physical volume “/dev/md125” from volume group “vgssd”
Volume group “vgssd” successfully removed
Finding volume group “vghdd”
Archiving volume group “vghdd” metadata (seqno 9).
Removing physical volume “/dev/md127” from volume group “vghdd”
Volume group “vghdd” successfully removed
Gentoo-20121221 ~ #

[collapse]

pvremove /dev/{md125,md126,md127}
Spoiler
Gentoo-20121221 ~ # pvremove /dev/{md125,md126,md127}
  Labels on physical volume "/dev/md125" successfully wiped
  No physical volume label read from /dev/md126
  Physical Volume /dev/md126 not found
  Labels on physical volume "/dev/md127" successfully wiped
Gentoo-20121221 ~ #

[collapse]

Note, /dev/md126 was the swap drive and so not attached to the LVM.

RAID Devices

swapoff /dev/md126
mdadm --stop /dev/md{125,126,127}
mdadm --remove /dev/md{125,126,127}
Spoiler
Gentoo-20121221 ~ # swapoff /dev/md126
Gentoo-20121221 ~ # mdadm --stop /dev/md125
mdadm: stopped /dev/md125
Gentoo-20121221 ~ # mdadm --stop /dev/md126
mdadm: stopped /dev/md126
Gentoo-20121221 ~ # mdadm --stop /dev/md127
mdadm: stopped /dev/md127
Gentoo-20121221 ~ # mdadm --remove /dev/md125
Gentoo-20121221 ~ # mdadm --remove /dev/md126
Gentoo-20121221 ~ # mdadm --remove /dev/md127

[collapse]

This should wipe the bio_grub partitons.

mdadm --zero-superblock /dev/sd{a1,b1}

However, this didn’t not appear to work for me.

Spoiler
Gentoo-20121221 ~ # mdadm --zero-superblock /dev/sd{a1,b1}
mdadm: Unrecognised md component device - /dev/sda1
mdadm: Unrecognised md component device - /dev/sdb1

[collapse]

……..but hopefully won’t be an issue……..(it wasn’t.)

After that, you just need to remove the partitions as normal then reboot. I normally use GParted but you can use whatever you like.