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

Jim Meyering jim at meyering.net
Wed Sep 22 13:17:03 UTC 2010


Richard W.M. Jones wrote:
> 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.

Hi Rich,

If you first remove all partitions (possibly exempting any
GRUB_BIOS partition), or at least the partitions that would be
impacted by the planned shrinkage, you will have no problem.
Can you do that?

That worked for me in a contrived example.



More information about the parted-devel mailing list