LinuxQuestions.org
Review your favorite Linux distribution.
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
 
Search this Thread
Old 02-20-2005, 06:21 AM   #1
nikhil
LQ Newbie
 
Registered: Feb 2005
Posts: 6

Rep: Reputation: 0
Question HDD Partition Table Recovery


hi all..

I need help!!! It's a long message, but i hope somebody does read it.. I've tried to give it some pointwise structure..


-->I had fedora core 2 + windows 98 dual boot on my pc,

-->but screwed up my HDD's partition table over a week ago while installing Mandrake 10.1..

-->partition table of /dev/hda was crooked even before i installed mandrake,used to show some 'overlapping' error,but was working.

-->Two partitions stopped showing on windows and linux became unbootable after the crash.

-->So i formatted the linux partition, and mindlessly did 'fdisk /mbr', and while trying to see data in my previous extended partition, the dos fdisk did an "integrity check" on it, and it stopped working.

-->I have tried testdisk, gpart and ranish's partition table editor, but this has helped me recover only 1 out of the 2 partitions that were lost.

-->The partitions as far as i remember, before the disaster were :
1 windows ( around 10 gb )
one exteneded partition consisting of 2 logical parts : linux ( 8 gb ) & one other partition ( maybe a swap partition )
& 2 more partitions of 8 gb each for songs.
Disk utilities used to show errors like corrupt partition table, overlapping partitions etc. but everything worked k even after errors.

-->One thing i did before installing mandrake was to save the output of fdisk -l command on my main hard disk.. it was as follows :
-------------------------
Disk /dev/hdd: 20.0 GB, 20020396032 bytes
16 heads, 63 sectors/track, 38792 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

Device Boot Start End Blocks Id System
/dev/hdd1 * 1 19380 9767488+ c W95 FAT32 (LBA)
/dev/hdd2 19381 38792 9783648 f W95 Ext'd (LBA)
/dev/hdd5 19381 38792 9783616+ b W95 FAT32

Disk /dev/hda: 40.0 GB, 40020664320 bytes
16 heads, 63 sectors/track, 77545 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 20321 10241752+ c W95 FAT32 (LBA)
/dev/hda2 59814 60021 104422+ 83 Linux
Partition 2 does not end on cylinder boundary.
/dev/hda3 20321 59814 19904535 f W95 Ext'd (LBA)
Partition 3 does not end on cylinder boundary.
/dev/hda4 60021 77536 8827717+ 8e Linux LVM
Partition 4 does not end on cylinder boundary.
/dev/hda5 20321 38776 9301635 b W95 FAT32
/dev/hda6 38777 59814 10603152 b W95 FAT32

Partition table entries are not in disk order
-------------------------

-->also, i don't remember how, but i have o/p of gpart when the harddisk was working ( probably )...

dev(/dev/hda) mss(512) chs(77545/16/63) #s(78165360) size(38166mb)
Primary partition(1)
type: 012(0x0C)(DOS or Windows 95 with 32 bit FAT, LBA) (BOOT)
size: 10001mb #s(20483505) s(63-20483567)
chs: (0/1/1)-(1023/15/63)d (0/1/1)-(20320/15/63)r
hex: 80 01 01 00 0C 0F FF FF 3F 00 00 00 B1 8D 38 01

Primary partition(2)
type: 131(0x83)(Linux ext2 filesystem)
size: 101mb #s(208845) s(60291945-60500789)
chs: (1023/254/63)-(1023/254/63)d (59813/7/1)-(60020/9/63)r
hex: 00 FE FF FF 83 FE FF FF 69 FB 97 03 CD 2F 03 00

Primary partition(3)
type: 015(0x0F)(Extended DOS, LBA)
size: 19438mb #s(39809070) s(20482875-60291944)
chs: (1023/15/63)-(1023/6/63)d (20320/5/1)-(59813/6/63)r
hex: 00 0F FF FF 0F 06 FF FF 3B 8B 38 01 2E 70 5F 02

Logical partition
type: 011(0x0B)(DOS or Windows 95 with 32 bit FAT)
size: 9083mb #s(18603270) s(20482938-39086207)
chs: (1023/15/63)-(1023/15/63)d (20320/6/1)-(38775/15/63)r
hex: 00 0F FF FF 0B 0F FF FF 3F 00 00 00 06 DD 1B 01

type: 007(0x07)(OS/2 HPFS, NTFS, QNX or Advanced UNIX)
size: 0mb #s(0) s(20483404-20483403)
chs: (0/170/0)-(1022/128/58)d (20320/13/26)-(20320/13/25)r
hex: 55 AA 00 00 07 80 FA FE 11 02 00 00 00 00 00 00

Logical partition
type: 011(0x0B)(DOS or Windows 95 with 32 bit FAT)
size: 10354mb #s(21206304) s(39086208-60292511)
chs: (1023/15/63)-(1023/15/63)d (38776/0/1)-(59813/15/63)r
hex: 00 0F FF FF 0B 0F FF FF 3F 00 00 00 20 95 43 01

Primary partition(4)
type: 142(0x8E)(Linux LVM physical volume)
size: 8620mb #s(17655435) s(60500790-78156224)
chs: (1023/254/63)-(1023/254/63)d (60020/10/1)-(77535/14/63)r
hex: 00 FE FF FF 8E FE FF FF 36 2B 9B 03 8B 66 0D 01


dev(/dev/hda) master boot record (w/o partition table):
0000: fa eb 21 01 b4 01 4c 49 4c 4f 16 05 51 86 35 42
. . ! . . . L I L O . . Q . 5 B
0010: 00 00 00 00 57 b9 e5 01 57 75 09 00 01 00 80 60
. . . . W . . . W u . . . . . `
0020: 4a 30 98 03 b8 c0 07 8e d0 bc 00 08 fb 52 53 06
J 0 . . . . . . . . . . . R S .
0030: 56 fc 8e d8 31 ed 60 b8 00 12 b3 36 cd 10 61 b0
V . . . 1 . ` . . . . 6 . . a .
0040: 0d e8 66 01 b0 0a e8 61 01 b0 4c e8 5c 01 60 1e
. . f . . . . a . . L . \ . ` .
0050: 07 80 fa fe 75 02 88 f2 bb 00 02 8a 76 1e 89 d0
. . . . u . . . . . . . v . . .
0060: 80 e4 80 30 e0 78 0a 3c 10 73 06 f6 46 1c 40 75
. . . 0 . x . < . s . . F . @ u
0070: 2c 88 f2 66 8b 7e 18 66 09 ff 74 21 52 b4 08 b2
, . . f . ~ . f . . t ! R . . .
0080: 80 cd 13 72 55 92 98 91 ba 7f 00 42 66 31 c0 40
. . . r U . . . . . . B f 1 . @
0090: e8 71 00 66 3b bf b8 01 74 03 e2 ef 5a 53 8a 76
. q . f ; . . . t . . . Z S . v
00A0: 1f be 20 00 e8 4b 00 b4 99 66 81 7f fc 4c 49 4c
. . . . K . . . f . . . L I L
00B0: 4f 75 27 5e 68 80 08 07 31 db e8 35 00 75 fb be
O u ' ^ h . . . 1 . . 5 . u . .
00C0: 06 00 89 f7 b9 0a 00 f3 a6 75 0d b0 02 ae 75 08
. . . . . . . . . u . . . . u .
00D0: 06 55 b0 49 e8 d3 00 cb b4 9a b0 20 e8 cb 00 e8
. U . I . . . . . . . . . . .
00E0: b8 00 fe 4e 00 74 08 bc e8 07 61 60 e9 60 ff f4
. . . N . t . . . . a ` . ` . .
00F0: eb fd 66 ad 66 09 c0 74 0a 66 03 46 10 e8 04 00
. . f . f . . t . f . F . . . .
0100: 80 c7 02 c3 60 55 55 66 50 06 53 6a 01 6a 10 89
. . . . ` U U f P . S j . j . .
0110: e6 53 f6 c6 60 74 58 f6 c6 20 74 14 bb aa 55 b4
. S . . ` t X . . t . . . U .
0120: 41 cd 13 72 0b 81 fb 55 aa 75 05 f6 c1 01 75 4a
A . . r . . . U . u . . . . u J
0130: 52 06 b4 08 cd 13 07 72 59 51 c0 e9 06 86 e9 89
R . . . . . . r Y Q . . . . . .
0140: cf 59 c1 ea 08 92 40 83 e1 3f f7 e1 93 8b 44 08
. Y . . . . @ . . ? . . . . D .
0150: 8b 54 0a 39 da 73 39 f7 f3 39 f8 77 33 c0 e4 06
. T . 9 . s 9 . . 9 . w 3 . . .
0160: 86 e0 92 f6 f1 08 e2 89 d1 41 5a 88 c6 eb 06 66
. . . . . . . . . A Z . . . . f
0170: 50 59 58 88 e6 b8 01 02 eb 02 b4 42 5b bd 05 00
P Y X . . . . . . . . B [ . . .
0180: 60 cd 13 73 10 4d 74 0a 31 c0 cd 13 61 4d eb f0
` . . s . M t . 1 . . . a M . .
0190: b4 40 e9 45 ff 8d 64 10 61 c3 c1 c0 04 e8 03 00
. @ . E . . d . a . . . . . . .
01A0: c1 c0 04 24 0f 27 04 f0 14 40 60 bb 07 00 b4 0e
. . . $ . ' . . . @ ` . . . . .
-------------------------
( some logical + extended partition overlapping probably )
-------------------------

