How to Fix a FUBAR'd MBR w/out Formatting


Recommended Posts

Fixing the Master Boot Record without Formatting

This is the ONLY guide on the web to fixing a FUBAR'd MBR without formatting or deleting your partitions.

A FUBAR'd MBR is one that cannot be repaired by using fixmbr or fdisk/mbr.

A warning: all the steps are laid out very clearly, but it takes absouloutely forever to carry out. Its a long and harsh road, but the path is clearly marked, there are no dead ends, and all the pot-holes are filled.

For n00bs and advanced alike, this works, and it works well. It will test your patience and your resolve, but ITS WORTH IT.

YOU WILL NOT LOSE A SINGLE BYTE OF DATA!

This is the ONLY way. I searched the entire web for a safe and secure way of pulling it off, and THERE WAS NONE.

There are some steps that can and are in the process of being shortened.

You are required to install Linux, but we will not even step foot in it. Do not be afraid :)

Please post feedback on the blog, its where people from all over the web will be reading the guide in the end.

EDIT

Forgot to post a link :pinch:

Left a moment there - not sure if all that was actually necessary at this point in time....

But at the very least, his steps are detailed *and* explained - so anyone carefully reading the blog and not thinking they know what to do and getting ahead of themselves should have a working MBR in a matter of an hour or less.

Thanks John.

I left a reply to your post there....

Basically I am working on trying to find a copy of a Grub Installer that boots from a floppy or something, without Linux at all. I think that will make it a lot easier, no Linux download, and no Resuce Mode for people who already installed Linux.

Plus, most beginners tremble at the *nix word :)

Hmmm, I wonder if I can assist you in this venture. I don't know if there is a floppy - accessible GRUB, b/c I am not sure that it will fit - but a very tine ISO would work just as well, and not limit you to a 1.44 / 1.76 (in case you use the M$ Extended Floppy format) barrier.

A 3 MB ISO may seem like a waste of a CDR - but if that ISO saves their arse even *one* they'll place it in storage and refer to it every single time.

EDIT: Added the following

Read your replies, and replied again. Thanks again for a well documented and clarified guide. As I said before as long as n00bs / lusers don't get ahead of themselves, they'll be back up and running in under an hour.

Now to find out if there is a GRUB install for use for the fix to avoid having to get a 20-40 MB install CD download (I personally use Gentoo, and the minimal CDs for it at 65 MB, but there *has* to be a way of compressing only the *absolutely* essential files into a minute image.

Edited by johngalt

Kewl. I will keep an eye out for it as well. I *know* there was a distro that was floppy loadable, and thus I may be wrong about GRUB not fitting on a floppy, but I cannot remember for sure.

And no, not referring to QNX - that is a different flavor entirely - and I have used it before when I worked at IBM. This was something more recent that I saw.

If you can install Grub to a floppy, and can locate the grub files on the floppy, I got the entry that will allow you to automatically install it to a HD....

We can edit it so that it can take into account various types of HDs - such as (hd0,0) etc, or to see how it works (if differently) for SATA drives.

try this:

#For installing GRUB into the hard disk
title Install GRUB into the hard disk
root    (hd2,0)
setup   (hd0)

In this example, my 'root' files, IE where the grub.conf is located, is [hd2,0]. By altering that you should be able to install Grub to the HD from a floppy, no?

EDIT: Added the following

In fact, that should work correctly, except that from that point on it would look for the floppy diskette every time it booted, and then the 'optional' steps at the end to remove GRUB would become mandatory to help fix it.

Of course, as you also mentioned in the guide, if the user already has Linux then they can perform this themselves and save a lot of time.

looks like this is shaping up nicely :) Good work John ^*^

Anyway, just a couple of things that I think would need to be looked at first however:

1) If I were to make the Grub floppy image on my computer, then distribute the unpacker that users can run, the entries in Grub will correspond to teh entries on my pc.. i.e. Windows on hd0,0 and linux on hd0,3 and hd1,2

There needs to be a wizard that will correctly identify the existing partitions. especially since the command to boot to windows is drastically different from booting to Linux, and not all of our users will be on one system or the other, ther are some linux-only and windows-only people.

but its a start :) I'm working on it too... just reinstalling FC4 tonight the real way (did the minimal install to get my MBR working he he) then I will see what i can get.

again, thanks a million!

Hmmm.... this is getting tricky - but you could *theoretically* make multiple entries - like this:

