Subject: bug#18984: Enhancement request: Handling of damaged partition tables

From: "Brian C. Lane" <[email-masked]>
Date: Fri, 7 Nov 2014 14:32:05 -0800

On Fri, Nov 07, 2014 at 04:12:22PM +0100, Ulrich Windl wrote:
> (This is a re-send of the message (extracted from the mail queue) dated Fri, 07 Nov 2014 14:38:39 +0100, because that message took the wrong mailer and is stuck in the queue)
> Hi!
> 
> As the web-based bug reporting is still broken, I'm mailing instead:
> 
> I have a system that features a damaged partition table for an 1TB disk
> with 4kB sectors. While Windows 7 boot without any complaint, and
> diskpart is happy, GNU parted doesn't display the existing partitions,
> because it says there are overlapping partitions. This in turn causes
> every Linux system I tried to install to overwrite the existing
> partitions, because they are not detected by parted!
> 
> (I only have the first sector here, but when trying to print the MBR
> partition table, I get this with GNU Parted 3.2)
> 
> I wrote some Perl code to decode the partition table, and I'm presenting
> it here for a test case for future enhancements. I suggest the
> following:
> 
> 1) Instead of saying "Can't have a partition outside the disk!" say
> _which_ partition you think is outside the disk, and say _why_ you think
> so.

I agree. These are all a product of only having the first few sectors.
For testing you could copy them to the start of a large sparse disk.

fallocate -l 10G test.img
dd if=disk.img of=test.img conv=notrunc 

> 
> 2) Despite of the message "Invalid partition table
> on /home/wiu09524/Projekte/sect0.0 -- wrong signature 0." the MBR
> signature is 0x55, 0xaa as expected

I'm not sure what's going on here, maybe fallout from the other errors.

> 
> 3) Instead of saying "Can't have overlapping partitions." say _which_
> partitions you think overlap with which other partitions, and
> perferrably give precise data for the overlap. Parted should not just
> help secretaries, but technicals also ;-)

I agree.

> 
> 4) "Can't have a primary partition inside an extended partition." may be
> true, but see 3) for proposed improvements.
> 
> It would be great if parted could not only complain, but also suggest
> how to fix the problems detected, just like fsck does for years.

I think complaining is fine, but I don't think parted should try to fix,
or suggest how to fix these problems. The chances for data loss are too
great. We do 'fix' GPT, but that is because we have a backup with
checksums that we can depend on.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)