How do I install GRUB on a RAID system installation?

188,493

Solution 1

My problem turned out to be that I had GUID partition table since my drives were 2TB each. The method I originally tried to follow didn't assume this, and so installing GRUB didn't work.

Instead, you should make a small (1MB) partition on each disk and RAID them together and set it as a GRUB boot partition (I'm not sure of the actual name). Set up your other RAID partitions (e.g. swap and /) and then the GRUB installer should find the boot area just fine.

(On Debian this is called a reserved BIOS boot area.)

Solution 2

Many of the answers here are just plain incorrect, telling you to disable BIOS RAID! The correct solution is at this blog entry. I'll summarize it below.

At the stage of the install where it is attempting to install GRUB it will detect as

/dev/mapper

This is incomplete! That's why the GRUB install fails.

You need the actual name of the RAID array to install to. So during that step, press ctrl+alt+F2 to drop to a busybox terminal, then enter

ls -l /dev/mapper

Pick out the name of your array from the list shown, then press ctrl+alt+F1 to switch back to the install (you can switch back and forth as much as you like with no problems) and enter it in the field as

/dev/mapper/{your array name}  

then GRUB installs perfectly and you're ready to go, with a proper BIOS RAID array intact.

Solution 3

A slight variation on @root45's recipe got me going (on an Ubuntu-only system). I didn't make the bootable partition part of the Raid array.

I created a small bootable GRUB partition (I chose the partition editor's option: "use is 'bootgrub'" or something similar) and did not make it part of the Raid device along with the swap and data (/) partitions.

You can rewrite the Grub2 data to the 'bootgrub' partition at any time .... as indeed the installation process will, on your behalf, when given the choice after all your selected packages have been installed; or at any time later if corrupted with grub-install /dev/sda changing the 'sda' to the device of the partition you used in 'step one' above to be 'used as "bootgrub"'.

If you choose to cause the installing of the many packages in a LAMP server, for example, it can be quite a while after partitioning before you get asked about writing the Grub2 data to the hard disk ... and the defaults it offered at that time caused an error until I supplied my "bootgrub" partition's device ... and all went OK and I have a viable system now.

Solution 4

I can't help with installing grub now but what i did to get my RAID running is i followed this instruction:

How To Install Ubuntu 8.04 With Software RAID1 | HowtoForge - Linux Howtos and Tutorials and install grub on every raid partition (not swap).

This will be helpful when one HDD fails there's still a working grub.

Share:
188,493
Kris Harper
Author by

Kris Harper

Updated on September 18, 2022

Comments

  • Kris Harper
    Kris Harper almost 2 years

    I'm trying to setup and install Ubuntu on a RAID 1 setup. I have two disks, sdb and sdc. I've been following this guide

    https://help.ubuntu.com/community/Installation/SoftwareRAID

    which more or less works for getting everything set up and Ubuntu installed. The problem is at the end of the installation, it tries to install GRUB. By default it tries my "first disk", which gives a "fatal error". I've tried installing it on a specific partion, e.g. sdb1 as well as RAID devices, e.g. md0, md1, etc.. Nothing seems to work.

    The actual error is

    Unable to install GRUB in /dev/sdb

    Executing 'grub-install '/dev/sdb' failed.

    This is a fatal error.

    Then I'm taken back to the main install menu. If I choose "Install the GRUB boot loader on a hard disk" option, I can pick the partition, but entering sdb2 or md1 gives the same error.

    So I went ahead an just didn't install GRUB, which means now I presumably have a working Ubuntu installation, but I can't boot it. I've tried booting from the LiveCD to install GRUB, but I can't chroot into my system because it doesn't seem to recognize that my disk is a Linux disk. There's an error about it being a RAID partition.

    So basically I would really like to know how you know to which device to install GRUB at installation, or at the very least, how to install it on to my system now.

    I suppose I should also mention that sda is a Windows 7 installation that I would like to keep around and be able to access at boot.

    Thanks for any help.

  • Kris Harper
    Kris Harper about 13 years
    When I create my first partition (for the filesystem), I can't set that partition to be bootable. The option is there, but if I select it, it just flickers and says "bootable flag: no". I went ahead and installed it anyway, but I still got the same error when it came to install GRUB.
  • crazyTechie
    crazyTechie about 13 years
    Hmm i didn't hear about such kind of behavior before. What's the exact configuration you used to set up your raid.
  • Kris Harper
    Kris Harper about 13 years
    I have three disks, sda is Windows 7. The others, sdb and sdc are blank when I start. When I get to the partition manager, I make a new partition on each drive for the filesystem. Your linked guide says to set this as "physical volume for RAID", rather than "Ext4 filesystem", so I did that. But this means I can't set the bootable flag. I made the rest of the drive swap and did the same on the other drives.
  • crazyTechie
    crazyTechie about 13 years
    It seems to me you don't follow the instructions all the way. After you created the raid volumes you have to map them into a raid after that you assign the file system e.g. ext4 after that you can assign the bootable flag. You need to create 2 raid partitions on each drive one for swap one for /.
  • Kris Harper
    Kris Harper about 13 years
    Well I did that eventually. But your guide says "Make the partition bootable" before creating the software RAID, and the installer won't let me do that. I went through with the installation and created the RAID, then assigned / and swap to the two RAID devices. But there's still an error when it tries to install GRUB.
  • crazyTechie
    crazyTechie about 13 years
    Hmm, ok sorry i couldn't be of any more help.
  • psusi
    psusi about 13 years
    Instructions mentioning the boot flag are usually wrong. Linux does not use the msdos boot flag at all. It sounds like you are indeed using a GPT partition table since the boot flag and raid are mutually exclusive on GPT. You need to create a small ( 1 mb ) partition flagged as bios_boot to install grub on GPT.
  • Brian Bauman
    Brian Bauman over 11 years
    What if ls -l /dev/mapper shows nothing but "control" as its contents?
  • Jeff Atwood
    Jeff Atwood over 11 years
    I'm not sure. I suspect you don't have BIOS RAID aka "fake" RAID at that point then?
  • Brian Bauman
    Brian Bauman over 11 years
    I complete the partitioning and installation as per usual, and the installation then fails at GRUB installation. I'm not sure why the RAID wouldn't be initiated at that point, since the installation was specifically to the three raid arrays I built - raid1 /, raid0 swap, and raid1 /home.
  • Brian Bauman
    Brian Bauman over 11 years
    Ah yes - now reminded of why I abandoned that approach a few months back - Ubuntu only detects 800GB or so of the BIOS RAID. Having to space out a build over months makes it easy to forget things!
  • Mr.Gosh
    Mr.Gosh almost 9 years
    this just works for raid1 - i was trying this for raid6 and it just keeps failing without a helping error message :(
  • c33s
    c33s over 8 years
    how have your created the software raid? i am currently trying to do the same. see my question on serverfault: serverfault.com/q/749274/71452