Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm having a terrible lot of trouble getting GRUB to work successfully.
When things go terribly wrong, sometimes it seems the best thing to do is to completely remove GRUB from the MBR.
I have tried the DOS command: FDISK /MBR, and WinXP recovery console commands: FIXMBR, FIXBOOT and possibly some others, but nothing seems to be able to erase the MBR to the depth that GRUB installs itself at.
After using any of the above commands, all I get at boot time is a nasty message saying "disk error". Even re-installing WinXP won't fix it. The only method I have found so far is a Seagate disk utility that does a quick low level format, which also destroys all partitions, but atleast then at boot time I get a much more friendly message "Insert system disk".
Anyone know how to wipe the MBR clean without damaging the partitions?
I have tried the DOS command: FDISK /MBR, and WinXP recovery console commands: FIXMBR, FIXBOOT and possibly some others, but nothing seems to be able to erase the MBR to the depth that GRUB installs itself at.
I am sorry that these Windows commands are not working for you, but you probably can't blame it on grub.
Your MBR makes up the first sector (512 bytes) of your harddisk. This first sector is numbered 0. The first 64 sectors of your harddisk are called "track 0". After track 0 is where "normal stuff" begins (your OS, typically).
Of your MBR, the first 442 bytes are called the "boot code". Then the next 4 bytes are the "volume bytes" (used only by newer versions of Windows, AFAIK). The next 64 bytes are called the "partition table". Then the remaining 2 bytes are "signature bytes" that mark the end of a valid MBR.
Installing grub to your MBR will overwrite the 442 bytes of boot code, and put some more data in the (normally unused) sectors 1 through 63. I don't think it goes all the way up to sector 63 - it probably ends significantly before that point.
Running the old msdos FDISK /MBR will overwrite those 442 bytes of boot code with code that should boot any version of Windows AFAIK. It may actually wipe out the first 446 bytes (including the volume bytes), but I can't remember for sure. I do not know why this is not working for you. Just the opposite usually happens. A very standard complaint on these forums is when someone has a working Linux installed, then installs Windows, and wonders where their Linux went. What happened is that Windows overwrote the boot code and thus wiped out grub (or lilo - another Linux bootloader that may be resident in the MBR).
When you run FDISK /MBR note that it does not clear out the part of grub that is in sectors 1 through 63. It doesn't need to. Windows does not use these sectors in track 0. Sectors 1 through 63 may contain nothing, or random data (an old grub install perhaps), and not make one bit of difference to Windows. I know of one sneaky program, Intuit's TurboTax, that installed some code in track 0 a few years back in an ill-conceived attempt at copy protection. This was Intuit's sneaky way to keep their code in place even if you reformatted your disk (format won't touch track 0). However, Intuit shoved it's code into track 0 without concern about what else might already be there. They were wiping out people's Linux grub and lilo installs!
Now back to your problem. I do not know why FDISK /MBR or the other tools you tried would not overwrite the bootcode as they were supposed to. You could use Linux to zero out the bootcode first, and then try your tools again. Assuming your harddisk is "hda", you can clear the bootcode like this:
Code:
# dd if=/dev/null of=/dev/hda bs=442 count=1
Be VERY careful to type this command correctly!!! A minor typo and you can really hose yourself. If you limit yourself to only zeroing the first 442 bytes of track 0, you will leave your partition table intact.
Saw you other thread, decided to stay out of it as I don't use FC. I don't understand why you have this problem, but do this from a Linux console
Code:
dd if=/dev/zero of=/dev/hda bs=1 count=446
Will leave your partition table intact - XP "fixmbr" will re-install the ntldr code.
Thank you both for your advice.
syg00's command worked perfectly, although it took "count=512". to completely erase the MBR and give me the old "disk boot failure - insert system disk" message that I was looking for.
Sorry haertig, but you syntax was slightly off - usage: bs=1 count=[bytes] seems to be the correct syntax, but only using "if=/dev/zero". Thank's very much though for your detailed explaination - it's given me me a much better understanding of what is going on within the MBR.
It didn't actually.
You destroyed the partition table - mis-interpretation of the symptoms (by you). The actual partitions still exist, as does the data contained therein.
Like when a file is deleted - you don't actually delete the file, just the pointer to it.
Situation is recoverable, but I think you have enough to keep you occupied ...
Sorry haertig, but you syntax was slightly off - usage: bs=1 count=[bytes] seems to be the correct syntax, but only using "if=/dev/zero".
Youy're right, /dev/zero is what I meant. Now didn't I tell you that you must be "very careful"?! But /dev/null might actually have worked by some stroke of luck (never tried it). Also, you can flip those bs and count parameters. It's just math. 1 * 442 = 442 * 1.
Now that you've whacked your partition table with a wipe of the first 512 bytes, you can attempt to use the "gpart" program (short for "guess partitions") to see if you can recover. If nothing else, your foray over to the Dark Side of harddisk maintenance will leave you with loads of experience to become a Jedi Master for teaching others!
although it took "count=512". to completely erase the MBR and give me the old "disk boot failure - insert system disk" message that I was looking for.
"...that I was looking for" ???!!!
You must be some kind of masochist. If you liked what 512 did for you, try something like "count=999999" for even MORE fun!
[ Please - don't really do that. It was a joke. You never know who's going to miss the sarcasm in one of these posts and really attempt a disk-blaster command like that! ]
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.