Help! Computer won't boot

Sureshot324

Diamond Member
Feb 4, 2003
3,370
0
71
I was trying to update my installation of Fedora core 2 to kernel 2.6.7, and after a reboot i got the error message "Error loading operating system". Now i cannot boot into windows xp or linux. My main hard drive is a 120gb and had Win XP and Fedora Linux on it. My second hard drive is a 60gb which is dynamic disk.

The last thing i did before the reboot was edit the grub configuration file so that the 2.6.7 kernel would use a ramdisk, since it wasn't working before. Also a while earlier I executed the following statement trying to resolve a problem i had:

dd if=/dev/zero of=/dev/hda bs=1022k count=1000

<a href="http://www.gridpp.ac.uk/tb-support/faq/mkinitrd.html">This</a> is the site that got that statement from. Apparently it changes something in the master boot record, and in retrospect executing this statement was probably a stupid idea.

I assumed that the problem was that my mbr got messed up somehow, so i put in my windows xp cd and executed fixmbr. It gave me a warning that the computer appears to have a non-standard or invalid master boot record and that continuing could damage my partition table. I ran it anyway but my computer still wouldn't boot. I went back into the winxp recovery console and ran partdisk and was shocked to see that hard disk 0 (the 120gb) is all unpartitioned space!

Is there any way to fix my boot sector so that my windows xp and linux partitions work again? Or at least get the data of the windows xp partition?
 

silverpig

Lifer
Jul 29, 2001
27,703
12
81
Okay, well it looked like mixmbr did mess up your partition table. The data is still there, but the table is gone. There are 2 options:

1. Find some tool on the internet that will fix the partition table. I've never used one so I can't recommend one.
2. If you remember the EXACT sizes of the partitions, then you can usually just re-write the partition table using fdisk and it should work again.

Once the partition table is up again, then put in the fedora cd and do an upgrade install, making sure to reinstall grub as you go. That should just about do it.
 

Sureshot324

Diamond Member
Feb 4, 2003
3,370
0
71
Originally posted by: silverpig
Okay, well it looked like mixmbr did mess up your partition table. The data is still there, but the table is gone. There are 2 options:

1. Find some tool on the internet that will fix the partition table. I've never used one so I can't recommend one.
2. If you remember the EXACT sizes of the partitions, then you can usually just re-write the partition table using fdisk and it should work again.

Once the partition table is up again, then put in the fedora cd and do an upgrade install, making sure to reinstall grub as you go. That should just about do it.

Are you sure that rewriting the partition tables like you said would work? What if I just made one big windows partition over the entire hard drive (i don't really care about the linux partition)?
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
dd if=/dev/zero of=/dev/hda bs=1022k count=1000

I think that command obliterated your entire master boot record along with your partition information. Completely gone. All zeros now, I'd probably just start from scratch again.


The way to get out of a broken boot up is to use Gruib's interactive command line feature. If there was a typo in the configuration or you had a wrong kernel selected, you just tell grub manually command by command what to do and boot up with that. That's one of the nice things about grub, that no matter what screwup happenned with the kernel selection or the configuation file you can always fix it safely.
 

pojen

Junior Member
Nov 6, 1999
16
0
0
dd if=/dev/zero of=/dev/hda bs=1022k count=1000

You had zero out near 1 GB?
I think you need to reinstall everything...
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Originally posted by: pojen
dd if=/dev/zero of=/dev/hda bs=1022k count=1000

You had zero out near 1 GB?
I think you need to reinstall everything...


I may be wrong, but that zeroe'd out slightly less then a meg. A MBR is 512k big. The first 300-400k is the actual part that has the loader installed, and the rest holds your partition information.


That's all your MBR is, it's not a special physical thing or hard-coded into the harddrive or anything like that, it's just the first 512k starting at the beginning of the disk. No special boundries or limits or protections beyond that.

This command is usefull for "fixing" the MBR. This is because the fixmbr/fdisk /mbr stuff is flawed. Most of the time it does a good job at resetting that area of the disk, but it doesn't aways erase all the information. So sometimes you end up with a MBR that can't be "fixed" in a normal way. This command simply writes zeros.

the "dd" command is a Unix command that basicly means "copy" a file. But it doesn't do the entire file, it mearly does the copy bit by bit by bit. Since with Unix's hardware abstraction "everything is a file" you have 2 things here. /dev/zero is a special file that means "infinate zeroes". /dev/hda represents your harddrive. So basicly the command is to copy zeroes to the beginning of your harddrive until you have 1024 bytes written 1000 times. So that obliterates your MBR completely.

Usefull for getting rid of boot viruses, too.

You do the same thing to make images of disks. Just like Ghost utility does. 2 things that people use it for is making a image of a floppy or cdrom. Like this:

dd if=/dev/cdrom of=CdromImage.iso

And that creates a ISO image you can burn to another cdrom.

It sucks when stuff like this happens. You can probably rescue your data, it's still their after the MBR is gone, but you computer normally has no way to find it.
 

Sureshot324

Diamond Member
Feb 4, 2003
3,370
0
71
Ok, i repartioned and reformatted and surprisingly got almost everything back with a data recovery program, so it didn't turn out too badly.

Originally posted by: drag

I may be wrong, but that zeroe'd out slightly less then a meg.

1024k x 1000 is a gb, no? Shouldn't this command have some kind of a warning or confirmation before it zeros out your hard drive?
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Next time you run the man files.

DD command has a lot of uses besides writing zeros, you can make scipts to automaticly backup entire partitions for instance. You can also backup the MBR, too, you know.

Scripts and stuff like that is one of the reasons that when people tried to switch from Unix to NT they had to hire 3-4 times as many techs to do the job.

If the thing asked yes/no everytime you told it do something wouldn't that be annoying? The majority of the time your going to use it, it would be used inside a script. 9 times out of 10.

~ >: dd if=/dev/zero of=cool bs=1024k count=1000
1000+0 records out
1048576000 bytes transferred in 17.977840 seconds (58326028 bytes/sec)

~ >: ls -lh cool
-rw-r--r-- 1 drag drag 1000M Jul 4 22:43 cool1000+0 records in


right about the size though. Usually you don't specify k, I didn't notice that.