GNU bug report logs - #18984
Enhancement request: Handling of damaged partition tables

Previous Next

Package: parted;

Reported by: "Ulrich Windl" <Ulrich.Windl <at> rz.uni-regensburg.de>

Date: Fri, 7 Nov 2014 15:13:02 UTC

Severity: wishlist

To reply to this bug, email your comments to 18984 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-parted <at> gnu.org:
bug#18984; Package parted. (Fri, 07 Nov 2014 15:13:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Ulrich Windl" <Ulrich.Windl <at> rz.uni-regensburg.de>:
New bug report received and forwarded. Copy sent to bug-parted <at> gnu.org. (Fri, 07 Nov 2014 15:13:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Ulrich Windl" <Ulrich.Windl <at> rz.uni-regensburg.de>
To: <bug-parted <at> gnu.org>
Subject: Enhancement request: Handling of damaged partition tables
Date: Fri, 07 Nov 2014 16:12:22 +0100
(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)

---
/tmp/parted-3.2/parted/parted sect0.0
WARNING: You are not superuser.  Watch out for permissions.
GNU Parted 3.2
Using /home/user/Projekte/sect0.0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)
print
Error: Can't have a partition outside the disk!
Ignore/Cancel?
i
Error: Can't have a partition outside the disk!
Ignore/Cancel?
i
Error: Can't have a partition outside the disk!
Ignore/Cancel?
i
Error: Can't have a partition outside the disk!
Ignore/Cancel?
i
Error: end of file while reading /home/user/Projekte/sect0.0
Retry/Ignore/Cancel?
i
Error: Invalid partition table on /home/user/Projekte/sect0.0 -- wrong
signature 0.
Ignore/Cancel?
i
Error: Can't have overlapping partitions.
Ignore/Cancel?
i
Error: Can't have a primary partition inside an extended partition.
Ignore/Cancel?
i
Error: Can't have a partition outside the disk!
Ignore/Cancel?
i
Error: Can't have a partition outside the disk!
Ignore/Cancel?
i
Error: Can't have a partition outside the disk!
Ignore/Cancel?
i
Model:  (file)
Disk /home/user/Projekte/sect0.0: 4096B
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:=20

Number  Start   End     Size   Type      File system  Flags
 1      1049kB  103GB   103GB  primary
 2      103GB   318GB   215GB  primary
 3      318GB   1000GB  682GB  extended               lba
 4      855GB   962GB   107GB  primary                boot

(parted)
version

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.

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

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 ;-)

4) "Can't have a primary partition inside an extended partition." may be
true, but see 3) for proposed improvements.

So here comes my own decoding of the MBR (cant' decode extended
partitions, because I only have an image of the first 4kB sector here):

First the four partition table entries as byte dump (for the gurus):
partition #1: 80 fe ff ff 07 fe ff ff 00 58 80 63 00 38 80 0c
partition #2: 00 7b cb ff 0f fe ff ff 00 48 00 25 00 b8 6f 4f
partition #3: 00 fe ff ff 07 fe ff ff 00 48 00 0c 00 00 00 19
partition #4: 00 20 21 00 07 fe ff ff 00 08 00 00 00 40 00 0c

Next the table entries decoded (partition type and active flag in hex,
then C/H/S of start, C/H/S of end, LBA of start, LBA of end):

partition #1:  7 80 1023/254/63 1023/254/63 1669355520  209729536
partition #2:  f 00 1023/123/11 1023/254/63  620775424 1332721664
partition #3:  7 00 1023/254/63 1023/254/63  201345024  419430400
partition #4:  7 00    0/ 32/33 1023/254/63       2048  201342976

Finally everything converted to LBAs and then to GB (1024^2 kB):
partition #1:    7.875    7.875  796.011  100.007 (   0.000 / -696.004)
partition #2:    7.871    7.875  296.009  635.491 (   0.004 /  339.482)
partition #3:    7.875    7.875   96.009  200.000 (   0.000 /  103.991)
partition #4:    0.001    7.875    0.001   96.008 (   7.874 /   96.007)

You see that partition #1 (the last entry in the table) features a
negative size!

Here is what Windows 7 diskpart (current updates installed) says about
the partitions (partition number, offset, size):
0, 296 GB, 635 GB
1, 1024 GB, 96 GB
2, 96 GB, 200 GB
3, 796 GB, 100GB
4, 296GB, 296GB * (Boot Partition)
5, 596GB, 200GB
6, 896GB, 35GB

