Partition Table Disappeared

Forum: HD Install
Topic: Partition Table Disappeared
started by: Juanito

Posted by Juanito on June 30 2008,18:57

On my frugal hd install, I had four partitions:

sdb1 - ext2 data - 25GB
sdb2 - swap (linux 82) - 1GB
sdb3 - ext2 dsl image -2GB bootable
sdb4 - ext2 data - 8GB

On my last reboot, grub reported that hd1,2 no longer exists and sure enough only sdb1 remains  :(

Booting from sda, I can see the following in fdisk (expert mode):
Code Sample
Expert command (m for help): p

Disk /dev/sdb: 255 heads, 63 sectors, 4462 cylinders

Nr AF  Hd Sec  Cyl  Hd Sec  Cyl     Start      Size ID
1 80   1   1    0 254  63 1023         63   71681967 83
2 00   0   0    0   0   0    0          0          0 00
3 00   0   0    0   0   0    0          0          0 00
4 00   0   0    0   0   0    0          0          0 00

Expert command (m for help): v
5404 unallocated sectors it seems as though the four partitions are partially there, but I don't have much idea how to recover the 2nd, 3rd & 4th partitions without losing the data (which seems to be OK in sdb1). Actually, its the data in sdb4 that I really need.

Any suggestions on how I might go about fixing this with fdisk or any other tool would be most welcome...

Edit - additional info:
Code Sample
# fdisk -l

Disk /dev/sdb: 36.7 GB, 36703934464 bytes
255 heads, 63 sectors/track, 4462 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1        4462    35840983+  83  Linux

# mount -t ext2 /dev/sdb1 /mnt/sdb1
# df /mnt/sdb1
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sdb1             24169412  14475840   8465808  64% /mnt/sdb1
# df -h /mnt/sdb1
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdb1              24G   14G  8.1G  64% /mnt/sdb1

Posted by curaga on June 30 2008,19:53
Ouch. How did that happen?

Parted to the rescue, if you give it the approx start and end of each partition it should be able to rescue them.. The command inside parted is "rescue"..

Edit: also check out Wdef's testdisk.uci, it specializes in recovery

Posted by Juanito on June 30 2008,20:48
Thanks for the tips - 'discovered an "awesome" utility < gpart >
I couldn't compile the source, but the static binary went like this:
Code Sample
# ./gpart.linux /dev/sdb

Begin scan...
Possible partition(Linux ext2), size(23979mb), offset(0mb)
Possible partition(Linux swap), size(964mb), offset(23979mb)
Possible partition(Linux ext2), size(1913mb), offset(24944mb)
Possible partition(Linux ext2), size(8142mb), offset(26858mb)
End scan.

Checking partitions...
Partition(Linux ext2 filesystem): primary
Partition(Linux swap or Solaris/x86): primary
Partition(Linux ext2 filesystem): primary
Partition(Linux ext2 filesystem): primary

Guessed primary partition table:
Primary partition(1)
  type: 131(0x83)(Linux ext2 filesystem)
  size: 23979mb #s(49110640) s(63-49110702)
  chs:  (0/1/1)-(1023/254/63)d (0/1/1)-(3056/254/61)r

Primary partition(2)
  type: 130(0x82)(Linux swap or Solaris/x86)
  size: 964mb #s(1975992) s(49110705-51086696)
  chs:  (1023/254/63)-(1023/254/63)d (3057/0/1)-(3179/254/60)r

Primary partition(3)
  type: 131(0x83)(Linux ext2 filesystem)
  size: 1913mb #s(3919856) s(51086700-55006555)
  chs:  (1023/254/63)-(1023/254/63)d (3180/0/1)-(3423/254/59)r

Primary partition(4)
  type: 131(0x83)(Linux ext2 filesystem)
  size: 8142mb #s(16675464) s(55006560-71682023)
  chs:  (1023/254/63)-(1023/254/63)d (3424/0/1)-(4461/254/57)r

# ./gpart.linux -W /dev/sdb /dev/sdb

[same thing with this at the end]

Activate which partition (1..4, q to quit) : 3
Write this partition table (y,n) : y

* Warning: partition table written, you should reboot now.

..and I'm writing this from the fixed hd  :)

Ouch. How did that happen?

dunno, but - I was fighting with a usb stick and fdisk, moved it from my laptop (sdb1) to my old desktop (sdc1) and no doubt the inevitable happened

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.