[parted-devel] [PATCH] Add autofix: Automatically "Fix" in script mode

Brian C. Lane bcl at redhat.com
Fri Dec 11 18:48:10 GMT 2020


On Tue, Nov 24, 2020 at 10:32:34AM +0100, Cristian Klein wrote:
> Use-case: VMs are booted from images that are smaller than their virtual
> disk. This means that -- almost by definition -- the secondary GPT
> header will be "misplaced", i.e., not at the end of the virtual disk.
> 
> Without this patch, parted cannot be used for custom/exotic partitioning
> when the VM boots (e.g., in cloud-init's `bootcmd`). Specifically, it
> will fail as follows:
> 
> ```
> $ sudo parted --script /dev/vda "mkpart 2 10GB -1"
> Warning: Not all of the space available to /dev/vda appears to be used,
> you can fix the GPT to use all of the space (an extra 500 blocks) or continue with the current setting?
> Error: Unable to satisfy all constraints on the partition.
> ```
> 
> This happens because, in script mode, exceptions are usually not
> resolved.
> 
> This patch adds `--autofix`. This allows exceptions to be automatically
> resolved with Fix. As a result, the following command will work:
> 
> ```
> $ sudo parted autofix --script /dev/vda "mkpart 2 10GB -1"
> ```

I like how limited this is. In the past I've been opposed to automating
responses to errors, but PED_EXCEPTION_FIX is pretty limited. I cam up
with this list of uses:

* GPT header not including full disk size
* GPT, Move the backup GPT table to the end of the disk
* Atari, fix sector count to match device size
* DVH fixes extended partition volume header (not familiar with dvh)
* MAC fix missing partition map entry
* AMIGA fix bad checksums
* AMIGA ignore free block loop (no fix code present, falls into ignore)

I'm not sure about the Amiga uses of it, but the others look just fine
to me.

I think naming it --fix would be better, since it is only allowed to be
used with --script 'auto' is implied.

It should also be documented in doc/C/parted.8, and doc/parted.texi

I think this should wait until after a 3.4 release (I'm hoping to do an
alpha build for that today or Monday) since it is a behavior change. It
looks pretty safe, but I'd rather be cautious at this point.


Any other thoughts on this patch?

Thanks,

Brian

-- 
Brian C. Lane (PST8PDT) - weldr.io - lorax - parted - pykickstart




More information about the parted-devel mailing list