Room 118 Solutions - Web Application Development & Programming

Ubuntu 10.10 Server + GRUB + GPT Partitions

So, I ran into a peculiar problem while trying to get my homebuilt 4TB NAS up and running last night.  I bought two 2TB SATA drives, and sourced everything else from my old computer boneyard (i.e. my closet).  The issue I was having was the Ubuntu 10.10 Server installer kept failing when trying to install GRUB.  I eventually tracked this down to an issue installing GRUB to GPT partitions (GRUB requires a BIOS boot partition).  Since I’m running a small 5GB partition in RAID1 for Ubuntu, and the rest of the disks (~4TB) in RAID0, I’m exceeding the partition size limitations of MBR, and thus need to use GPT.  Fine.  The issue is that the Ubuntu installer seems to be unaware of how to handle this situation.  Long story short, here’s what you need to do when yours fails:

  1. Switch to a virtual console (ctrl + alt + F2)
  2. Chroot into your new Ubuntu environment (the GRUB install happens towards the very end, so Ubuntu is more or less set up at this point).  For this example, let’s assume your root is /dev/md0, and it’s a RAID1 array consisting of partitions on /dev/sda and /dev/sdb.  Adjust accordingly.
    # mkdir /mnt/ubuntu
    Update: A few people have mentioned that their fs is not mounted at this point, and it appears that I did miss that step (*smacks head*), sorry about that! I’m writing this next line from memory, I need to run through this again to test, but your RAID array should be up and running at this stage, so simply mounting it to your new /mnt/ubuntu directory will work. Replace the ‘x’ in mdX with the number of the array / resides on (0 in my case).
    # mount /dev/mdX /mnt/ubuntu
    # mount -o bind /dev /mnt/ubuntu/dev
    # chroot /mnt/ubuntu /bin/bash
  3. Now you’ll be at a BASH prompt, chroot’d into your fresh Ubuntu install.  Let’s fire up GNU parted and get the first disk going.
    root@host:/# parted /dev/sda
  4. Hopefully, Ubuntu started the first partition of each drive at least 32kiB in, giving us enough room to stick a BIOS boot partition on each drive.  If not, you’ll need to use parted to recreate your entire partition table, then restart the installation, and let the Ubuntu install work with your partition structure (i.e. don’t let it make its own).
    (parted) mkpart grub 0 1MB
    Ignore whatever warning it gives you, and/or accept whatever rounded partition boundaries it gives you.
  5. Now we need to set the grub_boot flag on that partition.  Let’s find out what partition number it is
    (parted) print
    Replace <part number> with the partition number for the topmost partition.
    (parted) set <part number> bios_grub on
  6. That’s it.  Quit parted.
    (parted) quit
  7. Repeat from step 3 for your other drive(s)
  8. Now that you’ve created a BIOS boot partition on each drive in the array, we can clean up and continue with the install.
    root@host:/# exit
    # umount /mnt/ubuntu/dev
    # umount /mnt/ubuntu
    # exit
  9. Switch back to the first console, where the installer is running (ctrl + alt + F1) and try to re-run the grub install.  If it fails again, you can mount the new system again, chroot back into it (step 2), and run grub-install on both drives (i.e. ‘grub-install /dev/sda’ and ‘grub-install /dev/sdb’).  This should get you back on track.  Worst case scenario, you may need to restart the Ubuntu install, just have it leave your partition table alone, and the GRUB install will go smoothly.

Hopefully this saves you several late-night hours.

Jim Ryan

About Jim Ryan

Jim has been working with computers for as long as he can remember. He started programming when he was 12, and developed his first web application for hire when he was 16. Jim is as adept with hardware as he is with software. He's worked with countless languages on a variety of platforms, from gaming consoles to Android handsets to desktop applications, but his first and true love will always be the Web. For Jim, coding is more than a hobby or a job, it's his passion.

When he's not at his computer (which is rare), Jim's exploring Manhattan or enjoying a nice (gluten-free) meal with friends. He loves meeting new people, whether it be at home or when traveling the globe. Jim tries to learn something new everyday.

View all posts by Jim Ryan →