Tuesday, November 1, 2011

Watch out with mdadm

I've recently bought a new rig (it's been 3 years since I bought any hardware at all, at least for major upgrades), and since I got a new set of disks too, I decided to leave my old PC running while I built the new system (thanks to SysRescCD and SSH).

So I looked once more at Gentoo-Wiki for the proper way on assembling RAID-0 using mdadm (I tend to forget things I do only once every several months). I skimmed through it the same way I skim through the Gentoo Handbook: a furious scroll until I find the thing I need. In my skimming spree, I completeley missed this:
Only <=0.9 has autodetection on startup -> YES you need an initramfs if you choose 1.x - genkernel is your friend!
(Actual content from the time I visited the page may have changed, since the page is down, I got this from Google cache, and I can't exactly remember what it said originally, but it definitely was not this or else I would have seen it)

No, of course genkernel is not your friend. In fact if you're using genkernel for your Gentoo system(s), then I suggest you be a man and start building your own kernels. If you don't have time for that, then maybe Gentoo is not for you.

Back to more RAID-y things: so is this a problem? Not necessarily, unless you are using a metadata version >0.9 for /boot or /, which of course was my case :). I spent hours debugging why Grub-1 (Grub-2.x is still hard-masked on Portage. I am all for testing masked things, but not on such delicate things as a boot loader) would refuse to install itself on the "legs" of my perfectly normal RAID-1 /boot device. And Grub was not helping either. Some error messages I got were things like:
Error 15: Device or resource is busy
Error 17: Cannot find device
Maybe they are not the exact error messages (this was a few weeks ago), but it was something along these lines. I'm putting what I remember here because I spent A LOT of time googling for it and all the hits were related to other things. Moreover, you would need an initramfs for / if you built it with the new metadata version (another thing I'm reluctant to do - initramfs that is).

So, bottom line. Just remember, your real friend is:
mdadm -e 0.90 [...]