LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 09-06-2007, 01:02 AM   #1
mamtasahai1
Member
 
Registered: Jan 2007
Location: India
Distribution: RHEL 5, Fedora 9, Solaris, FreeBSD
Posts: 52

Rep: Reputation: 15
How to recover mbr


Hi All,
I m using RHEL 5. I want to know that how to recover MBR.
System is giving error message "OS loading Error"
 
Old 09-06-2007, 01:29 AM   #2
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
The easiest way is to boot the machine to a DOS floppy and run "fdisk /mbr".

If that isn't an option (no floppy drive, SATA drives, etc) then you can do it from the XP install CD's Recovery Console.

If you want do go the all-Linux route, then this page will get you sorted out.
 
Old 09-06-2007, 01:47 AM   #3
FragInHell
Member
 
Registered: Sep 2003
Location: Sydney Australia
Distribution: Redhat, Centos, Solaris, Ubuntu, SUSE
Posts: 282

Rep: Reputation: 45
use rescue disk and the re-install grub.
 
Old 09-06-2007, 03:09 AM   #4
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Quote:
The easiest way is to boot the machine to a DOS floppy and run "fdisk /mbr".
Not necessarily going to work for all newer Windows installs (XP).

Basically, unless you took a backup of your MBR before doing something to it, you can't "recover" it except for overwriting. So decide which bootloader you want to install there (Windows', GRUB, LILO, some 3rd-party bootloader, ...?), then install and configure it to be able to boot your operating systems (one or more).

Windows bootloader can be tricky sometimes, especially that of XPs. I know machines where 'fixboot' and 'fixmbr' don't do anything but trash the already-wrecked MBR (or a working Linux bootloader from it), so they're useless - basically copying an image of a working MBR (512 bytes, if with partition table, or perhaps without the partition table) might work, but I've seen and heard more failed attempts there than successful ones, so I don't recommend it.

If you are going to have a Linux on the disk, I suggest installing GRUB. It's easy to install, configre and especially maintain/update in case of changes to the boot configurations (compared to LILO which needs to be re-copied to MBR each time altered) and can easily be made boot non-Linux operating systems (like LILO also). If you're going to only use Windows or some other non-Linux system, your best choice is to take the original setup disk of that operating system, boot from it and hope that there is a restore/fix utility for reinstalling it's bootloader. XP's disc has that "Recovery Console" which is sometimes installed on harddisk too, but like I said, it's not always working.
 
Old 09-06-2007, 09:25 AM   #5
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
Quote:
Not necessarily going to work for all newer Windows installs (XP).
NTLDR is not saved in the MBR itself, the MBR simply contains a command to load and launch NTLDR from the disk. So you can write a MBR for a XP system through DOS, since the functionality has not changed since NTLDR was introduced. I have personally done this dozens of times without incident.

This won't work on Vista however, because Vista uses an entirely different bootloader than previous Windows versions.
 
Old 09-07-2007, 06:22 AM   #6
masterclassic
Member
 
Registered: Jun 2007
Distribution: Knoppix, antiX
Posts: 252

Rep: Reputation: 73
I think it would be better to know more about partitions and O.S. Is it a problem in the MBR or in a partition boot sector?
 
Old 09-08-2007, 12:00 PM   #7
mamtasahai1
Member
 
Registered: Jan 2007
Location: India
Distribution: RHEL 5, Fedora 9, Solaris, FreeBSD
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by MS3FGX View Post
NTLDR is not saved in the MBR itself, the MBR simply contains a command to load and launch NTLDR from the disk. So you can write a MBR for a XP system through DOS, since the functionality has not changed since NTLDR was introduced. I have personally done this dozens of times without incident.

This won't work on Vista however, because Vista uses an entirely different bootloader than previous Windows versions.
Sir, Please tell me how can i change MBR.
 
Old 09-08-2007, 12:10 PM   #8
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
Yes you can change the MBR.

Last link of my signature has the commands for restoring MBR for Windows, Vista, Lilo and Grub.

