LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-30-2009, 01:16 PM   #1
baldurpet
Member
 
Registered: Dec 2008
Location: Iceland
Distribution: Ubuntu, freeBSD
Posts: 110

Rep: Reputation: 15
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.
 
Old 06-30-2009, 01:18 PM   #2
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
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
 
Old 06-30-2009, 01:25 PM   #3
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
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.
 
Old 06-30-2009, 04:07 PM   #4
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,492

Rep: Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488Reputation: 2488
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.
 
Old 07-01-2009, 02:12 AM   #5
baldurpet
Member
 
Registered: Dec 2008
Location: Iceland
Distribution: Ubuntu, freeBSD
Posts: 110

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by johnsfine View Post
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)

Last edited by baldurpet; 07-01-2009 at 02:15 AM.
 
Old 07-01-2009, 02:31 AM   #6
ronlau9
Senior Member
 
Registered: Dec 2007
Location: In front of my LINUX OR MAC BOX
Distribution: Mandriva 2009 X86_64 suse 11.3 X86_64 Centos X86_64 Debian X86_64 Linux MInt 86_64 OS X
Posts: 2,369

Rep: Reputation: Disabled
Quote:
Originally Posted by baldurpet View Post
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

Last edited by ronlau9; 07-01-2009 at 02:32 AM.
 
Old 07-01-2009, 02:45 AM   #7
mitchell7man
Member
 
Registered: Jan 2007
Location: Draper, UT
Distribution: Ubuntu, Windows 10, OSX
Posts: 461

Rep: Reputation: 31
Quote:
GrapefruiTgirl
Always has great answers, I messed up my MBR like 2 years ago, did what she recommended, and it worked great.
 
Old 07-01-2009, 08:41 AM   #8
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
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.
 
Old 07-01-2009, 08:48 AM   #9
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Exclamation 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
 
Old 07-01-2009, 08:53 AM   #10
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
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
 
Old 07-01-2009, 08:59 AM   #11
nowonmai
Member
 
Registered: Jun 2003
Posts: 481

Rep: Reputation: 48
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.

Last edited by XavierP; 07-02-2009 at 03:27 PM. Reason: removed URL as the legality of the download is in question
 
Old 07-01-2009, 01:04 PM   #12
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally Posted by GrapefruiTgirl View Post
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
 
Old 07-01-2009, 01:11 PM   #13
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
You can (try to) fix the MBR from within Windows. See http://schivmeister.wordpress.com/20...in-windows-xp/
 
Old 07-02-2009, 04:53 AM   #14
nowonmai
Member
 
Registered: Jun 2003
Posts: 481

Rep: Reputation: 48
Quote:
Originally Posted by Wim Sturkenboom View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
may install from cdrom to USB FLASH DRIVE(to get it a USB stick bootable) the ubuntu lse123 Linux - Newbie 5 01-02-2009 04:56 PM
LXer: A much easier way to install Ubuntu on a USB device (Stick or Hard Disk)! LXer Syndicated Linux News 0 06-01-2008 11:20 PM
Erasing MBR from USB stick spiffytech Linux - Software 9 01-10-2006 05:38 PM
Need help please Firestarter might have ruined my mbr 1702fp Linux - Security 7 09-13-2005 07:07 PM
MBR with WinXP and Linux Dual Boot Ruined...! truhuska Linux - Newbie 7 04-29-2004 11:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration