LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 01-15-2010, 12:43 AM   #1
hennipaste
LQ Newbie
 
Registered: Jan 2010
Posts: 9

Rep: Reputation: 0
Blew up my partition table


Hi, so I was gonna install OpenBSD 4.6 on my PC and I accidentally overwrote my boot partition. Initially my partition table looked something like this:
------------------------------------
/dev/sda1 - Grub
/dev/sda2 - Free Space
/dev/sda3 - Slackware
/dev/sda4 - Linux Swap
------------------------------------
/dev/sda1 started at cylinder 0 and ended at cylinder 0 but I started the OpenBSD partition at cylinder 0 as well, I ended it before /dev/sda3 started though.

Quote:
Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xc301df06

This doesn't look like a partition table
Probably you selected the wrong device.

Device Boot Start End Blocks Id System
/dev/sda1 ? 15357 229722 1721888152+ e8 Unknown
Partition 1 does not end on cylinder boundary.
/dev/sda2 ? 1 1 0 1 FAT12
Partition 2 does not end on cylinder boundary.
/dev/sda3 115307 125803 84312115+ 0 Empty
Partition 3 does not end on cylinder boundary.
/dev/sda4 ? 1 1 0 3f Unknown
Partition 4 does not end on cylinder boundary.

Partition table entries are not in disk order
That's what my partition table looks like according to fdisk. So I'm wondering how I'd go about recovering /dev/sda3 (what /dev/sda3 was before I blew it up). Thanks. (=

Last edited by hennipaste; 01-15-2010 at 12:46 AM.
 
Old 01-15-2010, 01:55 AM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
You might be able to make use of a tool like testdisk (running it from a live CD or USB key).
 
Old 01-15-2010, 02:01 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
In the future, I'd recommend also using "fdisk -lu" to list the partition table and printing the results. The first partition will start at an offset. Some other partitions may not start on a partition boundary as well sometimes. Listing the partition table using 512 byte sectors will eliminate rounding errors.

If the partitions were created in Linux, the first one probably starts on sector 63. I'd recommend using losetup to attach a loop device at this offset and seeing if the filesystem is still OK.

Code:
sudo /sbin/losetup -fs /dev/sda -o $((63*512))
# will respond with which loop device was used.  If your losetup doesn't have the -s option, you can use "sudo /sbin/losetup -a" to list the used loop devices.
sudo file -s /dev/loop0

# loop0 is used as an example.  It could be loop1.
# if file returns a filesystem, you can attempt to mount it.  The /boot partition is often ext2 or ext3.
sudo mount /dev/loop0 -t <filesystem>  /boot

sudo df --block-size=512 /boot
I'd recommend sticking with 512 byte sectors and block sizes on all your utilities during your recovery. It keeps things consistant and accurate. The df will give you an indication of the size of the filesystem, which you to use to learn what the start of the second is. This assumes the filesystems weren't wrecked already of course. Next, add the size in sectors of /boot to 63 to obtain what may be the offset of the next partition.

Also consider getting a large external drive to create a backup image (using dd) of your drive. This image backup can be used to reverse unsuccessful attempts, or you might use it to try to recover the partitions on this copy instead of the original. (using losetup with a file instead of device)

PS. I just noticed that third partition was empty. If it wasn't formated, then you can recover it, mount it to learn its size to find the start sector of the third partition. Otherwise if the second or third partitions did start on cylinder boundaries, and the cylinder size indicated by fdisk is the same, you can try perhaps look at multiples of 16064 sectors for the start of the third partition.

Last edited by jschiwal; 01-15-2010 at 02:21 AM.
 
Old 01-15-2010, 02:28 AM   #4
hennipaste
LQ Newbie
 
Registered: Jan 2010
Posts: 9

Original Poster
Rep: Reputation: 0
Sda1,3 and 4 were made with cfdisk in linux (i'm pretty sure cfdisk rounds to the nearest cylinder). /dev/sda1 + /dev/sda3 were ext3 and sda4 was a linux swap. I attempted to make /dev/sda2 in openbsd using fdisk but I accidently overwrote the first cylindar which was used by sda1. Shouldn't the errors only be on /dev/sda1 and /dev/sda2 as they're the only partitions that use cylinder 0?

Code:
ubuntu@ubuntu:/$ ls /dev/ |grep sd
ptysd
sda
ttysd
None of sda's partitions are shown in /dev/, so I can't mount any of them =X. The output of fdisk is what my partition table currently looks like. Thanks for replies <=

edit: Yay, testdisk restored my partition table. Thank you, neonsignal =D

Last edited by hennipaste; 01-15-2010 at 02:52 AM.
 
Old 01-17-2010, 08:01 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
There are no devices for /dev/sda1 or /dev/sda2 because your partition table is damaged.

You need to learn what the beginning and ending points of them were and re-create it. If you did wipe out the entire first cylinder, then your old /boot directory may be gone. However if you just wiped the first sector, you may be able to attach a loop device (at offset of 32256) and then mount the loop device. I provided an example in my last post.

I would highly recommend you read the Wikipedia artical on the MBR.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"No partition table or unknown signature on partition table" 10.1 install madcow007 Slackware 4 02-09-2009 11:04 AM
openSolaris hosed the partition table. Why? Changing primary to secondary partition? JZL240I-U Solaris / OpenSolaris 9 10-16-2008 10:48 AM
Blew up my NTFS partition with chmod while mounting can it be fixed? PSIPHON Linux - General 1 12-20-2005 11:57 PM
Slack 10: S-ATA = "No partition table or unknown signature on partition table"? dissolved soul Slackware - Installation 11 08-05-2004 02:12 PM
I blew my partition -- Can I save it? wmcase Linux - General 24 05-31-2004 06:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:56 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