LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-08-2008, 01:19 AM   #1
centguy
Member
 
Registered: Feb 2008
Posts: 495
Blog Entries: 1

Rep: Reputation: 38
dual boot - MBR - reinstalled windows


I have dual-boot system (windowsXP+opensuse).

I try to simulate the steps given by
http://www.stoltenow.com/archives/20...alling_wi.html about restoring MBR after corrupting it.

I have saved the content of a working MBR in opensuse with this command:
dd if=/dev/sda of=/mnt/grub/save-mbr-image/mbr.image count=1 bs=512

where /mnt is mount point of /dev/sda3, which is the /boot of opensuse.

Without reinstalling WindowsXP, I purposely corrupted
/dev/sda with

dd if=/mnt/grub/save-mbr-image/random.image of=/dev/sda

As expect, I cannot boot to any OS.

After that I use the opensuse10.3 installation DVD and choose "Rescue
System".
I login as root and hoping that I can mount /dev/sda3 using

mount -t ext3 -o rw,dev /dev/sda3 /mnt

however, "mount: special device /dev/sda3 does not exist"

is the answer i get.

I became panic:

fdisk -l /dev/sda says "Disk /dev/sda does not contain a valid partition table".

At least now I learn through hard lesson that MBR contains the
partition table is need by fdisk !!

So is this the end of story ?? What can I do to rescue the system ?
Installing WindowXP will help ?
 
Old 04-08-2008, 01:25 AM   #2
return.c
LQ Newbie
 
Registered: Mar 2008
Distribution: Fedora
Posts: 11

Rep: Reputation: 0
I will not agree to this point that " if you corrupt your MBR then you cannot mount other partitions " I always reinstall Linux and Windows in my dual OS system. I always used to mount windows partitions from Linux, even though I modify the MBR. But I use two different hard drives for Linux and Windows.
 
Old 04-08-2008, 01:26 AM   #3
ronlau9
Senior Member
 
Registered: Dec 2007
Location: In front of my LINUX OR MAC BOX
Distribution: Mandriva 2009 X86_64 suse 11.3 X86_64 Centos X86_64 Debian X86_64 Linux MInt 86_64 OS X
Posts: 2,369

Rep: Reputation: Disabled
dual boot reinstalled windows

I the rescue mode of open suse there is also a automatic repair
Did this option works or not


all the best
 
Old 04-08-2008, 05:29 AM   #4
dr_agon
Member
 
Registered: Sep 2007
Location: Poland
Distribution: Ubuntu LTS
Posts: 104
Blog Entries: 12

Rep: Reputation: 26
If you corrupt only the bootloader, then you can mount the partitions anyway, but it seems centguy destroyed the partition table also (and hopefully nothing more).
Now you must restore the lost partition table using some utility from a live CD, and then repair the bootloader.
If you just reinstall Windows (or anything), it will probably create new partition table, and recovering any data from you disk will be almost impossible.
I know nothing about openSusie rescue, but there is a nice liveCD I use: SystemRescueCD and it has testdisk utility, which helped me a lot when I lost a partition
 
Old 04-08-2008, 08:11 AM   #5
scheidel21
Senior Member
 
Registered: Feb 2003
Location: CT
Distribution: Debian 6+, CentOS 5+
Posts: 1,323

Rep: Reputation: 100Reputation: 100
I am unsure but sda refers to the entire drive, and I am afraid you may have corrupted more than just the partition table and the MBR, hopefully you did not destroy all your data.
 
Old 04-08-2008, 08:27 AM   #6
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Well, hoss, this command:

dd if=/mnt/grub/save-mbr-image/random.image of=/dev/sda

didn't have a size limit on it, so it is kind of hard to know exactly what you have done, but it could be very bad. Unlikely to have destroyed sda3, but might have damaged sda1.

You obviously have destroyed your partition table, and the data you need to recover it neatly is on one of the partitions that you cannot access. Interesting conundrum.

Get yourself a copy of testdisk and run it. It will probably find and rebuild your partition table.

Yes, Virginia, the partition table IS in the MBR!!
 
Old 04-08-2008, 11:19 AM   #7
centguy
Member
 
Registered: Feb 2008
Posts: 495

Original Poster
Blog Entries: 1

Rep: Reputation: 38
Thanks for the concerns out there. I did my experiment on an old computer so it is not big deal. It is the time that I spent that I am worried about.

I am no genius, the command

