BigDiver

Dive away, explore the net…

Software Raid on Ubuntu and Debian

with 9 comments

Although this procedure is not taken from the Managing RIAD on Linux, you should still get it because it is a great book!

Managing RAID on Linux

Managing RAID on Linux

After many, many attempts to get software RAID working on both Debian and Ubuntu the system would always lockup during boot and would not do any thing after that.
The system wont boot after a fresh install.

After banging my head a few hundred times I finally found a procedure that works!!!!!!

Install Ubuntu or Debian as you normally would, and configure RAID right from the installer. Once the installation is done the server will not boot, how stupid is that. what you need to do now is to insert the Ubuntu CD again and boot in Rescue mode.

Once the rescue mode reaches the disk partitioning screen press ESC and Select “Execurte a Shell” from the list.

Now mount your boot device, which you can do with

mount /dev/md0 /mntchroot /mnt

Now you should use grub to write the MBR to both disks. Type

grub

if you get an error like

'Error opening terminal: bterm'

just set your terminal to something else like so:
export TERM=linux

You may not see a clear display, meaning the lines will overlap but it works. Now run grub again.

For disk 1:

grub
device (hd0) /dev/hda
root (hd0,0)
setup (hd0)
quit

For Disk 2:

grub
device (hd1) /dev/hdb
root (hd1,0)
setup (hd1)
quit

If you’re not sure which devices you have just do:

cat /boot/grub/device.map

Should look like this:

(hd0)   /dev/hda
(hd1)   /dev/hdb

Use those! After doing this reboot your server, and you should now be able to boot your machine using RAID!
You should repeat this procedure every time you rebuild your RAID set or upgrade your Kernel.

Written by bigdiver

March 15, 2007 at 3:30 am

Posted in Debian

9 Responses

Subscribe to comments with RSS.

  1. Thanks very much for the tip! When I installed Ubuntu the system booted just fine, but this is exactly what I was trying to figure out to get the system to boot from disk 2.

    I’ve incorporated your tips into an article I just posted on my blog… http://advosys.ca/viewpoints/2007/04/setting-up-software-raid-in-ubuntu-server

    (By the way, the line breaks in the code examples in this post seem to be a little messed up)

    D Webber

    April 24, 2007 at 9:44 pm

  2. I have to congratulate you D Webber on such a well written article!
    Fixed the line breaks, thanks!

    bigdiver

    April 28, 2007 at 3:59 pm

  3. [...] root (hd0,0) setup (hd0) device (hd1) /dev/sdb root (hd1,0) setup (hd1) quit (many thanks to BigDiver for the [...]

  4. if you disconnect a drive from the array and reboot, it eventually goes to (initramfs).

    shouldn’t there be MBRs on both disks individually so that if one disk fails that it will still work until someone can attend to the failed disk?

    William

    April 23, 2008 at 7:40 pm

  5. X William:
    I’ve just tried. The MBR is there, but the behaviour is as you said, because it tries to boot on md0, which in turn cannot find sda1. But if you use mdadm to first mark sda1 as failed and then remove it from md0 (while the system is running of course), then when you reboot and phisically disconnect the drive it will boot without problems, because md0 is relying on sda2 only.

    Detestor

    July 22, 2008 at 11:31 am

  6. OK… this all looks wonderful except when chroot fails?

    Yes there are the expected files in /mnt when I mount /dev/md0 on it, but it fails anyway.

    I’ve seen the same problem on other how to articles, but no one seems to help.

    Any ideas?

    $ chroot /mnt
    chroot: cannot execute /bin/sh: No such file or directory

    Please help!

    mrd

    July 25, 2008 at 9:48 pm

  7. I ran throught this tutorial :
    http://advosys.ca/viewpoints/2007/04/setting-up-software-raid-in-ubuntu-server/

    and I’m unable to do this command :

    device (hd0) /dev/hda

    I get an error “Error 15 file not found”. However before starting grub, it was present. Any hint ?

    Manny

    September 5, 2008 at 5:16 pm

  8. Manny,

    you need to find out what file represents your disk in your install. If you have SATA disks they usually don’t mount to /dev/hdx, but /dev/sdx. So try with /dev/sda, /dev/sdb, etc

    bigdiver

    September 16, 2008 at 8:55 pm

  9. [...] root (hd0,0) setup (hd0) device (hd1) /dev/sdb root (hd1,0) setup (hd1) quit (many thanks to BigDiver for the [...]


Leave a Reply