PDA

View Full Version : I am in hell, Trust me.



Schopenhauer101
01-14-2005, 05:44 AM
Sigh!

I have deleted the MBR. Yes i know, then everything is lost and unrepairable.

*BUT, the thing is that i have not yet booted my computer yet*.

When i do all will be gone forever, hda1, hda2, hda3, all of it. No harddisk recovery program will ever get the system back. I have (had?) a dualbootsystem that i have optimised for a half year or so. I feel sick when i think about it. But now everything works nice, i can access all partitions everything is still here, exept when i take a look on hda with qtparted. Then hda ofcourse is totally unreadable, because it tries to read from the actual master boot record (and not from memory and the post-booted info on disk.)

THE QUESTION :
Is there anyway that i can copy the data my computer is aware of right now when it still is unbooted and put it on the mbr? Something in the /boot folder? Anything that would make it possible to once more see that lovely Debian dualbootscreen once more? Can i make a startupdisk with the help of grub? And then copy the floppy to the hda bootblock?

How did this happend?
I was going to to copy a image of the mbr of my external drive to that very drive(sda1) but by fatal error i copied to hda. Adios partitions.

The limits of language fails to express how grateful i would be if someone could offer a glimpse of salvation out of this evil mess.

Thanks for reading this,
Björn.

eon
01-14-2005, 06:25 AM
Take some deep breaths and know that most of us can relate to this.

I have used this bootloader ( see link below ) to rescue systems I couldn't boot any other way

http://gujin.sourceforge.net/

My thought is if you can enter/boot the system with this bootloader you can
then create a floppy or reinstall grub from the running system itself.

I'm sure there are ways to do this with grub, at the command, line but my experiance
is mostly editing menu.1st. In fact I haven't found the grub command line to be so easy.

Good luck!

Note: It seems like most of the ideas put forth, after this post, focus on different tools which are fine.
But I'll just say that I have gujin on a floppy just for this type of situation and it never fails to boot a
reluctant system (as long as it's still there) I just like the lazy approach.

greenfly
01-14-2005, 08:17 AM
First, relax. Everything will be fine.

I've done the same thing before--accidentally overwritten my partition table but the rest of the files are there. Luckily there is a tool called gpart that can recover everything for you. When I give Knoppix talks, I actually purposely write zeros over my MBR with dd and then recover with gpart while the audience is watching. I go over the steps in my talk at http://greenfly.org/talks/knoppix_hacks/intro.html near the end, but here are the basic steps:

1) Open a terminal and type:
sudo gpart /dev/hda

2) The gpart program will scan your system for partitions and then recreate a partition table based on them. Check out what partitions it finds.

3) If you accept what it finds, run
sudo gpart -W /dev/hda /dev/hda

4) The -W option will write the new partition table onto /dev/hda, so run this when you are fine with what it says. If you see a minor discrepancy, don't edit it within gpart as it can get a bit complicated. I've found that it's easier to use cfdisk afterwards.

5) Run
sudo cfdisk /dev/hda and check out your new partition table. You can make any changes you need to (I've noticed gpart doesn't always find the end of the partition correctly so it'll be a few megs off).

6) Try to get this far. I assume at this point that your partition table is restored. The next step is to restore the boot loader, but all of that depends on whether you use lilo or grub. You need to identify your root partition. Let's say it is /dev/hda2

7) Mount your root partition:
sudo mount -o rw /dev/hda2 /mnt/hda2

8a) If you use lilo:
sudo chroot /mnt/hda2 lilo

8b) If you use grub:
sudo chroot /mnt/hda2 grub-install /dev/hda or if that doesn't work,
sudo grub-install --root-directory=/mnt/hda2 /dev/hda

9) reboot and everything should be normal

Harry Kuhman
01-14-2005, 08:27 AM
I have deleted the MBR. Yes i know, then everything is lost and unrepairable.
.....
When i do all will be gone forever, hda1, hda2, hda3, all of it. No harddisk recovery program will ever get the system back........
Not at all. The first question is just how did you delete the MBR, and did you delete just the MBR or the entire first sector?

If I recall right, The first sector of your hard disk contains both the mbr and the partition table. If you've just deleted the MBR (the first four hundred and some bytes of the sector), you can easily fix it. "FDISK /MBR" from the DOS command line is one way. You might also look at it as an excelent oppertunity to install Smart Boot Manager to the hard disk MBR; think of it as an upgrade with no down side risk.

