bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [parted-devel] msdos logical partition constraints bug in parted


From: Milko Krachounov
Subject: Re: [parted-devel] msdos logical partition constraints bug in parted
Date: Fri, 11 Feb 2011 22:21:18 +0200
User-agent: KMail/1.13.5 (Linux/2.6.35-trunk-amd64; KDE/4.5.3; x86_64; ; )

On Friday 11 February 2011, 20:58:33 Phillip Susi wrote:
> On 2/6/2011 10:25 AM, Milko Krachounov wrote:
> > I created the following partition table with parted (the snipped is *not*
> > actual fdisk output, I edited it by hand)
> > 
> > {{{
> > 
> >    Device Boot      Start         End      Blocks   Id  System
> > 
> > /dev/sdf1            2048      196607       97280   83  Linux
> > /dev/sdf4          196608    48859135    24331264   83  Linux
> > /dev/sdf3        48859136    60563455     5852160   83  Linux
> > /dev/sdf2        60565502  1953523711   946479105    f  W95 Ext'd (LBA)
> > /dev/sdf6        60565504    80101375     9767936   83  Linux
> > /dev/sdf5        80101376  1953523711   936711168   83  Linux
> > }}}
> 
> How exactly did you create this, because it appears to be invalid.
> There should be a 2 sector gap between the end of sdf6 and the start of
> sdf5.  My guess is that the EBR at sector 60565502 contains two type 83
> entries for sdf5 and sdf6 instead of one, and another extended entry as
> it should.


Here's exact step to reproduce my partition table. I have been hunting for 
several weeks as to why parted and parted-based utils refuse to open the 
resulting table, so the original one was "edited" over my current one, and
I also had changed the partition types during the period. Now the output is
without edits (except for removing the full paths and extra irrelevant 
messages). I separate everything in three sections:

1. The creation of the badly ordered partition table
2. A (failed) attempt to fix it with GNU fdisk (parted-based) 
3. A successful attempt to fix it with util-linux fdisk, and the subsequent 
refusal of parted and parted-based utils to open it

I also included the creation commands at the bottom of the email to ease 
anyone who wants to copy/paste them.

====== CREATION ========

$ dd if=/dev/zero of=test_disk seek=1953525167 count=1 bs=512
$ /sbin/parted --align=opt --script ./test_disk mklabel msdos
$ /sbin/parted --align=opt --script ./test_disk mkpart primary 1M 101M 
$ /sbin/parted --align=opt --script ./test_disk mkpart extended 100M 1000204M
$ /sbin/parted --align=opt --script ./test_disk mkpart logical 41012M 1000204M
$ /sbin/parted --align=opt --script ./test_disk mkpart logical 31010M 41012M
$ /sbin/parted --align=min --script ./test_disk resize 2 31010M 1000204M 
[...not relevant warning that resizing filesystems in parted is not robust...]
$ /sbin/parted --align=opt --script ./test_disk mkpart primary 25016M 31009M
$ /sbin/parted --align=opt --script ./test_disk mkpart primary 101M 25016M
$ /sbin/fdisk -lu ./test_disk | grep -v 'Warning' | sed -r s,.+/test,test,
[...]
test_disk1            2048      196607       98032   83  Linux
test_disk4          196608    48859135    24331200   83  Linux
test_disk3        48859136    60563455     5852096   83  Linux
test_disk2        60565502  1953523711   946479104    f  Extended LBA
test_disk6        60565504    80101375     9767872   83  Linux
test_disk5        80101376  1953523711   936711104   83  Linux

====== ORDER FIX (libparted) ========

$ /sbin/fdisk -u ./test_disk
GNU Fdisk 1.2.4
Copyright (C) 1998 - 2006 Free Software Foundation, Inc.
This program is free software, covered by the GNU General Public License.
[...]
Command (m for help): x                                                   
Expert command (m for help): m                                            
[...]
   f   fix partition order
[...]
Expert command (m for help): f                                            
Warning: Fixing partition order is experimental. Use at your own risk.    
   i   Ignore                                                             
   c   Cancel
i
Error: Unable to satisfy all constraints on the partition.                
Expert command (m for help): r                                            
Command (m for help): p                                                   
[...]
[...]/test_disk1            2048      196607       98032   83  Linux
[...]/test_disk2          196608    48859135    24331200   83  Linux
[...]/test_disk3        48859136    60563455     5852096   83  Linux
[...]/test_disk4        60565502  1953523711   946479104    f  Extended LBA
[...]/test_disk5        60565504    80101375     9767872   83  Linux
Command (m for help): q

