corrupted partition table after formatting

Hello.

I have a dual-boot system with Windows 7 and Opensuse and a shared storage ntfs partition. I wanted to upgrade from 12,1 to 13,1 so when with a clean install. Before that, i booted into the live usbstick and with gparted when to reformat beacause this time i wanted a smaller windows partition. After doing that, i went to install did clean install of win 7, but the partitioner showed me just a 137gb partition. I booted back into the suse livestick and open gparted which gave this error: Invalid partition table - recursive partition on /dev/sda and shows just a whole of 931,51 unollocated space with a warning of the aforementioned error with the first sector 0, last sector:1953525167, total sectors: 1953525168

I googled around, and this seems to be a mbr, dos something issue. I’m not sure what to do, because i had a shared 850gb partition with data and i don’t want it erased. (i know i shoul’ve backed up, but i didn’t have where to)

fdisk -l

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 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 label type: dos
Disk identifier: 0x00000001

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           0   268435454   134217727+   4  FAT16 <32M

Disk /dev/sda1: 137.4 GB, 137438952960 bytes, 268435455 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 label type: dos
Disk identifier: 0x00000001

     Device Boot      Start         End      Blocks   Id  System
/dev/sda1p1   *           0   268435454   134217727+   4  FAT16 <32M

That looks like the hybrid partitioning scheme for versions of opensuse prior to 13.1 (or, perhaps, prior to 12.3). It seems that gparted does not like that.

One way of fixing it from linux:


# gdisk /dev/sdX       ### be sure to get the right X
x
z
w

The “x” takes you to the expert menu within “gdisk”.
The “z” zaps the partition table (overwrites with zeros).
As I recall, it also asks if you want to zap the MBR. Say “yes” (or is it “y”) to that.
Saving the results should give a completely unpartitioned disk. You can then partition as you like (but not with “gdisk” unless you want GPT partitioning).

Warning - this may lose all data, though you can often recover by creating partitions in exactly the right places to account for the data.

On 2014-02-17 23:06, nrickert wrote:
>
> Penguin_Warrior;2625438 Wrote:
>>>
> Code:
> --------------------
> > > Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors

> >
> > Device Boot Start End Blocks Id System
> > /dev/sda1 * 0 268435454 134217727+ 4 FAT16 <32M
> >
> > Disk /dev/sda1: 137.4 GB, 137438952960 bytes, 268435455 sectors

> > Device Boot Start End Blocks Id System
> > /dev/sda1p1 * 0 268435454 134217727+ 4 FAT16 <32M
> >
> --------------------
>>>
>
> That looks like the hybrid partitioning scheme for versions of opensuse
> prior to 13.1 (or, perhaps, prior to 12.3). It seems that gparted does
> not like that.

No, it is a recursive partitioning scheme.

There is partition sda1, and inside that you get another partition
table, with one partition, sda1p1.

Never seen it before. :-o


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))

On 2014-02-17 21:56, Penguin Warrior wrote:

> Code:
> --------------------
> Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors

> Device Boot Start End Blocks Id System
> /dev/sda1 * 0 268435454 134217727+ 4 FAT16 <32M

> Disk /dev/sda1: 137.4 GB, 137438952960 bytes, 268435455 sectors

> Device Boot Start End Blocks Id System
> /dev/sda1p1 * 0 268435454 134217727+ 4 FAT16 <32M
>
> --------------------

Indeed, a recursive partition. Never seen it before, just a theoretical
construct. Well, I did, on a raid setup. I could not use it for anything
(device nodes were not created or something).

Your sda disk has one partition of 137 GB, and inside that there is
another partition table, the one that Windows 7 saw, and said had 137
GB. Inside there is another partition, named sda1p1.

I would try first to mount sda1p1 somehow, and see if there is something
inside. If there is, and you want to keep it, you have to back it up on
a different disk - sorry, no alternative, you can not use the same disk.

Then umount “/dev/sda1p1”.

The next step would then be to remove the partition “sda1p1”, calling
fdisk on “/dev/sda1”, not “/dev/sda” (which was probably your initial
error that created the problem).

Then I would try to mount “/dev/sda1”, to see if there is data inside.
If there is, back it up to a different disk.

Then, calling fdisk on “/dev/sda”, remove that partition and erase the
partition table.

Finally, use “gpart” on “/dev/sda” to see if it can guess the original
partition table. maybe it can find the data partition you have lost.

As a safety, you could make backups of both partition tables.

If gpart locates the old partition and you can reconstruct the partition
table enough to mount and read that data partition, backup the contents
somewhere else.

Final step, recreate a new partition table, from scratch. Doubtful you
can trust much of the recovered gpart partition, if it does find it at all.

Good luck!


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))

In the meantime i was able to recover the partions with TestDisk but they are kind of a mess. The good news is the that large 849.5 partition with all the data is mountable and accessible. However, i’m not sure how to proceed with the installation and formatting so it doesn’t mess up again. I don’t understand where those tiny 1,2 and 6mb of unallocated space come from and that sda5 with 145mb. Sda1 and Sda2 are supposed to be empty but on the table is showing that some space is used.

http://www.stooorage.com/show/2658/11006833_gparted-snapshot.png

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 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 label type: dos
Disk identifier: 0x00000001

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048    81919999    40958976    7  HPFS/NTFS/exFAT
/dev/sda2        81920000   169768959    43924480   83  Linux
/dev/sda3       169771008   171724799      976896   82  Linux swap / Solaris
/dev/sda4       171724800  1953523711   890899456    f  W95 Ext'd (LBA)
/dev/sda5       171726848   172023807      148480   83  Linux
/dev/sda6       172036096  1953519615   890741760    7  HPFS/NTFS/exFAT