You can only restore a MBR if there is an operating system that has been arranged to go into the MBR. Grub is the standard boot loader used by EHEL. Therefore Fraginhell has already given you the correct answer. I describe it as Task B6.

Last edited by saikee; 09-08-2007 at 12:11 PM.
 
Old 03-29-2008, 10:35 AM   #9
gymnart
Member
 
Registered: Oct 2005
Distribution: SUSE 11.4
Posts: 331

Rep: Reputation: 30
mbr woes on a laptop

How would you get around the problem of the console requiring an administrator password and the password is not accepted?

And:
For some reason, the laptop cannot read from the usb floppy drive even though "legacy" was enabled from the bios and the boot order was changed to boot from the floppy.

This is for my son-in-law's computer. He wanted to have a dual boot with Kubuntu on it and most of the apps worked but when he went to boot into the Windows partition, it could not boot at all. So panic set in and in effort to give Window's control of the mbr back, he deleted the Linux partition and tried the recovery disk. Then he ran into the problem that I described above. I feel so bad about this.

Quote:
The easiest way is to boot the machine to a DOS floppy and run "fdisk /mbr".
Can't do that, the computer can't read it. It gives an I/O error message even though the floppy disk is fine and can be read from another computer.


Quote:
If that isn't an option (no floppy drive, SATA drives, etc) then you can do it from the XP install CD's Recovery Console.
Can't do that either. When we try it, the computer demands a password just to get to the recovery console and it is not accepting it.

Last edited by gymnart; 03-31-2008 at 08:46 AM. Reason: more info
 
Old 03-31-2008, 10:25 AM   #10
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
Well the first thing to check is that you are using the correct password. You need to use the local administrator password that you specified when you installed Windows, not the Windows login password (though of course, they could be the same password). If you don't recall setting one or this is a OEM install, then it is probably just blank (from personal experience I would say 80% of Windows machines have blank local Admin passwords).

If that still isn't working, you might try booting to ntpasswd to change the Administrator password, and then retry the Recovery Console.

Alternately you could use the Ultimate Boot CD which includes tools to work with the MBR, in addition to being able to boot an image of the MS-DOS boot floppy from your CD-ROM (though you have to provide the image for licensing reasons).

If all else fails, you can just copy off his important data with a live CD and reinstall Windows/Linux however you like, this time having a bit of hindsight to guide you.
 
Old 03-31-2008, 11:19 AM   #11
gymnart
Member
 
Registered: Oct 2005
Distribution: SUSE 11.4
Posts: 331

Rep: Reputation: 30
MS3FGX, how would you copy his important data with a live CD? Do you mean a live Linux CD with this procedure?:

Open a terminal
sudo grub (then I should get a prompt with grub> )

grub> rootnoverify (hd0,0)
grub> chainloader +1
grub> boot

The way my son-in-law had his Windows set up, there was a hidden administrator account that has to be in SafeMode in order to change the password (or to get rid of it). I hope that when we can get it booted that we would be able to get into that SafeMode and get rid of that password so that if this were to happen again, then we would be able to use the recovery console if necessary!
 
Old 04-02-2008, 11:37 AM   #12
gymnart
Member
 
Registered: Oct 2005
Distribution: SUSE 11.4
Posts: 331

Rep: Reputation: 30
Progress so far:
MS3FGX that password blanking tool worked and we tried the fixmbr command in the recovery console BUT now when we try to boot into Windows, we get an "Operating System not found" error message.

When my son-in-law did a dir command in the dos window, all his files and Windows itself was still there. He is now trying the fix boot commands on the Windows installation disk.

