Diff for "RestoreUbuntu/XP/Vista/7Bootloader"


Differences between revisions 11 and 12
Revision 11 as of 2012-11-19 12:12:41
Size: 6671
Editor: coffeecat
Comment: Tidy formatting
Revision 12 as of 2012-11-19 14:16:28
Size: 6063
Editor: yannubuntu
Comment: improved method via Ubuntu disc
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
#title How to Restore the Ubuntu/XP/Vista/7 Bootloader
Line 8: Line 9:
= How to Restore the Ubuntu/XP/Vista/7 Bootloader =

This wiki is for windows dual booters who reinstall an operating system only to find that it has taken away access to their other operating system.
 This wiki is for Windows dual booters who reinstall an operating system only to find that it has taken away access to their other operating system.
Line 15: Line 14:
 If you have made a mistake and want to revert the changes, simply follow the instructions for reinstalling the previous bootloader. For example, if you have installed vista over ubuntu, try to get the ubuntu bootloader back, but want to get the vista bootloader back, simply follow my instructions for installing the vista bootloader.  If you have made a mistake and want to revert the changes, simply follow the instructions for reinstalling the previous bootloader. For example, if you have installed vista over ubuntu, try to get the ubuntu bootloader back, but want to get the vista bootloader back, simply follow the instructions for installing the vista bootloader.
