How to recover Ubuntu after installing Windows 7

Linux OS Topics
Post Reply
User avatar
Saman
Lieutenant Colonel
Lieutenant Colonel
Posts: 828
Joined: Fri Jul 31, 2009 10:32 pm
Location: Mount Lavinia

How to recover Ubuntu after installing Windows 7

Post by Saman » 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.
User avatar
Saman
Lieutenant Colonel
Lieutenant Colonel
Posts: 828
Joined: Fri Jul 31, 2009 10:32 pm
Location: Mount Lavinia

Re: How to recover Ubuntu after installing Windows 7

Post by Saman » Thu Sep 30, 2010 7:07 pm

Recovery Using the Ubuntu Alternate/Install CD (Method 2)

This section explains how to rescue Grub, using the Ubuntu Alternate/install CD.

1. Enter your computers BIOS to check computer can boot from CD ROM. If you can boot from CD, insert CD ROM into drive. Exit the BIOS (if needed save your settings to make sure the computer boots from the CD ROM).
2. When the Ubuntu splash screen comes up with the boot: prompt, type in rescue and press enter.
3. Choose your language, location (country) and then keyboard layout as if you were doing a fresh install.
4. Enter a host name, or leave it with the default (Ubuntu).
5. At this stage you are presented with a screen where you can select which partition is your root partition (there is a list of the partitions on your hard drive, so you are required to know which partition number Ubuntu is on). This will be dev/discs/disc0/partX, where the X is a partition number.
6. you are then presented with a command prompt (a hash).
7. type

Code: Select all

$ grub-install /dev/XXX
where XXX is the device of your Ubuntu install. (eg: grub-install /dev/""hda"" or grub-install /dev/""sdb"" ). Note: newer 2.6.xx kernels call all hard disks ""sdx"" now but not sure if grub does.
User avatar
Saman
Lieutenant Colonel
Lieutenant Colonel
Posts: 828
Joined: Fri Jul 31, 2009 10:32 pm
Location: Mount Lavinia

Re: How to recover Ubuntu after installing Windows 7

Post by Saman » Thu Sep 30, 2010 7:09 pm

Recovery Using the Unofficial Rescatux (Method 3)

Note about grub2: Rescatux can be used to restore either Grub (Ubuntu 9.04 and previous versions) or Grub2 (Ubuntu 9.10 and later versions)

* Download Rescatux
* Burn the Rescatux ISO in a cdrom
* Make your PC boot from the cdrom
* At Debian Live Boot screen just press ENTER
* Select Restore grub / Fix Linux Boot option and click on OK button
* Select the partition where your Ubuntu is and click on OK button
* Select the hard disk where you want Grub to be installed (usually the first one)
* Grub was installed OK confirmation / Grub was not installed error will appear
* Look for System -> Shutdown in the top tray in order to halt your machine
Post Reply

Return to “Linux”