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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
06-17-2005, 01:56 AM
|
#1
|
Member
Registered: Sep 2003
Location: California
Distribution: RH9, Fedora: FC1, FC3, Suse9.3
Posts: 54
Rep:
|
MBR zeroed. Can I verify backup MBR?
I am running FC3 with Grub in the /dev/hda MBR and / in /dev/hda7 .
I accidently zeroed my mbr. I have not rebooted. I have a backup file MBR.bin that I made last year. I don't think I changed the partitions since making the backup, but am not sure. Could I dd the MBR file to /dev/hda, do an fdisk p command, and compare the results to the output of gpart to see if they agree?
Is there another way to check if the MBR.bin agrees with my current partition structure, or to determine the partition structure from /proc?
I also have a recent dar backup. Is there a way to restore the MBR from it?
What is the best way for me to go from here?
Last edited by TomF; 06-17-2005 at 02:03 AM.
|
|
|
06-17-2005, 02:57 AM
|
#2
|
Member
Registered: Sep 2004
Location: India
Distribution: Solaris 9, FreeBSD 4.10, Slackware, RedHat, Knoppix,
Posts: 84
Rep:
|
boot from the CD in rescue mode
then
#chroot /mnt/sysimage
#grub-install <device name> (like /dev/hda1)
that should fix the boot record...u dont need a backup though
|
|
|
06-18-2005, 10:36 PM
|
#3
|
Member
Registered: Sep 2003
Location: California
Distribution: RH9, Fedora: FC1, FC3, Suse9.3
Posts: 54
Original Poster
Rep:
|
I discovered the file /proc/partitions, which has the partition structure that I zeroed out in the MBR. I copied it to another file system, so I won't lose it when I reboot.
I plan to try using dd to copy my backup MBR to the first 500 bytes of /dev/hda. Then I'll execute fdisk to print the partition table. If it is the same, I think I'll be done, and won't have to reinstall grub. Right?
If not, I'll still need to find out how to change the partition table in the MBR without affecting the data on the drive. Could I do this by executing fdisk with the first 500 bytes of /dev/hda zero, creating partitions according to the partitions file, and doing the grub-install? Could I do it by passing the partition structure to gpart -W?
|
|
|
06-18-2005, 11:13 PM
|
#4
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,441
|
Erkk !!! - how do you accidently zero the MBR ???.
You seem to have a fixation with the number 500 - did you merely zero just 500 bytes, or the whole sector ???.
May not matter, but fdisk (and cfdsik) for example won't open a disk without the signature bytes. If you only blotted 500 bytes, this won't affect you. Haven't tested if the following tools suffer the same restriction.
gpart may do the job for you, and testdisk has had good reports from people I've recommended it to.
Rebuilding the part table will not (for some value of "not"  ) mangle your data. Simply indicates the start and end (and sector count, and ... well, you get the idea) - not a problem.
UNLESS it's wrong - obviously that has the potential to hurt.
Once you're happy with the rebuilt part table, then you can re-install grub - that's a no-brainer. And yes, you should re-install - it also has sector offsets in it. Easy to install and be sure. Save the grub.conf/menu.lst first.
|
|
|
06-19-2005, 12:23 AM
|
#5
|
Senior Member
Registered: Oct 2003
Location: /earth/usa/nj (UTC-5)
Distribution: RHEL, AltimaLinux, Rocky
Posts: 1,151
Rep:
|
Before you do any more damage, you really should clarify how you "zeroed the MBR". It might help us suggest possible fixes.
|
|
|
06-19-2005, 10:42 AM
|
#6
|
Member
Registered: Sep 2003
Location: California
Distribution: RH9, Fedora: FC1, FC3, Suse9.3
Posts: 54
Original Poster
Rep:
|
I forgot about the last 12 bytes. The bad command was dd if=/dev/zero of=/dev/hda bs=512 count=1. I was trying to wipe out another drive in preparation for reallocating the partitions, but I pasted the command and forgot to correct the "of=" parameter.
'Rebuilding the part table will not (for some value of "not" ) mangle your data." I understand that if only the partition table is touched then the partition data is unaffected, and if the resulting partition table is correct, then the filesystems will be correctly mounted when I reboot.
I don't understand what fdisk does: does it store anything in the partitions when creating or modifying the partition table? I would guess not, since creating the filesystems is a separate operation, but I would like to be sure. Since gpart and testdisk are designed to fix the partition table, I would not expect them to touch the filesystems, but fdisk worries me.
I decided to check testdisk, and liked what I saw, so I installed and executed it. The results looked right, but were not formatted the same as the /proc/partitions file. I decided to save the partition table and execute the fdisk print command. fdisk shows hda1-hda9 the same as a previous fdisk, before I zeroed the MBR, and hda10 looks right, so I think the partition table problem is solved.
Since the testdisk suggestion worked so well, I'll also take the suggestion to do a grub-install /dev/hda1.
Added: the GRUB manual says to execute grub-install /dev/hda, so I did that instead. Then I remembered that /dev/hda1 is mounted to /boot, so I am again doubtful. Are the two grub-install commands equivalent, or should I re-install to hda1?
Thanks for the advice.
Last edited by TomF; 06-19-2005 at 11:14 AM.
|
|
|
06-19-2005, 07:16 PM
|
#7
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,441
|
fdisk is fine, it just defines the limits of the partition(s) as you would expect.
But it just won't talk to the disk if the entire first sector is zapped - see some of my mutterings here if interested.
So obviously testdisk did it's job if you could get fdisk to fire up.
As for grub, it *has* to be installed into the MBR - you currently have no loder code in there at all.
Remember ??? - some-one zeroed it out .... 
|
|
|
06-20-2005, 05:28 PM
|
#8
|
Member
Registered: Jul 2004
Distribution: LFS 5.1
Posts: 161
Rep:
|
If nothing helps you can use testdisk utility from www.cgsecurity.org .
This tool searches the disk for partitions and adds them to the partition table.
|
|
|
All times are GMT -5. The time now is 08:32 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|