[parted-devel] "Error: Can't have a partition outside the disk!"

Richard W.M. Jones rjones at redhat.com
Wed Sep 22 11:04:38 UTC 2010


On Wed, Sep 15, 2010 at 05:47:23PM +0200, Jim Meyering wrote:
> Richard W.M. Jones wrote:
> > If you take a virtual disk and truncate it, then likely some
> > partitions in the partition table will be off the end of the disk.
> >
> > However parted refuses to start up in this case.  It says:
> >
> >   Error: Can't have a partition outside the disk!
> >
> > even if you are trying to do something sensible such as deleting a
> > partition which is outside the disk.
> >
> > I can't really see a "good" way to solve this, since it happens in the
> > depths of the constraints/geometry code.  The attached patch just
> > deletes the error check, on the basis that parted should confine
> > itself to partition tables and not worry about the size of the disk.
> > Discuss ...
> 
> Hi Rich,
> 
> What is your use case?  It seems rather unusual
> to want to do something with existing partitions
> once you have shrunk the underlying device.
> IMHO, that is not enough of a reason to remove
> the offending check altogether.

We want to shrink the disk, then recreate the partition table, but at
the same time preserve the boot sector and boot loader.  To do this we
copy the blocks at the start of the disk (up to just before the first
partition), then attach to this disk and remove the existing
partitions.  The parted program fails at this point.

This is combined with another bug in parted where 'parted mklabel'
completely overwrites the first sector, instead of just updating the
(MBR) partition table.  The alternative approach would be to use
'parted mklabel' to write a new partition table, but since this
destroys the bootloader, we cannot use this method either.

So there is no way for us, using the 'parted' program, to do what we
want.

> Are you using a GPT table?

We could be given either sort of disk, we have no control over what we
are given.

> If so, would it be enough to have an option
> or separate tool that could adjust things
> for the new disk size and add the backup header
> at the end of the disk?

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://et.redhat.com/~rjones/libguestfs/
See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html



More information about the parted-devel mailing list