I had to do something kind of weird the other day — I had to take my perfectly well mirrored disks and split up the raid volumes, because I wanted to start doing some testing on that server, and use the second disk for space. As it turns out, there are a great many tutorials on the vast googletrons to help you set up, manage, or break Linux raid mirrors, but not so many when it comes to wiping away all evidence that you’d ever entrusted your system to such a beast.
Well, on the bright side, at least that means I get material for a blog post out of it!
It turns out that it’s actually fairly easy to do, but a shade tricky. As you probably already know if you’ve ever had to boot off one raided disk after losing part of your mirror, there’s really nothing special about the partitions that you’ve put in your raid volumes — they’re still secretly ext3, or whichever filesystem type you’ve chosen. But the partition type is set to 0xfd, Linux raid, rather than 0×83, Linux. And the superblock is encoded with the fact that it’s a member of a raid set — which is the reason that even if you boot off alternate media with no config files or anything, it’ll see the slice’s raid information and happily treat them that way even if you are tearing your hair out with the effort to make the system see a partition as just a plain old partition.
So here’s the steps I was following to wash that raid right out of my hair:
- Used cfdisk -P r to dump out my disk partition information in case I accidentally trashed it.
- Saved my /proc/mdstat and df output so I knew which filesystems were on which partitions and wouldn’t have to bother guessing.
- Booted off alternate media. (I used a net boot server but you could use IPMI virtual media, a DVD, USB stick, etc.)
- mdadm /dev/mdX –fail /dev/sdbX to disable half of the mirror, then mdadm /dev/mdX –remove /dev/sdbX to remove it from the volume. Repeat for all slices on /dev/sdb. (I am not really certain if this step is truly necessary — but I did use it, so it’s here for completeness’ sake. If I get a chance to down-convert another raided host I’ll note this appropriately.)
- mdadm –stop /dev/md0 to stop the raid volume.
- mdadm –zero-superblock /dev/sdaX and mdadm –zero-superblock /dev/sdbX to remove the raid information from the filesystems.
- fdisk /dev/sda and fdisk /dev/sdb to change the partition types from 0xfd to 0×83.
- mount /dev/sda1 /mnt; mount /dev/sd0 /mnt/boot to mount the root and /boot filesystems from one half of the ex-mirror.
- Edit /mnt/etc/vfstab to have the new plain sdaX partitions instead of mdX volumes.
-
- Edit /mnt/boot/grub/menu.1st to have the appropriate devices as well.
- Fix any other references to /dev/mdX you might have littered around your system.
- Umount /mnt/boot and /mnt, and repeat for sdb as appropriate.
- Reboot!
It wasn’t that difficult, really. In fact, although it took me a while to bumble my way through it the first time (mostly since I wasn’t aware of the superblock aspect, and it was driving me nuts every time I’d boot up in some alternative fashion and it would resurrect my raid volumes from the should-have-been-dead), it would probably take me all of about 15 minutes to do now, and most of that would be time spent rebooting.
Of course, after all the fuss, we ended up not really using that machine as a test host after all, but at least it was a good learning opportunity. It’s not nearly often enough that you get the chance to potentially totally blow up all your filesystems with no consequences. :)