-1 Linux user
Posted by: bigbolshevik in Open-source application software, Other computers/OS'es, Repositories, UbuntuRestore Windows MBR in Ubuntu Linux
I had installed Xubuntu on a friend’s laptop, at her request. Then she got a job using MYOB… and I had to put Windows back on.
So I did that, and got paid for it. It’s sad that there’s one less Linux user, but then I think she didn’t quite understand what she was getting into originally, and her reason for going Windows again was a legitimate one.
I backed up her Linux data and then booted up her recovery discs. At the end of the recovery session though, the machine rebooted… back into a GRUB Error 17!
Usually, you just get your Windows CD out, run a recovery console and type “fixmbr”. But in this case I only had recovery discs made by Symantec Ghost, not an actual Windows install CD. I needed a way to restore the Windows master boot record from within Linux, and I found the answer after about an hour.
sudo apt-get install ms-sys
NOTE: This package is not included in Hardy! You must apt-get it and install it within a Gutsy live CD, or an earlier Ubuntu, or a different live CD. Or you could install from source (http://sourceforge.net/projects/ms-sys) if desperate.
The man page tells you how to use it, because you need to use a different option depending on which version of Windows you will be using.
Now, find out the device file of the hard disk by typing
sudo fdisk -l
Put it into the ms-sys command like so (the following command is ONLY for restoring the MBR on an XP system, not for any other Windows versions!):
sudo ms-sys –mbr /dev/sda
Note that I’m using the device file of the hard disk, not of any partitions on it. Ms-sys will not write the MBR to a partition unless you use the force option, because this destroys the partition table.
Important warnings:
READ THE MAN PAGE FIRST. (man ms-sys)
The –mbr option is ONLY for when you are installing or have installed Windows XP, NOT for 98 or 2000 or any other versions except where stated in the man page.
Make sure you use the correct device file! Turn off or remove all external devices except your live CD and the target hard disk, to avoid installing the MBR onto the wrong device.
Specify a hard disk, not a partition. If your device file name has a number at the end of it, then it is WRONG. Get rid of the number, and then it will be right.
For god’s sake, if ms-sys gives you an error message, DO NOT use the force option. Forcing the program to write an MBR to the wrong place will destroy your data.
UPDATE: I filed a bug report regarding the missing ms-sys in Hardy, and got a quick response. Apparantly it was removed from Debian because it contains what may or may not be Microsoft code. Now that I know why, I understand and don’t blame Debian or Ubuntu for removing the package.
The author of the software claims that his program contains part of the output of a Microsoft program (fixmbr). I have not studied the source code, but if this is true, there would probably be no problems involved in its redistribution. Microsoft cannot copyright the output of a program. However, Debian claims that it is actual Microsoft code.
Legally dubious, but highly useful, maybe ms-sys should be in Medibuntu.
Entries (RSS)