dd if=/mnt/grub/save-mbr-image/random.image of=/dev/sda

was mentioned in http://www.stoltenow.com/archives/20...alling_wi.html

Anyway, I was extra careful before I committed to such dd operation.
Before I messed up everything, I login as root in opensuse and I overwrote MBR using this command with the correct mbr.image ONCE and
I am able to boot. As the for the size of random.image,
I have used dd if=/mnt/grub/save-mbr-image/a-random-text-file of=/mnt/grub/save-mbr-image/mbr.image count=1 bs=512
so there should be no issue with the size. I used ls -l to check the size of random.image, which is 512.

I tend to believe dr_agon that if I reinstall Windows or linux, the other partition
will be gone according to new partition table. So that's tough luck.

The dd method of overwriting MBR demands that I should not disturb
the existing partition table setting when I reinstall Windows(i.e., let the Windows installer create EXACTLY the same partition as before and overwrite the MBR --- I cannot create D: out of the original entire space for C. If not, the good old mbr.image will be in conflict with the new partition table, and that will be hell again. I hope I am right in this deduction. Well, so much so for the dumb dd method...
 
Old 04-08-2008, 12:12 PM   #8
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
centguy,

As jiml8 has already pointed out your have destroyed the partition table so no operating system can read your hard disk.

The information inside your hard disk may be in perfect order but the mean to read it has been destroyed.

I agree running the "testdisk" program, to let it rebuild your partition table, is the best advice.

If you start to re-partition, format the hard disk and write information on it you can kiss your existing data goodbye.

Actually if you have a copy of the original partition table or know the sizes, types and order of the partitions you can recreate the partition table with any Linux Live CD and not a single byte will be lost. I have done this loads of time. The partition table is positioned between 447th to 510th bytes and is only 64 bytes long. A total destruction of the partition does not affect the internal data of the partitions but without the partition table no operating system knows where to begin or stop when reading a partition.

People should never use dd to mess around the MBR which can always be regenerated by a system command in every operating system, regardless it is a Windows or a Linux.
 
Old 04-08-2008, 01:50 PM   #9
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Quote:
I tend to believe dr_agon that if I reinstall Windows or linux, the other partition
will be gone according to new partition table. So that's tough luck.
With a destroyed partition table, you may rest assured that a reinstall of anything will wipe out your partitions. I promise you that will happen.

And with respect to recovering partitions and disk structure and so forth, Saikee and I are the ones you want to listen to.
 
Old 04-08-2008, 01:58 PM   #10
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Quote:
People should never use dd to mess around the MBR which can always be regenerated by a system command in every operating system, regardless it is a Windows or a Linux.
I routinely use dd to back up my mbr.
 
Old 04-08-2008, 02:35 PM   #11
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194
If you were skilled at these things and if the contents of this hard drive were valuable enough to justify serious effort, it could be fixed. (If it happened to me, I would fix it. But I'm barely expert enough to do that for myself, not expert enough to talk you through every detail).

The saved mbr and partition table are somewhere on the disk. The disk can still be read (as raw data in /dev/sda). Once you deduce some distinctive content in the original MBR you can use some search utility to find the copy of it somewhere on /dev/sda and then copy it back where it belongs.

I've never tried that testdisk utility. It sounds like it might solve the problem with less effort and much less expertise required (by the user).

Last edited by johnsfine; 04-08-2008 at 02:38 PM.
 
Old 04-09-2008, 01:49 AM   #12
indikabandara19
LQ Newbie
 
Registered: May 2007
Posts: 18

Rep: Reputation: 0
Don't panic as yet. I too came across a similar scenario.
Do you remember the aproximate sizes of your partitions?
Boot with a Live CD(Knoppix is my choice). run parted and try rescue option.

When i came across this i didnt have any experience in rescuing a hd. so try. don't giveup.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux dual boot gone since i reinstalled windows mossy464 Linux - Newbie 5 03-25-2008 02:28 PM
reinstalled windows in dual boot,,,grub disappeared,,,help ace.adi Linux - Newbie 3 03-18-2007 12:46 PM
dual boot using Windows MBR lnxlrnr Linux - Laptop and Netbook 37 12-25-2006 03:19 AM
Reinstalled Windows, MBR overwritten Chapster Linux - Newbie 10 11-30-2003 08:47 AM
Reinstalled Windows 98 lost linux dual boot llefty Linux - Newbie 0 08-01-2003 01:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration