LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   How can I rebuild a Linux MBR which was wiped out by XP? (https://www.linuxquestions.org/questions/linux-hardware-18/how-can-i-rebuild-a-linux-mbr-which-was-wiped-out-by-xp-4175451349/)

jdtiede 02-22-2013 11:00 PM

How can I rebuild a Linux MBR which was wiped out by XP?
 
I had a response that said look for grup/stage1, but in the new grub the only file is grupenv, and it is not human sensible. This is Kubuntu 12.11. I can't quite get a handle on using perhed for this. There is one 465Gb partition with two Linux OS files, representing 121.04 and 12.11, I think. There is a smalles part that works normally. When XP got thru with it, the big part. was shown as a Win type (FAT322 or NTSF, can't remember which). I got it back to ext3 op 4 with smarttools. Most of it was backed up to the other computer, USB stick, or ibackup.com. Then the USB stick failed with very little warning. I think I'm o.k. but even so I want to be able to use the rest of that disc again.

descendant_command 02-22-2013 11:30 PM

Boot from a repair disk (install disk or SuperGrub2Disk or such) and reinstall grub to mbr.

syg00 02-23-2013 02:40 AM

Go here, and do as it says. The output will tell us what your boot environment is and how to offer proper advice.

sulekha 02-23-2013 11:26 AM

Easiest way is as follows , get a copy of system rescue cd http://www.sysresccd.org/SystemRescueCd_Homepagethen boot from CD/DVD drive using system rescue CD , then you will get the option for BOOT AN EXISTING LINUX PARTITION ,choose it. after you have booted into linux go to package manager and search for grub or grub2 depending on your distro and then simply re-install it

business_kid 02-25-2013 01:26 PM

When you get it up & running, do the following to put backups in /boot
Quote:

dd if=/dev/sda of=/boot/sdambr bs=512 count=1
dd if=/dev/sda1 of=/boot/sda1mbr bs=512 count=1
Then when windows overwrites, just boot anything unix and copy them back.

bloody 02-28-2013 07:49 AM

Quote:

Originally Posted by business_kid (Post 4899469)
When you get it up & running, do the following to put backups in /boot
dd if=/dev/sda of=/boot/sdambr bs=512 count=1
dd if=/dev/sda1 of=/boot/sda1mbr bs=512 count=1
Then when windows overwrites, just boot anything unix and copy them back.

WARNING: that's assuming alot. First of all, the GRUB code is about 29KB for GRUB2 (smaller for GRUB-legacy). Never fits into 512 bytes. Although, it might be enough if the "destroyer" was Windows which puts more bootloader stuff into the system partition, i.e., it might have overwritten only 512 bytes indeed. *Might have*. A bit more uncommon on Linux installations because you usually install GRUB to sda, not sda1.

Second, tell the OP that you assume that "sda1" is what you believe to be his/her root partition, or more precisely, what the OP has originally specified to write to using "grub-install".

And eventually, this MBR backup stuff isn't explained in one sentence. It is a low-level operation which needs some knowledge in the first place. What if "sda1" is not marked bootable and already starts with the partition superblock in that very first sector, but then, that sector has changed over the last months and then you come and restore an old sector copy the hardcore way? Oha.

There is no real problem using this DD/MBR stuff - as long as you *exactly* know what you're doing. Giving such kind of advice to someone who asks, especially with a one-liner ala "do this and be happy" is dangerous.. no offense..


All times are GMT -5. The time now is 05:43 PM.