Here’s some output on my system:


# fdisk -l
##### skipping output for hard drives.  Let's get to the USB that I have plugged in
Disk /dev/sdd: 4004 MB, 4004511744 bytes, 7821312 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 label type: dos
Disk identifier: 0x57e3059e

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1   *          64     1105919      552928   83  Linux

Doesn’t that look like the same kind of recursive partition table?

The USB was created with the 12.3 live rescue iso: openSUSE-12.3-Rescue-CD-i686.iso

When I write a live image to a USB, I get exactly the same sort of recursive partitioning.

In particular, that was present on opensuse live iso up through 12.1, and perhaps 12.2. It was present on 32-bit live isos up through 31.1RC1 (if I recall correctly). The 64bit formats changed for 12.3 and later to support UEFI.

And the “isohybrid” command creates the same sort of partitioning.

On 2014-02-18 01:36, Penguin Warrior wrote:
>
> In the meantime i was able to recover the partions with ‘TestDisk’

Wow.
Count your blessings, then :slight_smile:

> (http://tinyurl.com/p479pdp) but they are kind of a mess. The good news
> is the that large 849.5 partition with all the data is mountable and
> accessible. However, i’m not sure how to proceed with the installation
> and formatting so it doesn’t mess up again. I don’t understand where
> those tiny 1,2 and 6mb of unallocated space come from and that sda5 with
> 145mb. Sda1 and Sda2 are supposed to be empty but on the table is
> showing that some space is used.

Forget those tiny spaces, they are probably adjustments.

As said, I would backup somewhere else that important data partition of
yours, and completely scratch that partition on your disk. It is
possible that when installing W7 it will destroy it all, anyway…

If you want to see what those used spaces are, well, mount the
partitions and find out.


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))

On 2014-02-18 03:16, nrickert wrote:

> Here’s some output on my system:
>
> Code:
> --------------------
>
> # fdisk -l
> ##### skipping output for hard drives. Let’s get to the USB that I have plugged in
> Disk /dev/sdd: 4004 MB, 4004511744 bytes, 7821312 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 label type: dos
> Disk identifier: 0x57e3059e
>
> Device Boot Start End Blocks Id System
> /dev/sdd1 * 64 1105919 552928 83 Linux
>
> --------------------
>
> Doesn’t that look like the same kind of recursive partition table?

Nope. You don’t have “/dev/sdd1p1” :slight_smile:

> The USB was created with the 12.3 live rescue iso:
> openSUSE-12.3-Rescue-CD-i686.iso
>
> When I write a live image to a USB, I get exactly the same sort of
> recursive partitioning.

No, that’s a different thing.

> And the “isohybrid” command creates the same sort of partitioning.

Not the same. Look, the output of his “fdisk -l” said


Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
....
Disk /dev/sda1: 137.4 GB, 137438952960 bytes, 268435455 sectors

It identified “/dev/sda1”, which is a partition, as a disk, and then
went on to find partitions inside. And there was one, which it described
as “/dev/sda1p1”. Partition one of partition one of disk a.

Go on, have a look at the live iso, you will see it is different. This
is one of mine (the rescue xfce):


> Disk /dev/sdb: 4051 MB, 4051697664 bytes, 7913472 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 label type: dos
> Disk identifier: 0xa19f8ba9
>
>    Device Boot      Start         End      Blocks   Id  System
> /dev/sdb1            4084       12275        4096   ef  EFI (FAT-12/16/32)
> /dev/sdb2   *       12276     1232895      610310   83  Linux
> /dev/sdb3         1232896     7911424     3339264+  83  Linux

Or the full 13.1 DVD:


> Disk /dev/sdb: 7820 MB, 7820083200 bytes, 15273600 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 label type: dos
> Disk identifier: 0x7e142954
>
>    Device Boot      Start         End      Blocks   Id  System
> /dev/sdb1            3764       11955        4096   ef  EFI (FAT-12/16/32)
> /dev/sdb2   *       11956     8931327     4459686   17  Hidden HPFS/NTFS


I have another for 12.3 and it looks the same.


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))

Hmm, you are right. I didn’t check that closely. However, I did have that problem with 32 bit 13.1 milestones. There’s a bug report on it.

If I use “isohybrid” I will create the same structure.

It really isn’t recursive partitioning. If you look closely at the OP, you will see that partition 1 has offset 0. The result is that the PBR (partition boot record) of partition 1 is identical to the MBR – they are the same disk space.

This comes from creating partition 1 with offset zero.

On 2014-02-18 04:06, nrickert wrote:
>
> robin_listas;2625498 Wrote:
>> Nope. You don’t have “/dev/sdd1p1” :slight_smile:
>
> Hmm, you are right. I didn’t check that closely. However, I did have
> that problem with 32 bit 13.1 milestones. There’s a bug report on it.
>
> If I use “isohybrid” I will create the same structure.

Maybe… I don’t remember.

You used isohybrid on 13.1? It breaks that ISO. We modified the
instructions on the wiki page to say not to apply isohybrid on 13.1

> It really isn’t recursive partitioning. If you look closely at the OP,
> you will see that partition 1 has offset 0. The result is that the PBR
> (partition boot record) of partition 1 is identical to the MBR – they
> are the same disk space.
>
> This comes from creating partition 1 with offset zero.

Now, that is curious…

But the second partition could be using relative sector count, to the
start of the sda1 device, instead of to the start of sda. After all, it
is considering sda1 as a disk, not a partition.

To find this out we would have to intentionally create such a setup. I
might do that on a virtual machine one day. :slight_smile:


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))