(I have no idea how Microsoft numbers the partitions)

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.

Regards,
Ulrich Windl






Information forwarded to bug-parted <at> gnu.org:
bug#18984; Package parted. (Fri, 07 Nov 2014 22:33:02 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Brian C. Lane" <bcl <at> redhat.com>
To: bug-parted <at> gnu.org
Subject: Re: bug#18984: Enhancement request: Handling of damaged partition
 tables
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)




Information forwarded to bug-parted <at> gnu.org:
bug#18984; Package parted. (Mon, 10 Nov 2014 18:17:02 GMT) Full text and rfc822 format available.

Message #11 received at 18984 <at> debbugs.gnu.org (full text, mbox):

From: Phillip Susi <psusi <at> ubuntu.com>
To: Ulrich Windl <Ulrich.Windl <at> rz.uni-regensburg.de>, 
 18984 <at> debbugs.gnu.org
Subject: Re: bug#18984: Enhancement request: Handling of damaged partition
 tables
Date: Mon, 10 Nov 2014 13:15:06 -0500
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/7/2014 10:12 AM, Ulrich Windl wrote:
> 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!

<snip>

> Model:  (file) Disk /home/user/Projekte/sect0.0: 4096B Sector size
> (logical/physical): 512B/512B Partition Table: msdos Disk
> Flags:=20
> 
> Number  Start   End     Size   Type      File system  Flags 1
> 1049kB  103GB   103GB  primary 2      103GB   318GB   215GB
> primary 3      318GB   1000GB  682GB  extended               lba 4
> 855GB   962GB   107GB  primary                boot
> 
> (parted) version

That looks like it is detecting and displaying the partitions to me.

> 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 suppose that could be nice, though when you print the table and have
a look for yourself it isn't hard to figure out.  In your case your
"disk" is only one sector long so everything is outside of that.

> 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

It is talking about the extended partition table which it sees as all
zeroes since you don't have it in the image file, the read failed, and
you chose to ignore that failure.

> 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 ;-)

Same as above: might be nice but it's pretty easy to figure out by
looking at the output of print.

> 4) "Can't have a primary partition inside an extended partition."
> may be true, but see 3) for proposed improvements.
> 
> So here comes my own decoding of the MBR (cant' decode extended 
> partitions, because I only have an image of the first 4kB sector
> here):
> 
> First the four partition table entries as byte dump (for the
> gurus): partition #1: 80 fe ff ff 07 fe ff ff 00 58 80 63 00 38 80
> 0c partition #2: 00 7b cb ff 0f fe ff ff 00 48 00 25 00 b8 6f 4f 
> partition #3: 00 fe ff ff 07 fe ff ff 00 48 00 0c 00 00 00 19 
> partition #4: 00 20 21 00 07 fe ff ff 00 08 00 00 00 40 00 0c
> 
> Next the table entries decoded (partition type and active flag in
> hex, then C/H/S of start, C/H/S of end, LBA of start, LBA of end):
> 
> partition #1:  7 80 1023/254/63 1023/254/63 1669355520  209729536 
> partition #2:  f 00 1023/123/11 1023/254/63  620775424 1332721664 
> partition #3:  7 00 1023/254/63 1023/254/63  201345024  419430400 
> partition #4:  7 00    0/ 32/33 1023/254/63       2048  201342976
> 
> Finally everything converted to LBAs and then to GB (1024^2 kB): 
> partition #1:    7.875    7.875  796.011  100.007 (   0.000 /
> -696.004) partition #2:    7.871    7.875  296.009  635.491 (
> 0.004 /  339.482) partition #3:    7.875    7.875   96.009  200.000
> (   0.000 /  103.991) partition #4:    0.001    7.875    0.001
> 96.008 (   7.874 /   96.007)
> 
> You see that partition #1 (the last entry in the table) features a 
> negative size!

There is no such thing as a negative size since the table lists the
start and length ( not end ) as unsigned dwords.

> 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.

The fix should be obvious: delete one of the overlapping partitions,
or shrink the first one.  How to do that safely is too involved to
suggest in a short error message.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)

