BackTrack, or System Rescue CD to perform your rescue.
[root@home]# cd /dev/ # You forgot the option to use, so : [root@home]# man sfdisk # You read the man page, and find that this is -d. Let's try : [root@home]# sfdisk -d /dev/sdb # partition table of /dev/sdb unit: sectors /dev/sdb1 : start= 63, size= 192717, Id=83 /dev/sdb2 : start= 192780, size= 240975, Id= 7 /dev/sdb3 : start= 0, size= 0, Id= 0 /dev/sdb4 : start= 0, size= 0, Id= 0 # Let's go : [root@home]# sfdisk -d /deb/sdb > sdb
Just when pressing Enter, you realize that you are in /dev and you just filled the first bytes of /dev/sdb with something that does not really look like a MBR or a computer readable partition table.
Two possibilities :
Disk /dev/sdb: 222 MB, 222298112 bytes 255 heads, 63 sectors/track, 27 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x7a697320
This doesn't look like a partition table Probably you selected the wrong device.
Device Boot Start End Blocks Id System /dev/sdb1 ? 76368 126628 403709618 20 Unknown Partition 1 has different physical/logical beginnings (non-Linux?): phys=(32, 32, 32) logical=(76367, 148, 54) Partition 1 has different physical/logical endings: phys=(32, 32, 32) logical=(126627, 27, 12) Partition 1 does not end on cylinder boundary. /dev/sdb2 ? 13 27 120487+ 7 HPFS/NTFS
Partition table entries are not in disk order
In the latter case, your partition table is unreadable. Once rebooted, the OS won't be able to access your partitions anymore. Another mean to crash the partition table is to play with tools like Partition Magic. How do you know you have crashed your partition table ? Just when your OS can't see them anymore :)
It's time to introduce teskdisk(1).
Testdisk is intended to fix exactly what you have broken : the partition table. To perform that, it scans the disk in search of special bytes and partition boundaries.
In my case, I "just" crashed the primary partition table, but testdisk can be used if you have (un)intentionally erased a partition when playing with Partition Magic.
Rescuing a partition table with testdisk is rather straightforward. Let's go :
[root@home]# testdisk /dev/sdb TestDisk 6.11, Data Recovery Utility, April 2009 Christophe GRENIER <grenier@cgsecurity.org> http://www.cgsecurity.org
TestDisk is free software, and comes with ABSOLUTELY NO WARRANTY.
Select a media (use Arrow keys, then press Enter): Disk /dev/sdb - 222 MB / 212 MiB - ATA VBOX HARDDISK
[Proceed ] [ Quit ]
Go on with 'Proceed' Please select the partition table type, press Enter when done. [Intel ] Intel/PC partition [EFI GPT] EFI GPT partition map (Mac i386, some x86_64...) [Mac ] Apple partition map [None ] Non partitioned media [Sun ] Sun Solaris partition [XBox ] XBox partition [Return ] Return to disk selection
I suppose you use an Intel partition. So go on with it. [ Analyse ] Analyse current partition structure and search for lost partitions [ Advanced ] Filesystem Utils [ Geometry ] Change disk geometry [ Options ] Modify options [ MBR Code ] Write TestDisk MBR code to first sector [ Delete ] Delete all data in the partition table [ Quit ] Return to disk selection
You have lost partitions, so 'Analyse' is your choice.
Current partition structure: Partition Start End Size in sectors 1 * Willowsoft OFS1 76367 148 54 126627 27 12 807419236
Warning: Bad starting cylinder (CHS and LBA don't match) 2 * HPFS - NTFS 12 0 1 26 254 63 240975 Only one partition must be bootable
*=Primary bootable P=Primary L=Logical E=Extended D=Deleted [Quick Search] [ Backup ]
Validate on 'Quick Search'
Should TestDisk search for partition created under Vista ? [Y/N] (answer Yes if unsure)
Give the appropriate answer.
Disk /dev/sdb - 222 MB / 212 MiB - CHS 27 255 63 Partition Start End Size in sectors * Linux 0 1 1 11 254 63 192717 P HPFS - NTFS 12 0 1 26 254 63 240975
Hey, testdisk has found your lost partitions :) Just press Enter.
Partition Start End Size in sectors
1 * Linux 0 1 1 11 254 63 192717 2 P HPFS - NTFS 12 0 1 26 254 63 240975
[ Quit ] [Deeper Search] [ Write ]
Take a deep breath and press 'Write'
Write partition table, confirm ? (Y/N)
Light a candle and press 'Write'
You will have to reboot for the change to take effect.
Say yes, and quit testdisk (you'll have to validate on 'Quit' several times)
Actually, you don't have to reboot if partprobe is installed. If it is, just type 'partprobe'
Ask fdisk -l /dev/sdb what it thinks about your rescue : Device Boot Start End Blocks Id System /dev/sdb1 * 1 12 96358+ 83 Linux /dev/sdb2 13 27 120487+ 7 HPFS/NTFS
Congratulate yourself, and eventually give some money to the coders of testdisk.
Be careful when you are root and play with your disks and partition table. It's very easy to make a mistake that will destroy a partition. Since your are making backups (isn't it ?), this lost is not very harmful.
But testdisk, which can find and restore lost partitions, can be a great help in some cases, and make you save time.