3

So, I have Linux Mint installed on my computer and then attempted to install WindowsXP on another primary partition. After the installation finished, I found my data partition sda9 (which is a logical one) had been deleted. I think I didn't delete it by mistake so I guess it's caused by Windows XP installer. I tried to use TestDisk to analyze the disk and fix the partition table, and I am now able to access to my data partition from both Mint and Windows XP.

The problem is, when I use parted to show partitions on my disk, it shows an error like this:

Error: Can't have a partition outside the disk!

However, fdisk -l shows all the partitions correctly

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 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: 0x0006a436

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048    61442047    30720000   83  Linux
/dev/sda2        61442048   106498047    22528000    7  HPFS/NTFS/exFAT
/dev/sda3       106498048   204802047    49152000    7  HPFS/NTFS/exFAT
/dev/sda4       204802101   976784129   385991014+   f  W95 Ext'd (LBA)
/dev/sda5       204804096   214566895     4881400   82  Linux swap / Solaris
/dev/sda6       225279495   286712054    30716280    7  HPFS/NTFS/exFAT
/dev/sda7       286712118   327661739    20474811    1  FAT12
/dev/sda8       360454144   417796095    28670976   83  Linux
/dev/sda9       417798144   976773119   279487488    7  HPFS/NTFS/exFAT

Disk /dev/sdb: 16.0 GB, 16008609792 bytes
255 heads, 63 sectors/track, 1946 cylinders, total 31266816 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: 0x0004f355

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048    31266815    15632384    c  W95 FAT32 (LBA)

sda9 was the data partition that was somehow deleted, sda6 and 7 are 2 unknown partitions that TestDisk wrote to my partition table. Other than that, all the partitions are correct.

How should I fix my partition table now?

0

1 Answer 1

1

Your sda4 partition is invalid. That output says your drive has 976773168 sectors, yet sda4 ends at 976784129. This is not possible.

The solution is to recreate that partition with a correct size. However this is the tricky part. Since that is an extended partition, you have to delete every single partition after it. None of the partitions after it actually extend past the end of the disk, so you should be safe as long as you recreate them with the exact same start and end locations.

Note, it would still be a good idea to back up your data. Especially since things aren't in a "normal" state right now.

4
  • I'll backup my data and recreate sdsa4, but I wonder if there is any other way to fix sda4 without deleting other logical partitions? Like, can we directly write to the partition table and change the sda4 end into sda9 end?
    – boh
    Commented Nov 28, 2013 at 3:59
  • Technically possible yes, but much simpler/safer to use fdisk. As long as partitions have the same locations & sizes, the data isn't harmed. There is also sfdisk which has the ability to dump and restore a table. Could dump it, modify the dump, and then restore it.
    – phemmer
    Commented Nov 28, 2013 at 7:04
  • Thanks Patrick. I tried sfdisk and it helps, but Im not sure if the fixed partition table is not corrupted one. I am not quite clear about your suggestion, you mentioned deleting all logical partitions but my data is still unharmed?
    – boh
    Commented Nov 28, 2013 at 15:03
  • Altering partition tables has no impact on the data in the partitions. All the partition table does is tell the kernel where each partition begins and ends. If that information is screwed up, the data is still there, but the kernel just doesn't know where it's at. The harm comes when operating systems see "oh, this partition doesn't look like a filesystem, it must be unused" and then trash it. *nix OSs generally wont do this, but in windows, anything goes.
    – phemmer
    Commented Nov 28, 2013 at 22:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .