1

Topic: Invalid partition table - recursive partition

I had a Windows partitioning program cause Windows to blue screen in the middle of deleting a extended partition logical drive operation.  The process wiped out another logical drive partition.  I used another partitioning program to recover that logical drive, but in the process it wiped out a different logical drive!  I went in by hand with a disk sector editor to try to fix up the extended partition linked list of logical drives, but there is still something very wrong that I can't figure out!

Ok, I know that's a long story, but it shouldn't be too hard to resolve.  I booted into the GParted Live CD to try to make sense out of the condition.   While GParted scans the drive, an error box comes up with this message:

Invalid partition table - recursive partition on /dev/sda

Maybe somebody has a clue what the problem is here?   That error message is coming from the Linux parted program that provides the backend of GParted, but all other Linux utilities seem to have no problem with the partition table.  I also can even mount the affected partition after booting the live Linux CD, though there is indeed something wrong with the partition definition because GRUB can't mount and boot this Linux partition.

Here's the output from 'fdisk -l' which sees no problem and the affected logical drive /dev/sda6 is there and all good:

user@debian:~$ fdisk -l

Disk /dev/sda: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: TOSHIBA MK5061GS
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x2bd44934

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1            2048    206847    204800   100M  7 HPFS/NTFS/exFAT
/dev/sda2  *       206848 329715711 329508864 157.1G  7 HPFS/NTFS/exFAT
/dev/sda3       329715712 623859711 294144000 140.3G  7 HPFS/NTFS/exFAT
/dev/sda4       623859712 976771071 352911360 168.3G  f W95 Ext'd (LBA)
/dev/sda5       623861760 767059967 143198208  68.3G  7 HPFS/NTFS/exFAT
/dev/sda6       767059968 834168831  67108864    32G 83 Linux
/dev/sda7       834170880 850948095  16777216     8G 82 Linux swap / Solaris
/dev/sda8       850950144 976771071 125820928    60G  7 HPFS/NTFS/exFAT

With 'parted -l', however, we get the error, and after entering 'Ignore' the affected partition is missing from the list:

user@debian:~$ parted -l
Error: Invalid partition table - recursive partition on /dev/sda.
Ignore/Cancel? Ignore

Model: ATA TOSHIBA MK5061GS (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End    Size    Type      File system     Flags
 1      1049kB  106MB  105MB   primary   ntfs
 2      106MB   169GB  169GB   primary   ntfs            boot
 3      169GB   319GB  151GB   primary   ntfs
 4      319GB   500GB  181GB   extended                  lba
 5      319GB   393GB  73.3GB  logical   ntfs
 6      427GB   436GB  8590MB  logical   linux-swap(v1)  swap
 7      436GB   500GB  64.4GB  logical   ntfs

I'd attach images of 'gparted' display, but it seems like this forum has no ability to upload images?   Basically, upon clicking 'IGNORE' in GParted, the /dev/sda6 is still shown in the list, but the partition types and names are shifted downward.  I certainly do not see any recursive partitions or other error in the raw partition tables, but something is clearly wrong!  It wasn't like this before, and it must be something stupid.  Trying to figure out how to repair this!


CP

2

Re: Invalid partition table - recursive partition

I think I figured out the problem.  If you look closely, you'll notice that the data area for /dev/sda6 includes the extended partition's logical drive partition table.  Hence the recursion.  The system must have been that way all along, as the partition values in the lost partition are not something that I hand entered!  That's probably why the partition repair utility deleted this logical drive.  Somehow, Linux itself actually doesn't care about this, and can mount the partition notwithstanding.

No idea how it got this way, either a bug in the installer or something I did wrong long ago and never realized until now.  I'm wondering the best way to fix this?  Somehow, I need to shift the whole 32GB of data (or most of it, anyway) forward in-place by at least 1 sector, luckily the swap partition which follows is easy to drop or re-size.  Or, I suppose I could re-size the prior NTFS partition by the minimum and move the logical drive partition table into the new gap.  GRUB may need to be re-installed too, as the sector number for the stage loading may be changing...

3

Re: Invalid partition table - recursive partition

I wouldn't trust the state of the chain of EBRs (Extended Boot Records).  EBRs are a linked list each describing one logical partition and the location of the next EBR.

Therefore I suggest the following:
1. Backing up everything.
2. (Assuming sda6 is your Linux's root file system) making sure you know where it's boot code is and how to re-add it.
3. Deleting all logical partitions and extended partition.
4. Recreate extended partition and logical partitions.
5. Restre data to logical partitions.

4

Re: Invalid partition table - recursive partition

mfleetwo wrote:

I wouldn't trust the state of the chain of EBRs (Extended Boot Records).

Therefore I suggest the following:
1. Backing up everything.
...

Well there would be a cool new feature for GParted: Backup of partition tables

The best advice out there to do this is using 'dd' for raw dump and and 'sfdisk -d' (or 'sgdisk' for GPT) for human-readable dump.  Would not be hard to get GParted to do both and produce a data file that could be re-loaded to examine or restore a damaged partition table on a disk (or replicate it on a backup drive).  Automatic backup generation before each GParted operation, or upon demand, would be really helpful, as I don't see other tools out there doing this much.