feat(cgpt): Add resize command.
This implements CoreOS's automatic filesystem resizing as part of cgpt,
replacing the current shell script. Admittedly this code is more
complicated than the old shell script but it should be more robust and
suitable for use in the bootengine initramfs. Improvements include:
- Update partition table entry in place instead of the delete/add
required by gptfdisk. This hopefully reduces the risk of bugs
making larger changes to the partition table than expected such as
when gptfdisk used a different alignment for the new partition than
the old one did.
- Likewise use the partition resize ioctl so the kernel also treats
the change as an in-place update. Hopefully this will be the end of
the magic vanishing partition trick we have been seeing in EC2.
- Detect partition by searching for the new `coreos-resize` type
instead of the label `STATE` by default. This should be more robust
in the long term, preventing us from resizing user created
partitions for use with PXE booting or similar.
- On the flip size resizing by label is also supported, as is any
other identifier supported by `blkid`. For example to maintain
current behavior: `cgpt resize LABEL=STATE`
- Whatever identifier is used it is strictly required to be unique.
The resize is aborted if multiple devices are matched.
- Do not make any changes to disk if anything unexpected is found, up
to and including the resize partition ioctl failing. This particular
behavior may need to be revisited if it turns out something needs
the on-disk partition table to be written before the kernel changes.
- No dependencies on tools other than e2fsck and e2resize which makes
this tool easier to use before any real filesystems are mounted.
8 files changed