GParted destroyed my partition table: "Invalid partition table on /dev/sda -- wrong signature 0."

Bug #434463 reported by Tristan Schmelcher
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
gparted (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: gparted

I used to have the following partition table:

ext3 /dev/sda1 (mounted at /)
extended
  - swap /dev/sda5
  - ext3 /dev/sda6 (mounted at /home)

The /dev/sda1 was too small for me though, so to increase it I used GParted on a Jaunty LiveCD to queue the following:

- Shrink /dev/sda6 to half size, creating space on the left.
- Move swap to the right.
- Shrink extended to fit, creating space on the left.
- Grow /dev/sda1 to fill.

GParted successfully did step 1, but at the end of step 2 it had a fatal error:

Invalid partition table on /dev/sda -- wrong signature 0.

After closing the dialog, the entire partition table is now gone -- it all shows as "unallocated space".

GParted's saved report is attached.

$ lsb_release -rd
Description: Ubuntu 9.04
Release: 9.04
$ apt-cache policy gparted
gparted:
  Installed: 0.4.3-0ubuntu1
  Candidate: 0.4.3-0ubuntu1
  Version table:
 *** 0.4.3-0ubuntu1 0
        500 http://archive.ubuntu.com jaunty/main Packages
        100 /var/lib/dpkg/status
$

Revision history for this message
Tristan Schmelcher (tschmelcher) wrote :
Revision history for this message
Jan Claeys (janc) wrote :

Is the partition table still empty after you reboot the live-cd?

Revision history for this message
Tristan Schmelcher (tschmelcher) wrote :

I haven't rebooted yet. I wanted to try and recover things first.

fdisk does show a partial partition table though--the original entries for sda1 and sda5 are there, but sda6 is missing and it prints "omitting empty partition (6)" when it starts. Perhaps that mean that the partition table is actually still there? Or perhaps fdisk just uses the OS's cache of the partition table or something?

In any event, I was thinking of writing the table back out to disk from fdisk and then using GParted to reconstruct the entry for /dev/sda6 from the sizes and offsets in the htm output.

Revision history for this message
Jan Claeys (janc) wrote :

The error log suggests that /dev/sda6 was resized, but that after that the kernel got confused and needs a reboot to interpret thing correctly?

Revision history for this message
Tristan Schmelcher (tschmelcher) wrote :

I think what that error means is just that the changes weren't going to be reflected in the /dev/sda* devices until reboot. I've seen that error before on start-up if the devices were in use, which apparently is always the case even with the LiveCD because it automatically uses the swap partition. I did "Swap Off" from within GParted before doing any of the actions, but I think maybe something made the OS automatically start using it again during GParted's execution so that it later produced that message during processing. This could be what triggered the problem in the first place, since /dev/sda5 is the swap partition and also the one where the fatal error occurred.

My interpretation of the log is that sda6 has been resized correctly on disk, but that the partition table has been corrupted somehow, hence the "Invalid partition table on /dev/sda -- wrong signature 0".

I think I am going to try to backup all the information that is still accessible with fdisk and then reboot into the LiveCD again to see if what GParted sees is any different. If not then I'll still have the saved fdisk data and I can try to reconstruct the partition table.

Revision history for this message
Tristan Schmelcher (tschmelcher) wrote :

State of the partition table after the error and before reboot, as seen by sfdisk, fdisk, and parted:

$ sudo sfdisk -l /dev/sda

Disk /dev/sda: 9729 cylinders, 255 heads, 63 sectors/track
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.

sfdisk: ERROR: sector 98542710 does not have an msdos signature
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start End #cyls #blocks Id System
/dev/sda1 * 0+ 1823- 1824- 14648437+ 83 Linux
/dev/sda2 1823+ 9729- 7906- 63502306 5 Extended
/dev/sda3 0 - 0 0 0 Empty
/dev/sda4 0 - 0 0 0 Empty
/dev/sda5 1823+ 2538- 716- 5744140 83 Linux
$ sudo fdisk -l /dev/sda
omitting empty partition (6)

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0004a071

   Device Boot Start End Blocks Id System
/dev/sda1 * 1 1824 14648437+ 83 Linux
/dev/sda2 1824 9730 63502306 5 Extended
/dev/sda5 1824 2539 5744140 83 Linux
$ sudo parted -l /dev/sda
Error: Invalid partition table on /dev/sda -- wrong signature 0.
Ignore/Cancel? Ignore
Model: ATA INTEL SSDSA2M080 (scsi)
Disk /dev/sda: 80.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
 1 512B 15.0GB 15.0GB primary ext3 boot
 2 15.0GB 80.0GB 65.0GB extended
 5 15.0GB 20.9GB 5882MB logical linux-swap

Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0
has been opened read-only.
Error: /dev/sr0: unrecognised disk label

$

Revision history for this message
Tristan Schmelcher (tschmelcher) wrote :

And the exact sizes as seen by sfdisk:

$ sudo sfdisk -d /dev/sda
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.

sfdisk: ERROR: sector 98542710 does not have an msdos signature
# partition table of /dev/sda
unit: sectors

/dev/sda1 : start= 1, size= 29296875, Id=83, bootable
/dev/sda2 : start= 29296876, size=127004612, Id= 5
/dev/sda3 : start= 0, size= 0, Id= 0
/dev/sda4 : start= 0, size= 0, Id= 0
/dev/sda5 : start= 29296877, size= 11488280, Id=83
$

Revision history for this message
Tristan Schmelcher (tschmelcher) wrote :

Okay, so I've figured everything out.

After rebooting into the LiveCD again nothing had changed, the outputs from all the commands above were identical. So I decided to use the parted(8) command with its "rescue" function to have it try and find the sda6 partition, and it did. After that, the sda6 entry was fully restored and functional and "sudo parted -l" no longer printed. "Error: Invalid partition table on /dev/sda -- wrong signature 0."

After that, I opened gparted again and continued my repartitioning where I had left off. i.e., I queued up the following:

- Move swap to the right.
- Shrink extended to fit, creating space on the left.
- Grow /dev/sda1 to fill.

And it failed in exactly the same way as my original attempt. It got the same error when trying to process sda5. I've attached that log as gparted_details.htm. After that I was in the same state as before: sda6 was gone. But I used the rescue command in parted again and got it back.

So then I decided to get creative. I opened gparted again and queue up another command to move sda5, but this time I left the "Round to cylinder" box checked, whereas before I had always unchecked it so as to avoid unused space. And with that checked, the move now worked correctly. I then did the last two steps in a second batch (also with round to cylinders on). Those are attached as gparted_details_success.htm and gparted_details_success2.htm.

So it seems that the root problem was moving a swap partition without "round to cylinders". Somehow it caused GParted to corrupt the partition table.

Revision history for this message
Tristan Schmelcher (tschmelcher) wrote :
Revision history for this message
Tristan Schmelcher (tschmelcher) wrote :
Revision history for this message
Jan Claeys (janc) wrote :

Thanks for all the testing, I'll forward this issue to the GParted developer.

I forgot to say it before, but if you ever have such issues again, it might also be useful to try the latest version of GParted (there are small live CD/USB images on the GParted site).

Changed in gparted (Ubuntu):
status: New → Confirmed
Revision history for this message
jonnieo (jonnie-o) wrote :

I was able to fix a similar problem by "sudo parted /dev/sda" and then w

Revision history for this message
Curtis Gedak (gedakc) wrote :

This problem sounds suspiciously like the following upstream bug report:
Bug #623630 - Move logical partition to right yields invalid partition table on /dev/sda -- wrong signature 0
https://bugzilla.gnome.org/show_bug.cgi?id=623630

In the upstream bug report, the Extended Boot Record was overwritten when the partition was moved and this caused the invalid partition table.

The upstream bug was fixed with GParted version 0.6.2.

Revision history for this message
Tristan Schmelcher (tschmelcher) wrote :

I agree, they are the same bug. Ubuntu should update to 0.6.2+ for Maverick and then this can be closed.

Phillip Susi (psusi)
Changed in gparted (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.