"BAD idea" warning when trying to recover Grub, after Windows removed it

Tried sudo grub-install on sda1 but it complained about being a BAD IDEA.

I had to install windows for a work related issue so I used a separate disk (I had used it for ubuntu on this computer, but bought a bigger disk so installed ubuntu on that and left the old one in in case I needed an old file). Windows installed fine but overwrote Grub. So if I choose the Ubuntu disk to boot first in BIOS I get a blank screen.

I googled and followed this advice: https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows

However, when I get down to this section:

sudo grub-install --root-directory=/media/0d104aff-ec8c-44c8-b811-92b993823444 /dev/sda1

I get this:

Attempting to install GRUB to a partition instead of the MBR. This is a BAD idea…

--recheck does nothing. Any ideas?


The bad idea warning is caused by trying to install grub onto a partition rather than a hard disk. Having booted up your Live CD,

  • when you run grub-install as per the Guide in the Ubuntu Wiki, make sure the hard drive you pass as an argument is /dev/sda, not /dev/sda1.

    That is:

    sudo grub-install --root-directory=/media/[GUID] /dev/sda
    

    Where [GUID] is the identifier of the disk you have found out using mount | tail -1

Here's why:

  • The master boot record, MBR, is the first 512 byte 'sector' of any partitioned hard disk.

    • The BIOS searches this sector when trying to find a device it can boot from.

    In the GNU/Linux system, your hard disks are all named /dev/sd[x], where x are consecutive letters. E.g.: /dev/sda and /dev/sdb. The first partition on the first disk is called /dev/sda1. The fourth partition on the seventh hard disk is called /dev/sdg4, and so on. At the very least, you'll have one partition.

  • These partitions are not searched for bootable data by the bios. As a result, grub-install [...] /dev/sda7 will issue a warning. You can install it there, but in almost any case, you shouldn't.