#For installing GRUB onto device IDE 0 Disk 0
title Install GRUB into the hard disk
root    (fd0) [color=#FF0000]<--- changed that - that *should* be correct for locating the grub.conf on the floppy[/color]
setup   (hd0)

#For installing GRUB onto device IDE 0 Disk 1
title Install GRUB into the hard disk
root    (fd0) [color=#FF0000]<--- changed that - that *should* be correct for locating the grub.conf on the floppy[/color]
setup   (hd1)

#For installing GRUB onto device IDE 1 Disk 0
title Install GRUB into the hard disk
root    (fd0) [color=#FF0000]<--- changed that - that *should* be correct for locating the grub.conf on the floppy[/color]
setup   (hd2)

#For installing GRUB onto device IDE 1 Disk 1
title Install GRUB into the hard disk
root    (fd0) [color=#FF0000]<--- changed that - that *should* be correct for locating the grub.conf on the floppy[/color]
setup   (hd3)

Of course, then, if SATA drives are represented differently (I don't have access to am cine with SATA enabled, so I cannot say one way or another) then that will need editing as well to add entries for SATA drives.

An easier way might be to make sure there is no timeout setting (either set it extremely high, like 65535, or comment it out completely) so the user is *forced* to make a choice, then give him the commands to do so, with an explanation:

title Please read this carefully.  You have just booted your system
title with a *nix boot loader called GRUB.  In order to facilitate the
title MBR fix process, please select the very last entry in this list
title using the arrow keys and then hit the [E] key to edit the entry.
title Use the arrow keys to select the last line, which should have
title the syntax "setup (hd0)" - replace the 'hd0' part, leaving the
title parentheses, with your Windows system drive number - i.e.
title if the Windows disk is the master drive on the primary IDE
title channel, then use hd0 - if it is the slave drive on the primary
title IDE channel, use hd1.  Master on the 2nd IDE channel = hd2
title and slave on 2nd IDE is hd3.  Please note that IDE nomenclature
title starts at 0, so IDE 0 is the first* IDE channel and IDE 1 is the 2nd.
root (fd0)
setup (hd0)

Not exactly a wizard, but getting there- still not very n00b friendly, I admit, as you have to be savvy enough to know 8where you stuff is installed.

But a wizard on a floppy - umm, well...I don't see it.

Kudzu can probably run off the CD ISO image I mentioned earlier ;-0

well, I *may* have found something easier:

Invoking grub-install

The program grub-install installs GRUB on your drive using the grub shell (see Invoking the grub shell). You must specify the device name on which you want to install GRUB, like this:

    grub-install install_device

   

The device name install_device is an OS device name or a GRUB device name.

grub-install accepts the following options:

--help

Print a summary of the command-line options and exit.

--version

Print the version number of GRUB and exit.

--force-lba

Force GRUB to use LBA mode even for a buggy BIOS. Use this option only if your BIOS doesn't work properly in LBA mode even though it supports LBA mode.

--root-directory=dir

Install GRUB images under the directory dir instead of the root directory. This option is useful when you want to install GRUB into a separate partition or a removable disk. Here is an example in which you have a separate boot partition which is mounted on /boot:

          grub-install --root-directory=/boot hd0

         

--grub-shell=file

Use file as the grub shell. You can append arbitrary options to file after the file name, like this:

          grub-install --grub-shell="grub --read-only" /dev/fd0

         

--recheck

Recheck the device map, even if /boot/grub/device.map already exists. You should use this option whenever you add/remove a disk into/from your computer.

THis is a helper program that comes with the grub package. It can theoretically be invoked to install to the MBR via a script. Now the only problem would be, that a simply MS Boot Disk would not suffice, we woudl have to have a complete linux kernel fit on a floppy! but nesides the kernel there would not be anything, since the only thing we need is the kernel to run the grub-install script.

We could add grub-install as runtime script, it would install and then exit.

However, now seems to be the right time to ask this quesion: Do we *need* a floppy image? In this day and age, most new PCs do not have floppies. Every PC needs a CD-Drive however.... I personally have a floppy cuz many morons from the past still give me files via 3.25, but its disabled from teh BIOS for virus protection and speeded booting

That is the one I was trying to find lol.

I forgot about grub-install script, figures though since I always manually install grub by running grub from the CL....

I also still have a floppy in my system (both of them in fact) and can *easily* test the install scripts as well. The best part? Both machines (P4 2.0 GHz and Celeron 366 laptop) already have GRUB installed to hd0 to begin with, so as long as it is a current version of Grub, it will not affect anything (of course, I will have to manually specify the root folder to avoid losing my current configurations, but that is easy enough).

But, you still are no closer to a wizard / script that *auto* detects the HD and knows where to place it, no?

actually, we are.

Grub-install itself I *believe* does that. its how you get standard grub.conf across all distros.

My FC4 install last night went awry, guess where: Grub! Yep, apparently if you give the ext3 partition a name (Like I did mine: Fedora Core 4), then assign it a label '/' in FC4 setup, grub wont boot it.. you get kernel panic....

Soon as its fixed I'll try to compile a script and get you a copy.

thnks!

I can check now - great little tool called RSFgui - windows executable that allows you to read ReiserFS partitions (which is what I use for Gentoo).

Just as I thought - no grub-install script in /boot/grub.

I will try searching the usually /bin /sbin etc dirs later on. but I haven't gotten X working fully yet so I have no real Internet access. Yet. (and yes, by Internet access I mean the ability to enter forums and read stuff and reply. Not even via elinks / links2.

I went ahead and rated ya a 5 - with the work you're putting in to it it is definitely worth that much - even if it only saves .0001% of all computers out there - all those folks are gonna love you for life.

better than RSFgui, there are programs that can mount reiserfs systems in my computer, from where you can read and write to the NATIVELY!

i am usng ext3 with IFS Drives, (its free), but hope to upgrade to resiserfs soon

thanks for the rate... anyone else :D

best of luck with you net.. Linux needs net very much

Yeah, I said *net8 and meant GUI. I can do things without a GUI, but browsing is still too much of a PITA without a GUI.

When you said tools to mount ReiserFS, were you referring to *windows*? because I have been looking for such a tool and cannot find it.

If you meant in Linux, *that* I can see - building support for it in your kernel helps tremendously.

Cool!

I just formatted my nix :(

I downloaded Gentoo 2005.1 it reached 99% (with GetRight) then all of a sudden it resets to ZERO!

BUT before that I made much progress in Fedora Core with grub-install.

1) Grub2 is not yet included with anything, and hard to install. If we use GRUB2 = much more happy people!

2) grub-install is very picky on where it is installed to, gives much trouble if the first partition is NTFS :(

3) Grub itself comes with a basic bash.... can be used to run Grub-Install from within Grub?!

4) Looking a tad harder, but much clearer.

well, it depends upon which Gentoo 2005.1 you are downloading - and sometimes those managers get FUBAR'd from the several mirrors available - There are so many ways to get Gentoo working that it is impossible for me to know which one you are using.

I *can* say that there is now a Gentoo LiveCD (and a Live DVD as well, ISTR) that allow you to install from a GUI based installer script, but also allow you to simply have a working install environment when installing. The basic problem is that different boot CDs have support for different parameters - for example, if you want to use LVM, then you'll not be able to go through a stage 1 (I think). Other restrictions apply as well.

Regarding grub-install - I had a feeling that this would be the case seeing as it was an install script....

re: Grub itself - that is what the install entry I have in my grub.conf makes use of....

as long as it does not get hazy, you are all good.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • RollerCoaster Tycoon 3 and Voidwrought are free on the Epic Games Store by Pulasthi Ariyasinghe PC gamers can now jump in and grab two more games to keep this week, as the Epic Games Store's ever-present giveaway promotion has just gone through another refresh. Replacing last week's Citizen Sleeper and Robobeat offers, the store has brought in RollerCoaster Tycoon 3 Complete Edition and Voidwrought to keep. From the duo, Roller Coaster Tycoon 3: Complete Edition is an enhanced version of the classic title that was originally released in 2004. It comes with enhancements such as widescreen and 1080p resolution support, as well as increased compatibility with modern PC hardware. It also comes bundled with all the extra content from the Soaked! and Wild! expansion packs. "Control park finances, shops, services and staff to succeed in dozens of scenarios," reads the description. "Become a true tycoon and embark on your promising new career, or create your ideal park without money woes in sandbox mode. Satisfy your guests’ needs and keep your park running smoothly to succeed." If management is not your style, Voidwrought lands as a 2D action-platformer featuring hand-drawn cosmic horrors. The title touts tight platforming and close‑quarters combat, all brought together with a strong emphasis on mobility. "Descend below the star-scorched surface and explore the multidimensional depths below," says the studio Powersnake about the game. "Witness the corrupted revelry of the Court, lose yourself in the icy tunnels of the Old Waters, and discover the grim fate of the Abandoned Expedition." The RollerCoaster Tycoon 3 Complete Edition and Voidwrought giveaways are set to run until June 25 on the Epic Games Store, giving PC gamers seven days to claim the latest offer. Once this closes out, new freebies will take their place on the same day as always. Don't forget that mobile gamers can check out the Epic Game Store's weekly giveaways on Android and iOS to grab a freebie there as well.
    • I have a feeling this memory shortage issues are going to linger 6-8 years so until and unless Chinese memory floods the markets we are doomed
    • If you look at the account logs more than likely it will be showing that the request is coming from Valley Nebraska. we have been seeing thousands of these the last day or so.
    • It's requesting a login code as if I was signing into my account on my Windows machine. 
  • Recent Achievements

    • First Post
      kinowa earned a badge
      First Post
    • Rookie
      krychek57 went up a rank
      Rookie
    • Grand Master
      Jaybonaut went up a rank
      Grand Master
    • One Year In
      Philsl earned a badge
      One Year In
    • Dedicated
      Scoobystu earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      446
    2. 2
      +Edouard
      169
    3. 3
      PsYcHoKiLLa
      133
    4. 4
      Xenon
      77
    5. 5
      Michael Scrip
      75
  • Tell a friend

    Love Neowin? Tell a friend!