LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
LinkBack Search this Thread
Old 12-16-2004, 05:28 PM   #1
sleeper.service
LQ Newbie
 
Registered: May 2004
Distribution: Mandrake 9.2
Posts: 16

Rep: Reputation: 0
Overwrote partition table. System still running. :) Ways to restore?


As the title says...

Self = fool, fool, fool
I was going to restore a CompactFlash drive image.

Was supposed to be writing to /dev/sda
Accidentally wrote to /dev/hda :: oops ::
Quickly hit Ctrl-C, but damage was already done.

MBR = gone
Partition table = gone
Windows partition = corrupt
Linux partition = up, running, fine... self-destruct on next reboot
Data = all backed up, ready to reboot

So, essentially... I could reboot and reinstall.
But can anyone recommend a way to determine
which partition table layout I booted with, and write this layout
back onto the drive?

Last edited by sleeper.service; 12-16-2004 at 05:32 PM.
 
Old 12-16-2004, 05:40 PM   #2
sleeper.service
LQ Newbie
 
Registered: May 2004
Distribution: Mandrake 9.2
Posts: 16

Original Poster
Rep: Reputation: 0
Heh.
Had one idea:

Might the output of /proc/partitions... match my partition table's "state before disaster"?

:: goes to compare ::
 
Old 12-16-2004, 06:13 PM   #3
egag
Senior Member
 
Registered: Jul 2004
Location: Netherlands
Distribution: Slackware
Posts: 2,718

Rep: Reputation: 48
maybe a program called " testdisk " can help you here. i heard it's good for repair.....
( google for it )

EDIT: i don't know , but if the partition-table is in the mbr (?) : there might be a file "/boot/boot.0300 " wich in fact is a copy of your mbr-before-storing-lilo-there.

egag

Last edited by egag; 12-16-2004 at 06:23 PM.
 
Old 12-17-2004, 09:37 AM   #4
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 46
You should have a backup of the mbr at /boot/boot.0300

dd if=/boot/boot.0300 of=/dev/hda bs=1 count=512 skip=446 seek=446

then run lilo again to put lilo back on the mbr.

Explanation:
bs=1 <- 1 byte at a time
count=512 <- mbr=512 bytes
skip=446 <- first 446 bytes of boot.0300 are bootstrap code.
seek=446 <- that skips to the partition table.

NOTE: If you made any changes to your partition table since boot.0300 file was created then they will be lost. This could cause data loss if you don't know how to recreate the partition table exactly as before.
 
Old 12-17-2004, 11:11 AM   #5
egag
Senior Member
 
Registered: Jul 2004
Location: Netherlands
Distribution: Slackware
Posts: 2,718

Rep: Reputation: 48


EDIT: i need new glasses

egag

Last edited by egag; 12-17-2004 at 11:14 AM.
 
Old 12-18-2004, 01:03 PM   #6
Not now, John!
Member
 
Registered: Jul 2004
Distribution: LFS 5.1
Posts: 161

Rep: Reputation: 30
Use TestDisk from www.cgsecurity.org. It should work.
 
Old 12-18-2004, 11:22 PM   #7
J.W.
Guru
 
Registered: Mar 2003
Location: Milwaukee, WI
Distribution: Mint
Posts: 6,642

Rep: Reputation: 67
If you recreate your partitions exactly as they were before, you should be fine. I've done this myself, but the partitioning scheme needs to be exact. In other words, the partition sizes as well as the partition order must be identical to how it was before.

To illustrate, if you had defined:

/dev/hda1 = 128Mg /boot
/dev/hda2 = 256Mg swap
/dev/hda3 = 6G /usr
/dev/hda5 = 6G /var
/dev/hda6 = 10G /
/dev/hda7 = (everything else) /home

then if you recreate those partitions in the same order, you should be OK. Good luck with it -- J.W.
 
Old 12-19-2004, 12:02 AM   #8
eeyoree
Member
 
Registered: Aug 2004
Distribution: Slackware Ten
Posts: 34

Rep: Reputation: 15
try like /bin/bash says

as alternative try gpart (find it with google, it should be in the first list)
 
Old 12-19-2004, 12:18 AM   #9
n0xvb
Member
 
Registered: Sep 2004
Location: 127.0.0.1
Distribution: Slackware 13; openSUSE 11.2
Posts: 255

Rep: Reputation: 31
There is a HOWTO called "Partition-Rescue" that might be just the ticket. On my Slack system, it's located in /usr/doc/Linux-HOWTOs
 
Old 12-19-2004, 01:06 PM   #10
sleeper.service
LQ Newbie
 
Registered: May 2004
Distribution: Mandrake 9.2
Posts: 16

Original Poster
Rep: Reputation: 0
Thank you for your kind recommendations.
In the end... I didn't run out of tools... but time.

I first looked at my output of "/proc/partitions", but found some oddities.
Did not dare to use -- copied into another machine (just in case).
Then I tried "gpart", but presence of extended partitions confused it.
It could not determine the original partition table layout.
Testdisk arrived at the same result.

Perhaps part of the problem was... that the data which overwrote
my partition table... was not random trash, but contained another parition table,
originating from a CompactFlash card.

In the end... I set the corrupted disk aside for analysis
(later extracted some source code from the Windows partition)
and started installing things onto a new disk (faster too).
Since everything I stored under Linux (read: most things)
were successfully evacuated, I obtained a working system reasonably fast
(and a new kernel too).

So things are... nearly back to normal.
And there's a CD-ROM on my bookshelf.
With double backups of my current partition table.

Last edited by sleeper.service; 12-19-2004 at 01:12 PM.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
create a system restore disc/partition devildodger Linux - Software 0 11-12-2005 04:51 PM
How to restore partition table without a CDROM? welson_sun Fedora - Installation 2 10-11-2005 03:30 PM
ext3 partition table restore pats Linux - General 1 07-22-2005 10:44 PM
Why can't I restore a partition table backup containing a reiser partition? oldweasel Linux - Software 2 05-23-2004 12:11 AM
No partition table present on scsi drive How do I restore it? kosiadis Red Hat 1 10-17-2003 04:50 PM


All times are GMT -5. The time now is 12:25 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration