Debian – Recover lost partitions ( or partition table) after fdisk in debian

debian-squeezefdisk

I am running Debian Squeeze in my laptop. I did a big mistake. Instead of doing fdisk /dev/sdb (which is my usb pendrive), I fdisk-ed /dev/sda, which is my primary hdd.
When prompted, I chose options o and w and the reboot my machine.

Now, I cannot start my machine as it says no OS found.

Is it that, all my data is lost or only the partition table? How do we recover the data?

Edit:-
Initially I had 5 partitions. The partitions are as follows:-
A 105 GB for Windows installation, a 170 GB for storing data (possible NTFS), another 170 GB (possibly NTFS), a 1 GB (swap space) and 20 GB (ext4 partition). I was having a debian squeeze and win 7 dual boot.

105 GB
170 GB
170 GB
1 GB
20 GB

After loading an Ubuntu live cd, when I tried to see whether any partition structure exist using the Gpart command like,

sudo gpart /dev/sda

I got the following output:

ubuntu@ubuntu:~$ sudo gpart /dev/sda

Begin scan...
Possible partition(Windows NT/W2K FS), size(107419mb), offset(59139mb)
Possible partition(DOS FAT), size(2mb), offset(187738mb)
End scan.

Checking partitions...
Partition(OS/2 HPFS, NTFS, QNX or Advanced UNIX): primary 
Partition(Primary DOS with 12 bit FAT): primary 
Ok.

Guessed primary partition table:
Primary partition(1)
   type: 007(0x07)(OS/2 HPFS, NTFS, QNX or Advanced UNIX)
   size: 107419mb #s(219996159) s(121117248-341113406)
   chs:  (1023/254/63)-(1023/254/63)d (7539/51/1)-(21233/83/33)r

Primary partition(2)
   type: 001(0x01)(Primary DOS with 12 bit FAT)
   size: 2mb #s(4544) s(384488496-384493039)
   chs:  (1023/254/63)-(1023/254/63)d (23933/77/1)-(23933/149/8)r

Primary partition(3)
   type: 000(0x00)(unused)
   size: 0mb #s(0) s(0-0)
   chs:  (0/0/0)-(0/0/0)d (0/0/0)-(0/0/0)r

Primary partition(4)
   type: 000(0x00)(unused)
   size: 0mb #s(0) s(0-0)
   chs:  (0/0/0)-(0/0/0)d (0/0/0)-(0/0/0)r

ubuntu@ubuntu:~$

The screenshot is at
enter image description here

Shall I continue to write to the disk ? Does the partitions shown match my previous partitions as I mentioned ?

Best Answer

Boot from a Live CD and try using testdisk or gpart utilities, which can in many cases find lost partitions automatically. One popular Live CD distribution suited for such recovery tasks is SystemRescueCd.

Related Question