Recent versions of fdisk
start the first partition at sector 2048 by default. If you're seeing some other behavior, then either you're using a rather elderly version of fdisk
or there's a bug in the version of fdisk
that you're using.
You could also use parted
or GParted for this task. They both work with MBR disks as well as with GPT disks, so using one of these tools does not necessitate switching to GPT. That said, GPT does have certain advantages, even on smaller disks. They're minor, but you might want to consider using GPT to get these advantages. (These include having CRCs of important data structures to spot problems, having a backup of important data structures to help recovery from some types of problems, having partition labels, eliminating the awkward primary/extended/logical quagmire, and of course supporting over-2TiB disks.)
Well, a more knowledgeable answer will be appreciated - however, at least I found how to avoid this problem, while writing the OP. Btw this is TestDisk 6.11, Data Recovery Utility, April 2009
on Ubuntu 11.04. After the disk is blank, re-start the sudo testdisk
and follow the trace in the OP to get to the same screen (the one you get after you:
- hit
l
for L: load backup
;
- choose
Disk /dev/sdc - ...
for Choose the backup you want to restore:
and then hit [ Load ]
)
Here, go to the second entry, and: Use Left/Right Arrow keys to CHANGE partition characteristics:
until you get D=Deleted
for that partition; it looks something like this:
Now, obviously, no more "bad structure" is reported, and everything is green; interestingly, only this partition reacts like this (the first one, for example, induces no change even if it is set to D
).
Now I just press Enter: to continue
; get this on next screen:
Partition Start End Size in sectors
1 P Linux 0 1 32 10244 36 26 20980827
2 E extended LBA 10244 38 1 57231 63 32 96230208
5 L Linux 10244 38 26 40962 39 6 62910477
6 L Linux 40962 41 6 49151 63 26 16771797
7 L Linux 49152 1 26 53246 44 4 8385867
8 L Linux Swap 53246 46 4 57231 35 32 8160957
At it, choose [ Write ] Write partition structure to disk
; and
- answer
y
to Write partition table, confirm ? (Y/N)
- get
You will have to reboot for the change to take effect.
, hit [Ok]
- choose
[ Quit ] Return to disk selection
on next screen
- choose
[ Quit ] Quit program
on next screen
Now I can do this:
$ sudo fdisk -lu /dev/sdc
Disk /dev/sdc: 60.0 GB, 60011642880 bytes
64 heads, 32 sectors/track, 57231 cylinders, total 117210240 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c0705
Device Boot Start End Blocks Id System
/dev/sdc1 63 20980889 10490413+ 83 Linux
/dev/sdc2 20980928 117211135 48115104 f W95 Ext'd (LBA)
/dev/sdc5 20980953 83891429 31455238+ 83 Linux
/dev/sdc6 83891493 100663289 8385898+ 83 Linux
/dev/sdc7 100663353 109049219 4192933+ 83 Linux
/dev/sdc8 109049283 117210239 4080478+ 82 Linux swap / Solaris
... and nearly everything is the same as in the original partition table in the OP - except here I have "f W95 Ext'd (LBA)
" while above it was "5 Extended
" for the second (sdc2
, "extended") partition.
If someone can point out what am I doing wrong, and what should I do exactly to reconstruct the exact same partition table even after a deletion, I'd appreciate it.
EDIT: I think I got something more; the difference is not only in "f W95 Ext'd (LBA)
" vs "5 Extended
"; but also, from fdisk
- in first case:
255 heads, 63 sectors/track, 7296 cylinders, total 117210240 sectors
/dev/sdc2 20980890 117210239 48114675 5 Extended
... and in second case:
64 heads, 32 sectors/track, 57231 cylinders, total 117210240 sectors
/dev/sdc2 20980928 117211135 48115104 f W95 Ext'd (LBA)
So, the CHS geometry - and the region of the extended partition - is wrong; that is probably the meaning of the Warning: the current number of heads per cylinder is 64 but the correct value may be 255.
obtained in the OP. So once we get to the main menu in testdisk
we can change geometry:
[ Geometry ] Change disk geometry
[ Heads ] Change head geometry
Enter the number of heads:
255
[ Sectors ] Change sector geometry
Enter the number of sectors per track (1-63):
63
[ Cylinders ] Change cylinder geometry
(no change here):
Enter the number of cylinders:
7296
[ Ok ] Done with changing geometry
[ Analyse ] Analyse current partition structure
[Quick Search] Try to locate partition
n
to Should TestDisk search for partition created under Vista ? [Y/N]
testdisk
now finds the partitions that were deleted; hit L: load backup
Disk /dev/sdc -
to Choose the backup you want to restore:
then [ Load ]
Again Structure: Bad.
and duplicated partitions; set every second one to D
- bad structure clears:
Finally:
Enter: to continue
[ Write ] Write partition structure to disk
y
to Write partition table, confirm ? (Y/N)
[Ok]
to You will have to reboot for the change to take effect.
[ Quit ] Return to disk selection
[ Quit ] Quit program
Now fdisk
will report the same geometry - and the same range for the extended partition:
255 heads, 63 sectors/track, 7296 cylinders, total 117210240 sectors
...
/dev/sdc2 20980890 117210239 48114675 f W95 Ext'd (LBA)
/dev/sdc2 20980890 117210239 48114675 5 Extended # first
/dev/sdc2 20980928 117211135 48115104 f W95 Ext'd (LBA) # second
... and comparing to previous reports, now we have the same range as the first, but still not the same filesystem type (f W95 Ext'd (LBA)
instead of 5 Extended
); but it looks much better like this, at least.
Best Answer
It looks like they wasn't. I re-formatted it using
as adviced here and let the first partition start at the offset 58720256 = 56 * 2**20 (so losing 58MB). Now, parted doesn't even start (message "Can't have a partition outside the disk!"), but the disk works fine and according to my limited knowledge and to the calculator, everything's fine.