If we have a dual-boot computers, especially Windows and Linux, we often get grub bootloader strucked by Windows bootloader when we reinstall windows. To restore GRUB from Linux, especially Ubuntu 11.04(Natty Narwhal), we can do the following steps :
- Prepare Ubuntu 11.04 live CD or live usb
- Set first boot on BIOS, to CD or Flashdrive
- Wait until the screen Boot Ubuntu appear, choose Try Ubuntu
- Once inside the Ubuntu Desktop, open the Terminal or press the key combination Ctrl+Alt+F2 to run terminal
- Check your Linux partition
sudo fdisk -l
- Once you know the Linux root partition, for example as on my laptop there are 2 partitions sda6 mounted as / and sda7 mounted as /home, Then do the following scripting :
sudo mount -t ext4 /dev/sda6 /mnt sudo mount -t proc proc /mnt/proc sudo mount -t sysfs sys /mnt/sys sudo mount -o bind /dev/ /mnt/dev sudo chroot /mnt/ /bin/bash
- Now we will restore GRUB to the MBR, here is the command :
grub-install /dev/sda
- Then comes a message as below:
Installation finished. No error reported. This is the contents of the device map /boot/grub/device.map. Check if this is correct or not. If any of the lines is incorrect, fix it and re-run the script `grub-install (hd0) /dev/sda (hd1) /dev/sdb
- Now we will install it into the Linux root partition, in this case my linux partition is on sda6, here is the command:
grub-install /dev/sda6
- Then comes a message like this:
grub-setup: warn: Attempting to install GRUB to a partition instead of the MBR. This is a BAD idea. grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and its use is discouraged. Installation finished. No error reported. This is the contents of the device map /boot/grub/device.map. Check if this is correct or not. If any of the lines is incorrect, fix it and re-run the script `grub-install (hd0) /dev/sda (hd1) /dev/sdb
- Now we need to update grub by typing this command:
update-grub
- The message below will appear:
Generating grub.cfg … Found linux image: /boot/vmlinuz-2.6.31-14-generic Found initrd image: /boot/initrd.img-2.6.31-14-generic Found memtest86+ image: /boot/memtest86+.bin Found Microsoft Windows 7 Loader on /dev/sda1 done
- Reboot your computer
No comments:
Post a Comment