How to recover Ubuntu after installing Windows 7
Posted: Thu Sep 30, 2010 7:03 pm
This method allows you to restore GRUB and keep the Windows bootloader as your primary bootloader. Thanks to Ubuntu's support for NTFS writing this method is now quite simple.
The previous method puts GRUB back on the MBR (Master Boot Record) of the hard drive instead of in the root partition. Should you not wish to do so, for instance if you use a third-party boot manager like Boot Magic or System Commander, this next suggestion will be helpful. Another reason to prefer this method is for when restoring the Grub menu after a re-ghosting. In either case, use this alternative.
Restoring GRUB
1. Boot from a Live CD, like Ubuntu Desktop, or similar. It is recommended to use Ubuntu 9.04 or newer as this has NTFS write support.
2. Open a Terminal. Open a root terminal (For non-Ubuntu live CDs type su the terminal. For Ubuntu based distros run sudo -i) Enter root passwords as necessary.
3. Type grub which makes a GRUB prompt appear.
4. Type find /boot/grub/stage1. You'll get a response like "(hd0)" or in my case "(hd0,3)". Use the output from this command for the following commands.
Note:
You should have mounted the partition which has your Linux system before typing this command. (e.g. In Knoppix Live CD partitions are shown on the desktop but they're not mounted until you double-click on them or mount them manually)
5. Type root (hd0,3) note the space between root and (hd0,3).
6. Type setup (hd0,3) into the prompt. This is key. Other instructions say to use "(hd0)", and that's fine if you want to write GRUB to the MBR. If you want to write it to your Linux root partition, then you want the number after the comma, such as "(hd0,3)".
7. Type quit
8. At this stage you can either restart the system and install your own bootloader, or you can continue and tell the Windows bootloader where to find GRUB which will handle booting Linux.
The previous method puts GRUB back on the MBR (Master Boot Record) of the hard drive instead of in the root partition. Should you not wish to do so, for instance if you use a third-party boot manager like Boot Magic or System Commander, this next suggestion will be helpful. Another reason to prefer this method is for when restoring the Grub menu after a re-ghosting. In either case, use this alternative.
Restoring GRUB
1. Boot from a Live CD, like Ubuntu Desktop, or similar. It is recommended to use Ubuntu 9.04 or newer as this has NTFS write support.
2. Open a Terminal. Open a root terminal (For non-Ubuntu live CDs type su the terminal. For Ubuntu based distros run sudo -i) Enter root passwords as necessary.
3. Type grub which makes a GRUB prompt appear.
4. Type find /boot/grub/stage1. You'll get a response like "(hd0)" or in my case "(hd0,3)". Use the output from this command for the following commands.
Note:
You should have mounted the partition which has your Linux system before typing this command. (e.g. In Knoppix Live CD partitions are shown on the desktop but they're not mounted until you double-click on them or mount them manually)
5. Type root (hd0,3) note the space between root and (hd0,3).
6. Type setup (hd0,3) into the prompt. This is key. Other instructions say to use "(hd0)", and that's fine if you want to write GRUB to the MBR. If you want to write it to your Linux root partition, then you want the number after the comma, such as "(hd0,3)".
7. Type quit
8. At this stage you can either restart the system and install your own bootloader, or you can continue and tell the Windows bootloader where to find GRUB which will handle booting Linux.