-->Now, output of "fdisk -l" is as follows :
-------------------------
Disk /dev/hdd: 20.0 GB, 20020396032 bytes
16 heads, 63 sectors/track, 38792 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

Device Boot Start End Blocks Id System
/dev/hdd1 * 1 19380 9767488+ c W95 FAT32 (LBA)
/dev/hdd2 19381 38792 9783648 f W95 Ext'd (LBA)
/dev/hdd5 19381 38792 9783616+ b W95 FAT32

Disk /dev/hda: 40.0 GB, 40020664320 bytes
16 heads, 63 sectors/track, 77545 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 20321 10241752+ c W95 FAT32 (LBA)
/dev/hda2 38777 59814 10602868+ c W95 FAT32 (LBA)
/dev/hda3 20322 38776 9301320 f W95 Ext'd (LBA)
/dev/hda4 59860 77069 8673840 83 Linux
/dev/hda5 20322 38776 9301288+ b W95 FAT32

Partition table entries are not in disk order
-------------------------

-->I know that the data is still there, and it's accessible too using GetDataBack, but i want to somehow get that partition showing again and working properly..

-->-->My Question:
----------------------
can i edit my partition manually and feed the previous ( even overlapping ) values ?


And don't think that i've been idle in the last few weeks, i have read many threads about hdd partition recovery on LQ and googled a lot ( found mostly commercial s/w there ).. But in vain.

Plz help !
waiting eagerly for replies..

nikhil
 
Old 02-20-2005, 08:39 AM   #2
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 114Reputation: 114
You have all the information you need to recover your partition table manually, but you have to know what you are doing.

Also, you say you had warnings about overlapping partitions but "everything was working". Overlapping partitions will inevitably lead to file system corruption and data loss, when you least expect it. You do need to fix this, but not until after you have recovered data. The indicated partitions for your drive hda are a mess; you need to straighten that out and know what it is you want to accomplish before you do anything.

You will need the linux disk editor (lde) - try to find it on your system and if you can't then google for it.

Alternatively you will need to use the dd command and a hex editor. Using lde would be simpler because you can alter the MBR in place but if you have to you can extract the MBR using dd, then edit it in a hex editor, then put it back.

Go here for detailed information on the structure of partition tables and the exact location of every byte of information contained in the partition table.

http://www.netsys.com/library/papers/multiboot.pdf

edit

Actually, you could use parted as well. Parted will let you make a partition wherever you tell it to make it. This would be a lot easier.

Last edited by jiml8; 02-20-2005 at 08:54 AM.
 
Old 02-20-2005, 08:51 AM   #3
nikhil
LQ Newbie
 
Registered: Feb 2005
Posts: 6

Original Poster
Rep: Reputation: 0
thanx jiml8.. !

but i'd like to make backup of the current partition tables before experimenting :-)

Code:
dd if=/dev/hda of=backup bs=512 count=1
should be enough.. right ? or do i need to take backups for hda1, hda2, etc. individually also.. ?
 