====== ORDER FIX (util-linux) ========

$ /sbin/fdisk.distrib -v
fdisk (util-linux-ng 2.17.2)
$ /sbin/fdisk.distrib -u -S 32 -H 4 -C 15261915 ./test_disk

Command (m for help): p
[...]
      Device Boot      Start         End      Blocks   Id  System
./test_disk1            2048      196607       97280   83  Linux
./test_disk2        60565502  1953523711   946479105    f  W95 Ext'd (LBA)
./test_disk3        48859136    60563455     5852160   83  Linux
./test_disk4          196608    48859135    24331264   83  Linux
./test_disk5        80101376  1953523711   936711168   83  Linux
./test_disk6        60565504    80101375     9767936   83  Linux

Partition table entries are not in disk order

Command (m for help): x

Expert command (m for help): f
Done.

Expert command (m for help): r

Command (m for help): p
[...]
      Device Boot      Start         End      Blocks   Id  System
./test_disk1            2048      196607       97280   83  Linux
./test_disk2          196608    48859135    24331264   83  Linux
./test_disk3        48859136    60563455     5852160   83  Linux
./test_disk4        60565502  1953523711   946479105    f  W95 Ext'd (LBA)
./test_disk5        60565504    80101375     9767936   83  Linux
./test_disk6        80101376  1953523711   936711168   83  Linux

Command (m for help): w
The partition table has been altered!

Syncing disks.
$ /sbin/parted --script ./test_disk print
Error: Unable to satisfy all constraints on the partition.
$ /sbin/fdisk ./test_disk 
GNU Fdisk 1.2.4
[...]
Error: Unable to satisfy all constraints on the partition.

> 
> > Then used to fix the partition order and types with util-linux's fdisk,
> > which not only created a real overlap, it also made the partition table
> > unopenable by parted and applications using libparted. Got the following
> > result (this snipped *is* actual output).
> > 
> > {{{
> > 
> >    Device Boot      Start         End      Blocks   Id  System
> > 
> > /dev/sdf1            2048      196607       97280   fd  Linux raid
> > autodetect /dev/sdf2          196608    48859135    24331264   fd  Linux
> > raid autodetect /dev/sdf3        48859136    60563455     5852160   fd 
> > Linux raid autodetect /dev/sdf4        60565502  1953523711   946479105 
> >   f  W95 Ext'd (LBA) /dev/sdf5        60565504    80101375     9767936  
> > fd  Linux raid autodetect /dev/sdf6        80101376  1953523711  
> > 936711168   83  Linux
> > }}}
> 
> What real overlap did it create?  I don't see one here, though I do
> wonder why the tags changed from 83 to fd.  It also still looks like
> partitions 5 and 6 are both stored in the first EBR instead of being
> chained.

The overlap that parted complains about when refusing to open the refusing 
disk that's been referred to by the comments of the 
_log_meta_overlap_constraint  function. I don't know if there's a real overlap 
between the metadata and the partitions, but libparted doesn't like it. 

What I'm suggesting that parted reads the partition table with more strict 
constraints so that such situations are avoided. Or are read with less strict 
constraints (with the appropriate warnings) so that the table can be edited 
and fixed. On a second thought my original suggestion as to how to do this 
doesn't sound like a great idea, and I was wrong about the actual walk over 
the partitions.

Commands to reproduce the disordered partition table:

dd if=/dev/zero of=test_disk seek=1953525167 count=1 bs=512
/sbin/parted --align=opt --script ./test_disk mklabel msdos
/sbin/parted --align=opt --script ./test_disk mkpart primary 1M 101M 
/sbin/parted --align=opt --script ./test_disk mkpart extended 100M 1000204M
/sbin/parted --align=opt --script ./test_disk mkpart logical 41012M 1000204M
/sbin/parted --align=opt --script ./test_disk mkpart logical 31010M 41012M
/sbin/parted --align=min --script ./test_disk resize 2 31010M 1000204M 
/sbin/parted --align=opt --script ./test_disk mkpart primary 25016M 31009M
/sbin/parted --align=opt --script ./test_disk mkpart primary 101M 25016M

To fix the partition order with util-linux fdisk:

/sbin/fdisk -u -S 32 -H 4 -C 15261915 ./test_disk
x
f
r
w

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]