Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate disk image building to systemd-repart
Let's switch to systemd-repart to build disk images. systemd-repart allows building disk images declaratively. repart will assemble a disk image according to a set of partition definition files, which it will search for in a set of predefined locations or in the locations provided via the --definitions option. Partition definition files are defined in the usual systemd ini style and define a single partition each. Many aspects of the partition can be configured, including its size, type, and how it should be populated. Of note should be the CopyFiles= setting that allows providing a set of files/directories from which the partition should be populated. The CopyFiles= setting takes a list of path pairs, where the first path in a pair defines the source location, and the second path the destination location in the partition. If combined with repart's --root or --image options, the source path is resolved relative to the given root directory. Along with switching to systemd-repart, we also rework how we build images. Previously, we first provisioned the disk image with all its partitions, then mounted the disk image and finally populated it with contents. Now, we provision to a regular directory on the host filesystem first, followed by creating the disk image with systemd-repart. The partition definition files can be supplied via the --repart-directory option or in the mkosi.repart/ directory. If not provided, a default configuration consisting of an automatically sized root partition and an ESP partition of 256M is used. repart's --root switch is used so that the partition definition files don't need to encode the full path to the root directory of the image we're building. For example, to copy the root directory to a root partition, it's sufficient to specify "CopyFiles=/:/" in the definition file. If we're building non-bootable images, any ESP partition definitions are excluded. To allow building UKIs with an embedded roothash cmdline parameter, we run repart twice, first to populate all partitions except the ESP/XBOOTLDR partitions, and again to populate the ESP/XBOOTLDR partitions including any UKIs with embedded roothash cmdline parameter (which we determined when running repart the first time). Because we don't know up-front anymore where the ESP partition will be mounted, all boot loader files are installed to /boot. So to populate an ESP partition, you'd use "CopyFiles=/boot:/" in the partition definition file of the ESP partition. Also, since we don't know up-front anymore which filesystem we'll be building for, we stop installing filesystem related packages by default. Users will be required to add the necessary filesystem packages themselves. Similarly, we also stop installing cryptsetup and device-mapper by default since we don't know upfront anymore whether partitions will be verity protected or encrypted. By switching to systemd-repart, we also set ourselves up for building images without needing root privileges or loop devices. systemd-repart is fully capable (from v253 onwards) of building disk images without needing root privileges or loop devices. After we switch to systemd-repart, we'll only need root privileges to be able to run systemd-nspawn (which should not be necessary in the future anymore). This PR also removes all the option related to disk image building that can now be specified in repart definition files instead. This includes: - Format=gpt_xxx options are replaced with a single "disk" options. Filesystem can now be specified with repart's Format= option - Format=plain_squashfs (Can be reproduced by a single repart squashfs root partition combined with SplitArtifacts=yes) - Verity= (Replaced by repart's Verity= options) - Encrypt= (Replaced by repart's Encrypt= option) - RootSize=, HomeSize=, VarSize=, TmpSize=, ESPSize=, SwapSize=, SrvSize= (Replaced by repart's size options) - UsrOnly= (replaced with `CopyFiles=/:/usr` in a usr partition definition) - OutputSplitRoot=, OutputSplitVerity=, (Replaced by repart's SplitName= option) - OutputSplitKernel= (UKI is now always written to its own output file) - GPTFirstLBA (Removed, no equivalent in repart) - ReadOnly= (Replaced by repart's ReadOnly= option per partition) - Minimize= (Replaced by repart's Minimize= option per partition) - CompressFs= (No equivalent in repart, can be replicated by replacing mkfs.<fs> in $PATH with a script that adds the necessary command line option) - MkSquashfs= (Can be replaced with a script in $PATH that invokes the correct binary) We also remove the WithoutUnifiedKernelImages= switch as building unified kernel images is trivial and fast these days.
- Loading branch information