iQEcBAEBAgAGBQJUYQCpAAoJEI5FoCIzSKrwmy0H/0qwo3rN6gNofBwyvDaHY9bh
r9J/PK3QJQaKW+yNn9R4julxeSDau84Yzoy4VtRpfaHeF5pQVZTTYv8BrFen16Cy
fgIPWaUMmI9xHTam5n0BRXp6HpEp0FObwsXskbs9fpjzVk64NTy0SBG/UzS4Oazu
1Y1fOdQGxmouenj4gRh5t6cQ+WbGHhlo1bjrzZRhTdsVMKgpDihUdUoMZbCd4MI2
+3DKJrs5mrFvwIkn5/lxPWGnfCycQPP5A6HyBBLCCaTFzqJ5qya/Fbb8z0JlCw3b
q1KZLrvT7kvPjJ7nXbZ/gKmFt8134ql9X4BDw3oaTpjQCj7hPWcUmu2NqDn79uE=
=Hu6R
-----END PGP SIGNATURE-----




Information forwarded to bug-parted <at> gnu.org:
bug#18984; Package parted. (Tue, 11 Nov 2014 07:55:01 GMT) Full text and rfc822 format available.

Message #14 received at 18984 <at> debbugs.gnu.org (full text, mbox):

From: "Ulrich Windl" <Ulrich.Windl <at> rz.uni-regensburg.de>
To: <18984 <at> debbugs.gnu.org>,<psusi <at> ubuntu.com>
Subject: Antw: Re: bug#18984: Enhancement request: Handling of damaged
 partition tables
Date: Tue, 11 Nov 2014 08:54:36 +0100
>>> Phillip Susi <psusi <at> ubuntu.com> schrieb am 10.11.2014 um 19:15 in Nachricht
<546100AA.1050803 <at> ubuntu.com>:
[...]
>> 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 suppose that could be nice, though when you print the table and have
> a look for yourself it isn't hard to figure out.  In your case your
> "disk" is only one sector long so everything is outside of that.

Actually a computer can compare and intersect numeric intervals much faster than I can. Of course up to now we all can do what computers can do, but are we to relieve the computers, or is it the other way 'round?

> 
>> 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
> 
> It is talking about the extended partition table which it sees as all
> zeroes since you don't have it in the image file, the read failed, and
> you chose to ignore that failure.

That's not obvious from the message. What about "Invalid partition table at sector ### of <device> -- wrong signature..."?

> 
>> 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 ;-)
> 
> Same as above: might be nice but it's pretty easy to figure out by
> looking at the output of print.

See above, too.

> 
[...]
>> Finally everything converted to LBAs and then to GB (1024^2 kB): 
>> partition #1:    7.875    7.875  796.011  100.007 (   0.000 /
>> -696.004) partition #2:    7.871    7.875  296.009  635.491 (
>> 0.004 /  339.482) partition #3:    7.875    7.875   96.009  200.000
>> (   0.000 /  103.991) partition #4:    0.001    7.875    0.001
>> 96.008 (   7.874 /   96.007)
>> 
>> You see that partition #1 (the last entry in the table) features a 
>> negative size!
> 
> There is no such thing as a negative size since the table lists the
> start and length ( not end ) as unsigned dwords.

OK, my fault (I remembered it incorrectly)!

> 
>> 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.
> 
> The fix should be obvious: delete one of the overlapping partitions,
> or shrink the first one.  How to do that safely is too involved to
> suggest in a short error message.






Information forwarded to bug-parted <at> gnu.org:
bug#18984; Package parted. (Tue, 11 Nov 2014 07:58:02 GMT) Full text and rfc822 format available.

Message #17 received at 18984 <at> debbugs.gnu.org (full text, mbox):

From: "Ulrich Windl" <Ulrich.Windl <at> rz.uni-regensburg.de>
To: <18984 <at> debbugs.gnu.org>,<de.techno <at> gmail.com>
Subject: Antw: Re: bug#18984: Enhancement request: Handling of damaged
 partition tables
Date: Tue, 11 Nov 2014 08:57:38 +0100
[Message part 1 (text/plain, inline)]
>>> dE <de.techno <at> gmail.com> schrieb am 08.11.2014 um 06:25 in Nachricht
<545DA93A.4090503 <at> gmail.com>:
[...]
> Can you provide a screenshot of Windows disk management utility?

You'll have to cope with the German Versions.


