Courtesy Jordan-U from #ubuntu (freenode.net)
Dual booting (Windows/Linux) can cause some unique situations. Windows will try to assert itself as the only game in town, which can cause grub to go into an endless boot loop. Here’s an easy way to fix grub after a Windows Install/Hiccup.
1. First boot off of a livecd You can get one here.
NOTE: 32 BIT SYSTEMS REQUIRE A 32 BIT LIVECD. 64 BIT SYSTEMS REQUIRE A 64 BIT CD TO CHROOT CORRECTLY!
2. Go to a terminal window. Let’s first mount the Linux Partition.
You will see output that looks like:
ny@Px:~$ sudo blkid
/dev/sda1: UUID=”C2B0DA3DB0DA379D” TYPE=”ntfs”
/dev/sda2: UUID=”0408bd37-4a4d-4dac-a27e-408816aecd1e” TYPE=”swap”
/dev/sda3: LABEL=”waynolnx” UUID=”338b39c2-dd06-4aab-905c-98d9d01a3240″ TYPE=”ext4″
NOTE: If you are running of the livecd, then you will need the sudo infront!
So we’re looking for /dev/sda3
NOTE: YMMV APPLIES! (Your Mileage May Vary). Mine happens to be sda3, yours might be different! Your’s might be sda5.
sudo mount /dev/sda3 /mnt
3. We are going to mount major Linux access points lets do them one at a time. First the Linux Devices Files. The –bind allows us to mount a subtree somewhere else, so it’s available in both places.
sudo mount --bind /dev/ /mnt/dev
4. Now the proc files. The proc system allows files to be generated dymanically.
sudo mount --bind /proc/ /mnt/proc
5. Now let’s mount /sys. /sys exports information from the kernel to the user space.
sudo mount --bind /sys /mnt/sys
6. Chroot to the device that we earlier mounted. Chroot (change root) changes the Linux root to be the device we mounted earlier. Note the mount point: /mnt
sudo chroot /mnt
If you get something like:
chroot: cannot run command `/bin/bash’: Exec format error
It might be because you are using a 32 bit live cd on a 64 bit system, or vice versa.
The prompt MAY change to an # (octothorpe) — no cause for alarm.
7. Finally re-install grub into the MBR (Master Boot Record)
sudo grub-install /dev/sda
Reboot and all the operating systems, Linux and Windows should be available.