Line 18: Line 17:
= How to restore the Ubuntu grub bootloader (10.04 and above) = = How to fix the Ubuntu GRUB bootloader =
Line 22: Line 21:
= How to restore the Windows XP Bootloader = = How to fully fix the Windows bootloader using a Windows disk =
Line 24: Line 23:
 For this you will need your Windows XP installation CD or [[http://www.bleepingcomputer.com/forums/topic270018.html|XP Recovery console]]. Boot into it now. == XP ==

 B
oot on your Windows XP installation CD or [[http://www.bleepingcomputer.com/forums/topic270018.html|XP Recovery console]].
Line 29: Line 30:

Line 49: Line 48:
= How to Restore the Windows Vista or 7 Bootloader = == Windows Vista or 7 ==
Line 51: Line 50:
 To restore the Windows Vista/7 bootloader, you must first boot off your Windows Vista/7 installation DVD.  First boot on your Windows Vista/7 installation DVD.
Line 53: Line 52:
 When you get to the Regional settings, select your Location/Keyboard setting then click next. On the next page you must click on "Repair your computer."  When you get to the Regional settings, select your Location/Keyboard setting then click next. On the next page, click on "Repair your computer."
Line 56: Line 55:
 Then click on "Command prompt". From there, type in the folowing:  Then click on "Command prompt". From there, type in the following 2 commands:
Line 70: Line 69:
 Take out your Vista/7 DVD and hopefully, you will be left with your Windows Vista/7 Bootloader.  Take out your Vista/7 DVD and hopefully, you will be left with your Windows Vista/7 bootloader.
Line 72: Line 71:
= How to restore the Windows Bootloader using an Ubuntu CD = = How to partially fix the Windows bootloader using an Ubuntu CD =
Line 74: Line 73:
 The methods described above for restoring the Windows bootloader using a Windows installation or repair disc are the preferred ones. However, there are occasions where a user does not have access to such discs, for instance where they have only the OEM manufacturer's restore set of discs which rarely if ever include the Windows recovery console. In such cases it is possible to install code to the mbr from the Ubuntu live session, which is functionally the same as the Windows bootloader. Two methods are described: the first where you are able to connect to the internet from the live session and the second as an alternative or where internet connectivity is not possible. <<BR>>  ''' Note:''' these methods will work on Legacy firmwares (not UEFI), if Windows boot files are not broken, and if the boot sector of the Windows boot partition is healthy. In other cases, you will need a Windows installation or repair disc as described above.
Line 76: Line 75:
 For both methods, boot from the live CD (or live USB) of any recent version of Ubuntu and choose “Try Ubuntu” to get to the live desktop. Before running the command to install the bootloader, it is a good idea to check that the partition from which Windows boots is still set as active. This will usually be so, but in some unusual cases the boot flag may have been unset. You need to know which partition Windows boots from. For XP and Vista, this is normally the main C: partition. Windows 7 usually (but not always) has a separate boot partition of 100-200 MB in size with the partition label “SYSTEM”. There are also more exotic configurations where two versions of Windows have been installed to the same hard drive, or where the main Windows partition is a logical one. In these cases there will be a single primary partition with the Windows boot files which needs to be marked as active, and you will need to identify which this is. Once you have done so, open Gparted and see if “boot” is listed under the flags column for that partition. If not, highlight the partition and go to Partition menu → Manage Flags, tick the tick-box for “boot” and then close that window and close Gparted. <<BR>> <<BR>> == Via the Boot-Repair graphical tool ==
Line 78: Line 77:
 Both methods assume that the boot drive is designated /dev/sda in Ubuntu. This is almost always so, but with some unusual BIOS configurations where there is more than one hard drive, the boot drive may be other than /dev/sda. In such cases you will need to adjust the command appropriately. Run [[Boot-Repair]] from a liveCD, click "Advanced options", tick "Restore MBR", click "Apply".

{{http://pix.toile-libre.org/upload/original/1353333605.png}}

This will automatically restore a generic syslinux MBR, and set the boot flag on the Windows boot partition. This will also tell you if the Windows bootsector needs repair (see [[https://help.ubuntu.com/community/BootSectorFix|this tutorial]]).

== Via command lines ==

1. Boot from the live CD (or live USB) of any recent version of Ubuntu and choose “Try Ubuntu” to get to the live desktop

2. Check that the partition from which Windows boots has the 'boot' flag. For XP and Vista, this is normally the main C: partition. Windows 7 usually (but not always) has a separate boot partition of 100-200 MB in size with the partition label “SYSTEM”. There are also more exotic configurations where two versions of Windows have been installed to the same hard drive, or where the main Windows partition is a logical one. In these cases there will be a single primary partition with the Windows boot files which needs to be marked as active, and you will need to identify which this is. Once you have done so, open Gparted and see if “boot” is listed under the flags column for that partition. If not, highlight the partition and go to Partition menu → Manage Flags, tick the tick-box for “boot” and then close that window and close Gparted. <<BR>> <<BR>>

3. Both methods below assume that the boot drive is designated /dev/sda in Ubuntu. This is almost always so, but with some unusual BIOS configurations where there is more than one hard drive, the boot drive may be other than /dev/sda. In such cases you will need to adjust the command appropriately.
Line 81: Line 92:
'''Method 1 – Internet Connectivity available'''

Open a terminal and run these commands:
'''If internet connectivity available''', open a terminal and run these commands:
Line 93: Line 102:
 Now reboot, remove the Ubuntu CD and you should reboot straight into Windows.
Line 95: Line 103:

'''Method 2 – No
Internet Connection'''

 R
ecent versions of Ubuntu include the file /usr/lib/syslinux/mbr.bin which is 440 bytes in length and simply needs to be written to the beginning of the mbr with this terminal command. WARNING! Be very careful with this command and check for typos before running it.
'''If no Internet connection''': recent versions of Ubuntu include the file /usr/lib/syslinux/mbr.bin which is 440 bytes in length and simply needs to be written to the beginning of the mbr with this terminal command. WARNING! Be very careful with this command and check for typos before running it.
Line 104: Line 109:
 Now reboot, remove the Ubuntu CD and you should reboot straight into Windows.<<BR>>

 ''' Note:''' both these methods will work if the boot sector of the Windows boot partition is healthy. If it is not, you will need a Microsoft installation or repair disc in order to run fixboot or bootrec.exe /fixboot as described above.
4. Now reboot, remove the Ubuntu CD and you should reboot straight into Windows.<<BR>>

Discussion of this wiki can be found here

  • This wiki is for Windows dual booters who reinstall an operating system only to find that it has taken away access to their other operating system.

    Whether you want to restore the XP, Vista, 7 or Ubuntu (Grub) bootloader, this guide will walk you through it.

    All four parts of this tutorial require that you boot from a CD or DVD. If you don't know how to do this, check here.

    If you have made a mistake and want to revert the changes, simply follow the instructions for reinstalling the previous bootloader. For example, if you have installed vista over ubuntu, try to get the ubuntu bootloader back, but want to get the vista bootloader back, simply follow the instructions for installing the vista bootloader.

How to fix the Ubuntu GRUB bootloader

How to fully fix the Windows bootloader using a Windows disk

XP

  • Boot on your Windows XP installation CD or XP Recovery console. You will get to a part where it asks if you want to repair or recover. To do so, press "r". If prompted, enter your Windows XP administrator password. This will leave you at at a command line, so type in the following two commands:

fixboot

fixmbr
  • Then type

exit
  • Then remove your XP cd. If everything has gone well, you should come to your XP bootloader.

Windows Vista or 7

  • First boot on your Windows Vista/7 installation DVD.

    If you have one of the many OEM computers that didn't come with a Vista/7 installation disk, you can get the same effect with a Vista/7 repair disk, which you can download (eg Win7-32bit, Win7 64bit) or create from another Vista/7 computer (see this page and this tutorial). When you get to the Regional settings, select your Location/Keyboard setting then click next. On the next page, click on "Repair your computer." On the next page, if it finds your Windows Vista/7 installation, make sure it is UNSELECTED before clicking next. Then click on "Command prompt". From there, type in the following 2 commands:

bootrec.exe /fixboot

bootrec.exe /fixmbr
  • Now close the two windows and click "Restart." Take out your Vista/7 DVD and hopefully, you will be left with your Windows Vista/7 bootloader.

How to partially fix the Windows bootloader using an Ubuntu CD

  • Note: these methods will work on Legacy firmwares (not UEFI), if Windows boot files are not broken, and if the boot sector of the Windows boot partition is healthy. In other cases, you will need a Windows installation or repair disc as described above.

Via the Boot-Repair graphical tool

Run Boot-Repair from a liveCD, click "Advanced options", tick "Restore MBR", click "Apply".

http://pix.toile-libre.org/upload/original/1353333605.png

This will automatically restore a generic syslinux MBR, and set the boot flag on the Windows boot partition. This will also tell you if the Windows bootsector needs repair (see this tutorial).

Via command lines

1. Boot from the live CD (or live USB) of any recent version of Ubuntu and choose “Try Ubuntu” to get to the live desktop

2. Check that the partition from which Windows boots has the 'boot' flag. For XP and Vista, this is normally the main C: partition. Windows 7 usually (but not always) has a separate boot partition of 100-200 MB in size with the partition label “SYSTEM”. There are also more exotic configurations where two versions of Windows have been installed to the same hard drive, or where the main Windows partition is a logical one. In these cases there will be a single primary partition with the Windows boot files which needs to be marked as active, and you will need to identify which this is. Once you have done so, open Gparted and see if “boot” is listed under the flags column for that partition. If not, highlight the partition and go to Partition menu → Manage Flags, tick the tick-box for “boot” and then close that window and close Gparted.

3. Both methods below assume that the boot drive is designated /dev/sda in Ubuntu. This is almost always so, but with some unusual BIOS configurations where there is more than one hard drive, the boot drive may be other than /dev/sda. In such cases you will need to adjust the command appropriately.

If internet connectivity available, open a terminal and run these commands:

sudo apt-get install lilo

sudo lilo -M /dev/sda mbr

If no Internet connection: recent versions of Ubuntu include the file /usr/lib/syslinux/mbr.bin which is 440 bytes in length and simply needs to be written to the beginning of the mbr with this terminal command. WARNING! Be very careful with this command and check for typos before running it.

sudo dd if=/usr/lib/syslinux/mbr.bin of=/dev/sda

4. Now reboot, remove the Ubuntu CD and you should reboot straight into Windows.

See also

Thread for discussion about this wiki page

RestoreUbuntu/XP/Vista/7Bootloader (last edited 2013-07-31 19:14:01 by yannubuntu)