[Partitions.jpg (image/jpeg, attachment)]
[Partitions2.jpg (image/jpeg, attachment)]

Information forwarded to bug-parted <at> gnu.org:
bug#18984; Package parted. (Tue, 11 Nov 2014 14:19:01 GMT) Full text and rfc822 format available.

Message #20 received at 18984 <at> debbugs.gnu.org (full text, mbox):

From: Phillip Susi <psusi <at> ubuntu.com>
To: Ulrich Windl <Ulrich.Windl <at> rz.uni-regensburg.de>, 
 18984 <at> debbugs.gnu.org, de.techno <at> gmail.com
Subject: Re: bug#18984: Antw: Re: bug#18984: Enhancement request: Handling
 of damaged partition tables
Date: Tue, 11 Nov 2014 09:17:20 -0500
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/11/2014 2:57 AM, Ulrich Windl wrote:
>>>> dE <de.techno <at> gmail.com> schrieb am 08.11.2014 um 06:25 in
>>>> Nachricht
> <545DA93A.4090503 <at> gmail.com>: [...]
>> Can you provide a screenshot of Windows disk management utility?
> 
> You'll have to cope with the German Versions.

I've known for some time that Windows is stupid and doesn't care about
overlapping partitions.  What I still can't figure out is how people
sometimes manage to create them.  Have you ever used partition magic
on this disk?  What other partitioning tools have you used?  Could it
involve converting the disk to "dynamic disk" ( ldm ) and then back?


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)

iQEcBAEBAgAGBQJUYhpwAAoJEI5FoCIzSKrwFLkH+QFOKrIRSAk8gLxC86Rc3B0C
ii8XVMIHStqW2K8G7365gYzBxYRAycyJUHYN9g/6xJMbDglKukYhTl5r+0lQ0cvy
COVPv5oAA0041ENFTLkT+ARS2PVwgheaf89CBrWBFmSfpF6Fc9W4nAWu/+62cfZb
hd6RrmQSH0vWsfNDSK/qv7kkylbNaPHiyBhOgYs3YIujpSwHniSAI8H7pihKM9bN
Sv3vsWNN36OmPGD5k9l6q8Yc9zs3jf4C6iypc54SuorlJlypr0oRopZS7/sogRMv
GlANXnTXeSD9WdKlCezBq6ZJNSKYN4KGkYDfvjNoXf/bBJ5GzILCfZcBrbdE8yc=
=iwzT
-----END PGP SIGNATURE-----




Information forwarded to bug-parted <at> gnu.org:
bug#18984; Package parted. (Tue, 11 Nov 2014 19:33:02 GMT) Full text and rfc822 format available.

Message #23 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Rod Smith <rodsmith <at> rodsbooks.com>
To: bug-parted <at> gnu.org
Subject: bug#18984: Antw: Re: bug#18984: Enhancement request: Handling,	of
 damaged partition tables
Date: Tue, 11 Nov 2014 14:32:29 -0500
On 11/11/2014 12:01 PM, psusu <at> ubuntu.com wrote:
>
> I've known for some time that Windows is stupid and doesn't care about
> overlapping partitions.  What I still can't figure out is how people
> sometimes manage to create them.  Have you ever used partition magic
> on this disk?  What other partitioning tools have you used?  Could it
> involve converting the disk to "dynamic disk" ( ldm ) and then back?

Some versions of Microsoft's partitioning tools can create primary 
partitions inside of logical partitions. I don't recall the precise 
circumstances offhand, but from what I do recall, if you start with a 
disk that has fewer than three primary partitions and some free space 
and feed it to the Windows XP installer, you can end up with a disk in 
which the extended partition is resized to cover the primary partition 
that XP creates for itself. I don't know if this bug exists in later 
versions of Windows. There were quite a few reports of this problem in 
the Ubuntu forums a few years ago.

Some versions of TestDisk will also create an extended partition that 
extends beyond the end of the disk. (This happens with older versions 
that are fed partitions that are not cylinder-aligned, with the final 
partition ending inside what TestDisk considers the final partial 
"cylinder.") I haven't checked lately, but I hope this problem has been 
fixed by now. I saw lots of problem reports about this in forums a few 
years ago.

-- 
Rod Smith
rodsmith <at> rodsbooks.com
http://www.rodsbooks.com




This bug report was last modified 10 years and 222 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.