Edit (from son-in-law):
I've blanked all user's passwords and got in recovery console. Used fixboot and fixmbr. I checked the MSKB and found that maybe I need to tell Windows what my active partition is (since kubunto changed it and therefore after finding out Windows wouldn't boot, I deleted the partition ^.^; ) but what it says here in Method 3... using diskpart to set active partition where my Windows directory is. One problem: the commands the KB states aren't the same as what I have; I can just add/delete partitions, both via command-line and GUI.

Last edited by gymnart; 04-02-2008 at 12:19 PM. Reason: Son-in-law edited
 
Old 04-02-2008, 12:12 PM   #13
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
It sounds like the Windows partition is not where the bootloader expects it. Is it on the first partition of the primary drive, or somewhere else?

You might also need to repair/replace the actual bootloader as well. You have run "fixmbr" from the Recovery Console to fix the MBR, if you go back into the Recovery Console and run "fixboot" this should place a new bootloader binary into your recently restored MBR.

You might also want to check around with the "bootcfg" program in the Recovery Console. This is used to read and edit Boot.ini, the file that tells which OS's the bootloader is aware of. Try a command like "bootcfg /scan" and verify that it lists your Windows installation (and only that).
 
Old 04-02-2008, 12:30 PM   #14
gymnart
Member
 
Registered: Oct 2005
Distribution: SUSE 11.4
Posts: 331

Rep: Reputation: 30
Via son-in-law:

I've did fixmbr first, then fixboot (it gave me a message stating: "fixboot cannot find the system drive", so I tried "fixboot c:"). Finally bootcfg /scan and it gave me 1 Windows installation...

Anything else?
 
Old 04-03-2008, 12:52 PM   #15
gymnart
Member
 
Registered: Oct 2005
Distribution: SUSE 11.4
Posts: 331

Rep: Reputation: 30
Robert decided to go totally Linux and installed Sabayon Linux which was able to use his sound chip and had no problem with his graphics card. It even had "Beryl" and that was a definite "selling point" for him. He loved that eye candy! (there is a demo of it on youtube, http://www.youtube.com/watch?v=xC5uEe5OzNQ It's got cool music in the video. I like it.)

Anyway,

The cracking program that you recommended, "Windows NT Passsword & Registry Editor" worked, we were able to use that to Blank the problematic password. Then we were able to get into the recovery console. After trying in vain to get Windows to boot, we put in the KUbuntu live CD and poked around with it and Robert found out how to mount his Windows partition to Linux and it worked, he was able to read the Window's files. (This he did when I was out at a meeting last night -- I'm so proud of him for figuring out how to find and use the mount command. ). So, when I got home, I got out his DVD's and told him to open up K3B and he just dragged and dropped what he wanted to back up onto the DVD and it worked.

Then, he found "Parted" (on the KUbuntu live CD) and noticed that the Windows partition was listed but it said that it was not the "Active Partition" and there was a tool to make it active. He chose that and it worked! Windows booted! However -- the stuff we had done that first night when we chose the option to "repair windows" well, the problem was that Robert had Service Pack 2 and the CD we were using for repair was Windows XP but with Service Pack 1 so the SP2 system files were overwritten with SP1 stuff so the installation had been corrupted.

Well, that's when Robert decided to go all Linux and after playing around with the Sabayon Live DVD that my friend gave me, he loved what he saw. He had it format the harddrive and installed it - no partition. Now he is learning how to install apps from source. So far, he has installed Extreme Tux Racer and Wine.

Anyway, Robert went with KDE for his default desktop environment. I guess he prefers that because that is what I use.

*What kind of packages does Sabayon use? Is it .deb? or does it use .rpm?*

In Gnome, what is the keyboard shortcut to get to the T.O.P.? In KDE I know it's CTRL + ESC.

OK, now for his future plans:
He wants to get a much larger Harddrive and install Windows XP on it and then when he wants to switch between the two OS's, he plans to open up his lap top and take the one HD out and put the other one in. *Would that work?*
 
  


Reply



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
Do I need to recover MBR when reinstalling Edubunutu? zoffmann Ubuntu 4 11-19-2006 02:37 AM
how Recover my Hard disk Mbr & partion viji2ks Linux - Hardware 1 09-01-2006 08:25 AM
Restoring MBR :partitions are detected only after the reboot after MBR restoration? sharathksin Linux - Newbie 2 04-14-2006 07:48 AM
GRUB MBR overwritten by WIN98 MBR TOuseef Linux - General 7 11-14-2004 04:25 PM
how do i recover my Hard Disk and MBR? Pisces107 Linux - General 5 12-25-2003 11:12 PM

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

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

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