If the entire first sector is blown, including that the partition table is gone, then you would need some way to rebuild the partition table. Turns out there's a handy linux command to do just that! It scans your hard drive, figures out where the partitions are and their type and size and recreates the table for you. If only I could remember the name of that command (but then what fun would Linux be without all of the cryptic commands that only geeks know?) Sadly, I'm sure the program is there but not as sure of the name, but you might look and see if there is a command called "gpart" or somethings very similar to that (I'm on Windows at the moment and can't boot Knoppix because of other things running that shouldn't be stopped) . And, of course, after fixing the partition table, you'll want to do one of the above to replace the MBR too.

Good luck and please post back to let others know how it goes (and what you did to kill the MBR in the first place).

Harry Kuhman
01-14-2005, 08:28 AM
Ah, I see that while I was typing greenfly posted and confirmed that it is gpart! Great.

Schopenhauer101
01-14-2005, 08:59 AM
Hi and thanx alot for your advices and concern. Well im writing this from a knoppix cd so i think that pretty much gives a clue about how my system (and nervous system too) is doing. Well everything isnt death and despair anyway after all.

Let me tell. First i burned a backup-cd of the entire /boot folder with grub and all inside. About 12 megs. Then i created a grub bootfloppy with stage1 and 2 whatever that is supposed to mean. then i downloaded and created a GAG boot disk. And then i found out something great. In the grub folder there is always a file called "boot.0300" That file is actually a mbr-image. I googled around a bit more and then after a while i felt secure enough to add the image to my hda. Then i opened qtparted again. YES, all partitions back again looking just the way they are supposed to.

Relifed i rebooted my decitefull little darling just too get struck by the famous 99 99 99 99 99 99 99 screen. Sigh. I inserted the grubdisk and it showed all that i wanted. But it couldnt launch linux, it complained about the stuff not being on my harddrive. I tried the GAG disk and reached a very limited grub shell. The XP partition worked however. I then used knoppix and found my linuxpartitions and everything on em to be alive.

If anyone knows how to make grub come alive again it would be great. I really miss my linux system and hope to be able to stay away from XP as much as possible exept when using my music/midi equipment.

Thanx for all help. The partition table seems to be ok, and if anyone knows how to get things working with grub it would be great help coz the stuff i get when i google is so contradictory.

Take care/
Bj;rn

greenfly
01-14-2005, 09:15 AM
<snip>

If anyone knows how to make grub come alive again it would be great. I really miss my linux system and hope to be able to stay away from XP as much as possible exept when using my music/midi equipment.

Thanx for all help. The partition table seems to be ok, and if anyone knows how to get things working with grub it would be great help coz the stuff i get when i google is so contradictory.

Take care/
Bj;rn

Congrats! I bet you feel a lot better now. I'm glad you were able to find a backup copy of your MBR. The steps are slightly different since you have a separate /boot partition. Assuming your /boot partition is /dev/hda2 here is what you do:

1)
sudo mount -o rw /dev/hda2 /mnt/hda2

2)
cd /mnt/hda2; sudo ln -s . boot this creates a recursive symlink called boot, as the grub-install tool expects to be pointed to a directory that contains a boot directory inside.

3)
sudo grub-install --root-directory=/mht/hda2 /dev/hda this should restore grub completely to your boot code.

4) Reboot and hopefully you should see your old grub menu.

Schopenhauer101
01-14-2005, 09:32 AM
Thank you, really!!! When shit like this kind of crashes happens i wonder why i bother to care about linux or even computers in general. But when i get suprised the other way around, by the effort, friendliness and solidarity from people stuck in the linux swamp im really quick to re-remember why it fun and worth it.

I will try out to reinstall grub but im first going to check out the smart boot manager, just because ive never tried it before. I do not by the way have a separate boot partition. I got a boot folder under / on hda. Should that make anything very different from what you recommended?

Take care, and thanx once more.

/Bj0rn

greenfly
01-14-2005, 06:23 PM
If /boot is under your root partition and not on a separate partition, you can simply skip the step that makes a boot symlink inside your /boot directory.

Schopenhauer101
01-17-2005, 12:59 PM
This is a great forum. Everythings works fine. This night i will browse around the forum and see if i can help some people that got some very newbie questions:
Take care all.
/Björn

simmons71
01-18-2005, 05:56 AM
:?
i am trying to dual boot my xp system without messing it up. amd xp 2800, 512 mb ram, 160 gb hd. xp installed in hda1 ntfs, hda2 is a fat32 i use for music files, hda3 is where i keep installing knoppix, hda4 is swap. all are primary. i first tried to use ntldr to boot xp and knoppix...did not work. i then tried to use gag boot disk. it wont boot knoppix from hda3.

i would like step by step commands as if i popped in cd and booted knoppix.
is it better to type knoppix single in first boot menu and run knoppix-installer or something else?
should i keep my four partitions as primary, or should i do something else like extended partitions?

i have been hunting for something that will work. i have been reading the boards for a while and nothing seems to work. i would prefer to use ntloader, but a single boot disk or gag is ok too.

thanks

simmons71
01-18-2005, 05:58 AM
:?
i am trying to dual boot my xp system without messing it up. amd xp 2800, 512 mb ram, 160 gb hd. xp installed in hda1 ntfs, hda2 is a fat32 i use for music files, hda3 is where i keep installing knoppix, hda4 is swap. all are primary. i first tried to use ntldr to boot xp and knoppix...did not work. i then tried to use gag boot disk. it wont boot knoppix from hda3.

i would like step by step commands as if i popped in cd and booted knoppix.
is it better to type knoppix single in first boot menu and run knoppix-installer or something else?
should i keep my four partitions as primary, or should i do something else like extended partitions?

i have been hunting for something that will work. i have been reading the boards for a while and nothing seems to work. i would prefer to use ntloader, but a single boot disk or gag is ok too.

btw, i got everything to work on my laptop, i used only knoppix, not a dual boot setup.

thanks

greenfly
01-18-2005, 06:25 AM
It's generally considered very bad form to post your own new question inside an existing thread like this (often known as hijacking a thread). I'd recommend posting your question as a new thread and see who can help you.