Old 02-20-2005, 08:55 AM   #4
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 114Reputation: 114
Ummm...

I edited my post but saw you had replied.

Yes, the dd command you list will back up your MBR. Beyond that, try parted as I specified in an edit of my previous post. IIRC, I suggested this to you when you first posted about your problem.
 
Old 02-20-2005, 09:05 AM   #5
nikhil
LQ Newbie
 
Registered: Feb 2005
Posts: 6

Original Poster
Rep: Reputation: 0
ok

but won't parted format the partitions created by me.. or if i give the wrong parameters, overwrite some of my data .. ? ( i can risk losing a few files.. most of data on the lost partition was songs in mp3 format )...
 
Old 02-20-2005, 09:06 AM   #6
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 114Reputation: 114
parted edits partition tables. I don't know if it will format.
 
Old 02-20-2005, 09:17 AM   #7
nikhil
LQ Newbie
 
Registered: Feb 2005
Posts: 6

Original Poster
Rep: Reputation: 0
hmm.. i'll read about lde & parted in a day or two and post about progress made soon.. not today ! too much of pc already...

thanx mate.. really appreciate it ..
 
Old 02-22-2005, 05:33 AM   #8
nikhil
LQ Newbie
 
Registered: Feb 2005
Posts: 6

Original Poster
Rep: Reputation: 0
parted didn't help much

i tried its 'mkpart' & 'rescue' commands, but that didn't help in recovery.. prob i faced was that it takes input in "mega bytes" and i've the backup info in blocks ( i suppose )..

am apprehensive about using lde as it looks quite difficult to use.

isn't there any disk partition table editor in which i could directly feed the backup values that i have with me ( in blocks/sectors whatever .. )



plz help

nikhil
 
Old 02-22-2005, 07:24 AM   #9
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 114Reputation: 114
Quote:
isn't there any disk partition table editor in which i could directly feed the backup values that i have with me ( in blocks/sectors whatever .. )
look at sfdisk. It will do it too and should be easier than lde.
 
Old 02-22-2005, 07:37 AM   #10
aufomechanic
Member
 
Registered: Sep 2004
Distribution: Make my own
Posts: 30

Rep: Reputation: 15
Cant help a whole lot. I imagine you are doing a floppy of net boot

Your probably going to have to do a nfs mount or boot off other drive
then
e.g.
sfdisk -d /dev/hda > partitiontable.out
That will give you the table and later you will be able to cat partitiontable.out | sfdisk /dev/hda

But to do the back up use dump and restore you can put these on the NFS mount

Think this is the syntax
dump 0 -f /mnt/somenfsmount/opt.dump /dev/hda3

Then you can use restore later

A bit of advise no matter what the tool tells you make sure to run fsck on a dry run after partitioning
 
Old 03-04-2005, 10:08 AM   #11
nikhil
LQ Newbie
 
Registered: Feb 2005
Posts: 6

Original Poster
Rep: Reputation: 0
Success !!!

After many weeks of fiddling with linux tools.. i finally got hold of one for windows. called "partition table doctor" and it worked like magic.. !

the screwed up partition was fixed, and it was too easy to do ? why aren't there such tools for linux too ? ( i've used testdisk many times.. but believe me PTD is much more user friendly. )

but a few of my mp3's are corrupted due to the whole ordeal.. :-( really doesn't matter that much though

then i converted a partition from logical to primary using partition magic, and installed mandrake.. TOO EASY installation.. and what cooool interface ... and the amrok mp3 player is tooo good..

thnx guys for ur help.. :-)

nikhil.
 
  


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
partition table recovery phoenix7 Linux - Distributions 8 08-10-2005 12:47 AM
how to copy partition table from 1 hdd to another? turbokid Fedora 4 12-10-2004 03:04 PM
Fedora Core 2 HDD Geometry Partition Table problem. morrolan Fedora 1 10-01-2004 09:27 AM
Partition table recovery SYakush Linux - General 4 08-04-2004 04:55 AM
File recovery after partition table damage - XFS file system gracecourt Linux - General 2 01-13-2004 03:53 PM


All times are GMT -5. The time now is 04:40 AM.

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 Google+: linuxquestions
Open Source Consulting | Domain Registration