Tag Archives: MBR

So.. My trusted 5 old Seagate HDD crashed on me during a reboot. Grub was installed on its MBR and hence I couldnt even boot to my Windows 8 partition and Gentoo without reinstalling Grub.

While trying to do it from a Ubuntu LiveCD, I found that it wouldnt boot at all. I found a Debian LiveCD and managed to boot to terminal based Rescue mode and run e2fsck on the HDD. But surprise, surprise..No errors on the Seagate HDD were found. Only my Hitachi containing Gentoo was present on it. Ubuntu was on Seagate. I had just upgraded to Kubuntu 12.10 yesterday after a painful upgrade process. Painful because of my slow internet speeds.

Anyway, I got Debian and fixed the disk. I then tried to fix the Grub2 with Debian, but it seemed to have issues even doing a chroot. Finally I booted off the Ubuntu LiveCD and initially having i get stuck at boot.

The solution to boot the Ubuntu LiveCD was to do a acpi=off, noapic, nolapic option. To get this, press any key during boot when the pink Ubuntu screen shows up with a small icon at the bottom. Now you get a full fledged boot menu, Hit F6 after choosing your language and choose the options mentioned. Now it ought to boot.

Once booted, type “Terminal” in Unity, and get to the shell. Alternately, you can Hit Ctrl-F1-6 for shell. Hit Ctrl-F7 to get back.

Now, locate the disk where your boot partition is located with:

sudo parted -l


Find the ext4 partition(s), mount it, chroot to it.

sudo mount /dev/sda7 /mnt


ls -l /mnt will show you whether /mnt/boot is present. If not, you chose the wrong disk.

sudo mount --bind /dev /mnt/dev

sudo mount --bind /proc /mnt/proc

sudo chroot /mnt

Note: For a split boot an / partition, you need to first mount your partition containing /, to /mnt; then mount the partition for /boot, to /mnt/boot.

Now you’re in your old linux installation. You can now install Grub.

sudo grub-install /dev/sda


Note that this is the main disk and not an individual partition. You need to install it to MBR (in my case).

After rebooting, you will find grub installed. However Windows might be lost from grub menu. You can readd it with the following commands:

sudo su -

After rebooting, you’ll get Windows back on the grub2 list. If you need Windows to always come first in the menu, do this.

Since my distro was Gentoo, I found an issue. It gave me an error:

/dev/root: Not found or not a block device.[/code]
To fix, I had to do an additional command:
grep -v rootfs /proc/mounts > /etc/mtab


Details here

The command actually sends the entire list of partition info to the file mtab.

Now repeat the command and it works:

sudo grub-install /dev/sda

Read more:




So, I had Windows 7, Ubuntu happily coexisting with a Grub2 on MBR. I installed Windows 8 as a fresh installation after deleting the Windows 7 files (Program Files and Windows directory) to preserve my data, and as expected the Windows 8 Bootloader overwrote Grub2, leaving me with no option to Boot into Ubuntu.

The following is the procedure I followed to recover Grub:

Boot into a Live CD of Ubuntu.

Run a terminal as root and get the hang of the partitions:

[email protected]:~$ sudo su
[email protected]:/home/ubuntu# fdisk -l

Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00073736

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 186062847 93030400 7 HPFS/NTFS/exFAT
/dev/sda2 186062848 248309759 31123456 7 HPFS/NTFS/exFAT
/dev/sda3 248309760 268789759 10240000 83 Linux
/dev/sda4 268789760 625141759 178176000 5 Extended
/dev/sda5 549278478 592364744 21543133+ 83 Linux
Partition 5 does not start on physical sector boundary.
/dev/sda6 592375808 625141759 16382976 82 Linux swap / Solaris
[email protected]:/home/ubuntu#


Now, we bind the device which contains the Linux partition Boot (typically the First Linux partition)-/dev/sda3 in my example.

mount /dev/sda3 /mnt
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
cp /etc/resolv.conf /mnt/etc/resolv.conf
chroot /mnt
(This takes a few seconds)
grub --install --recheck /dev/sda


Note that the last command reinstalls grub to a location. In my case, I wanted to install to MBR of my first hard disk, so I used /dev/sda (Not /dev/sda3)
This procedure replaces the Windows 8 bootloader from MBR, in addition it also checks all the installed OSes that it can find on your system and adds entries for these to the new grub configuration file.

The process is now over and you can reboot now!