Sunday, June 1, 2008

Installing Bootloader How-to

I've noticed a lot of people asking about restoring Vista/XP bootloaders, and so I decided to write a how-to for this. Also, I will include a quick how-to on restoring GRUB as well.

For Vista:
Boot to your recovery cd/partition (if you don't have one, or lost yours, you can get a recovery CD from here note: the CD is ONLY recovery options, so no cheap way of getting Vista "This download is available to customers running genuine Microsoft Windows. Please click the Continue button to begin Windows validation. As described in our privacy statement, Microsoft will not use the information collected during validation to identify or contact you." part of the disclaimer for the multi-gigabyte download for the actual program used to create that disk. If you don't agree with it or don't have a genuine windows system, do not use this download.)
After booting to the CD, get to the Recovery Console (it differs for each recovery program, but generally is easily enough found). Once there type
bootrec /fixmbr
bootrec /fixboot
which will restore the Vista bootloader.

For XP:
boot to an XP CD (sorry, no links available :P) and, once the menu loads, hit "R" to enter a command prompt. Once there, choose which partition you want, and enter an admin password (if you have one set).
then type
fixmbr
fixboot
and the XP bootloader should be restored.

For GRUB restore to MBR:
boot to the LiveCD (this is the easiest way IMHO) and then start a terminal (applications-->accessories-->terminal)and type:
sudo grub
find /boot/grub/stage1
root (hd?,?)
setup (hd?)
quit

where the (hd?,?) and (hd?) corresponds to the output of find /boot/grub/stage1 (first time round the (hd?,?) stands for the drive (hd?) and the partition (,?) at which Ubuntu (or any Linux) is located, and then the second time round (hd?) just stands for the drive, for the MBR).
If you would like a more detailed explanation catlett did a good job with his how-to here and also offers troubleshooting ideas.

How to restore GRUB to a partition:
**DISCLAIMER** This is untested, as I haven't had time to do so yet, but it should work. Any feedback would be great, either by PM on UF or to have a reply posted here.
sudo grub
find /boot/grub/stage1
root (hd?,?)

setup (hd?,?)
quit
(for an explanation of the above code, see the info on restoring GRUB to the MBR, apart from the code marked in bold).
There is only one small variation for this (marked in bold) but it's a significant one. That "?" marked in red should be the same one you used for your "root" command in the line above. It will then install GRUB to that partition.

Now, you may ask, why is this on a Linux blog? Well this is for those people who either decide Ubuntu (or Linux in general) isn't for them, and wish to get back to Vista or XP, or else for those people (like me) who have set up a triple boot system. To set up a triple boot, I found, it works best if you install the XP bootloader (for XP), then the Vista Bootloader (on top) and then lastly, the GRUB which then allows the booting of all 3 systems. The problem I ran into was that i had Vista and Ubuntu installed, so I installed XP, then GRUB, and realized XP bootloader files (which are in the Partition and called the ntldr files) could not boot Vista. I ended up removing Vista then, but that's another story.

No comments: