LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   I ruined my Window's MBR by trying to install Ubuntu on a USB stick (http://www.linuxquestions.org/questions/linux-general-1/i-ruined-my-windows-mbr-by-trying-to-install-ubuntu-on-a-usb-stick-736732/)

baldurpet 06-30-2009 01:16 PM

I ruined my Window's MBR by trying to install Ubuntu on a USB stick
 
I wanted to install Ubuntu on a USB stick, and apparently something went wrong with the mbr.

I was using a Windows machine at the time, inserted the Ubuntu live CD into the computer, installed Ubuntu on the USB stick but now the machine won't start unless the memory stick is connected to the computer! (I get a GRUB error, I can't remember the number of the error atm)

Could anyone please help me? I know this is really a Windows problem but any help would be really appreciated.

GrapefruiTgirl 06-30-2009 01:18 PM

I believe if you boot Windows from the installation CD but choose "Recovery Console" instead of "Install" you can then use the 'fixmbr' command to fix the Windows boot sector.

NOTE: I haven't done this in years, but the procedure here is correct; it's just that the 'fixmbr' command might have a slightly different name.

Cheers,
Sasha

johnsfine 06-30-2009 01:25 PM

If you have a Windows install CD, there is a program on it for repairing the MBR.

What version of Windows is it?

This recent post gives more info if it is Vista.
http://www.linuxquestions.org/questi...21#post3580221

There are solutions even if you don't have a Windows install CD. But most of us here don't remember enough details to talk you through that. The Microsoft documented solutions generally assume you have the install CD.

yancek 06-30-2009 04:07 PM

I expect you accepted the default bootloader installation which is putting Grub stage1 file in the mbr of the disk listed first in boot priority in BIOS. During your installation of the bootloader with Ubuntu, you have an advanced tab you can click to get other options than the mbr. You should select root partition of the USB drive. When you want to boot Ubuntu, you will have to make the selection of the USB disk in the BIOS.

The suggestions above for fixing windows mbr should work for xp, w2k. vista uses a different bootloader and you can download EasyBCD to use to edit its bootloader.

baldurpet 07-01-2009 02:12 AM

Quote:

Originally Posted by johnsfine (Post 3591825)
If you have a Windows install CD, there is a program on it for repairing the MBR.

What version of Windows is it?

I unfortunately don't have the Windows CD, but it's Windows XP.

I didn't really understand yancek's response- is it possible to fix the Windows bootloader from the Window's operating system or do I have to result to the Linux command line?

(this is a pretty important problem so I want to get it right)

ronlau9 07-01-2009 02:31 AM

Quote:

Originally Posted by baldurpet (Post 3592584)
I unfortunately don't have the Windows CD, but it's Windows XP.

I didn't really understand yancek's response- is it possible to fix the Windows bootloader from the Window's operating system or do I have to result to the Linux command line?

(this is a pretty important problem so I want to get it right)

If you like to restore the MBR for windows you need a Windows XP CD
And use the rescue mode in the WINDOWS XP CD
If you googled for it you will find a detailed information how to do it

mitchell7man 07-01-2009 02:45 AM

Quote:

GrapefruiTgirl
Always has great answers, I messed up my MBR like 2 years ago, did what she recommended, and it worked great.

johnsfine 07-01-2009 08:41 AM

If I understand correctly:

The OP does not have a Windows CD.

The OP can currently boot Windows or Linux through grub when the USB device is present (but can't boot without the USB).

I'm sure there is some downloadable program that can be downloaded and run in Windows that will fix the MBR for Windows XP. But I don't know what it is nor where to download it from.

Fixing the Windows XP with command line tools you could download and run in Linux is also possible, but those are probably even harder to find.

There may be a Windows recovery partition on the hard drive that would be an easier method to fix the MBR. In the Windows partitioning tools, the recover partition may be hidden of disguised. To find out if it is there (and to set up to use it) you should boot into Linux. First use gparted to examine the hard drive partition table. If you find the recovery partition, it should be easy to edit the /boot/grub/menu.lst file on the USB so that on the next reboot it gives you the option to boot from the recovery partition.

If you have and boot from a recovery partition, that should act just like the install CD that you would have used if you had one.

GrapefruiTgirl 07-01-2009 08:48 AM

Ideas....
 
Thanks Mitchell7man :)

Unfortunately, in this case which now does not have the original XP CD, I am at a loss. I'm quite sure there's likely a way to repair the Windows bootloader without the CD, but unless someone can provide some info on how to do it (from their own experience would be good) then the OP might be at the mercy of whatever tool he/she can download from who-knows-where.

What I am wondering though, is this:

The machine will boot (Windows boots too I presume) when the USB drive is connected. Therefore, the Windows bootloader IS still intact *somewhere*, ie maybe it is on the USB drive's MBR? So, I wonder if reinstalling GRUB to the correct MBR (on the HDD) would allow the machine to boot without the USB stick. NOTE: This might cause a boot menu to appear from GRUB, however at least Windows ought to be bootable from the menu too. It would bridge the gap until you could maybe *find* your XP CD and repair the MBR the right way.

NOTE: I don't know if this will work!!! It's just a theory. Don't try this until someone else with a more solid background with GRUB can provide some more help.


Sasha

GrapefruiTgirl 07-01-2009 08:53 AM

http://www.linuxquestions.org/questi...10#post2299410

NOTE: The post I linked to here also claims that along with 'fixmbr' you will need to run the 'fixboot' command. I can't recall doing this when I borked Windows years ago, but it sounds logical.

S

nowonmai 07-01-2009 08:59 AM

You can download a program which will build the Windows Recovery Console on a bootable CD, which you can then boot and run fixmbr.

CAVEAT: I haven't tried this, or even d/l'd the file to validate it, but the site is reputable.

Wim Sturkenboom 07-01-2009 01:04 PM

Quote:

Originally Posted by GrapefruiTgirl (Post 3592953)
What I am wondering though, is this:

The machine will boot (Windows boots too I presume) when the USB drive is connected. Therefore, the Windows bootloader IS still intact *somewhere*, ie maybe it is on the USB drive's MBR?

I think you're mistaken here. The bootloader is the bootloader. Windows places it in the MBR. Under Linux you can define where you want it, but in this case it also went into the MBR. So the Windows bootloader is gone. Grub has taken over this function in this case.

The bootloader will load the operation system (in layman's terms).

The problem here is Grub (this would not have happened with Lilo). Grub only fits partially in the MBR and therefore is also partially somewhere else on the HD (in /boot). Wiping the partition or removing the USB stick makes that Grub can not continue after a certain point.

Lilo fits fully in the MBR and therefore does not suffer from this problem.

Some links if you're interested in further reading:
google linux boot process explained
http://itreviews.blogspot.com/2006/0...explained.html
http://www.debianadmin.com/the-lniux...explained.html

Wim Sturkenboom 07-01-2009 01:11 PM

You can (try to) fix the MBR from within Windows. See http://schivmeister.wordpress.com/20...in-windows-xp/

nowonmai 07-02-2009 04:53 AM

Quote:

Originally Posted by Wim Sturkenboom (Post 3593255)
I think you're mistaken here. The bootloader is the bootloader. Windows places it in the MBR. Under Linux you can define where you want it, but in this case it also went into the MBR. So the Windows bootloader is gone. Grub has taken over this function in this case.

Correct. And GRUB knows enough about windows to chain-load NTLDR when it is selected as an option in the boot menu.


All times are GMT -5. The time now is 02:10 AM.