Installer: Disk Partitioning
For installing Ubuntu machines we use the Minimal netboot installer which is based on the Debian installer technology. This allows the preseeding of configuration options so that the install can be completed in a fully automated fashion without any user interaction. We have had LCFG support for this installer for a while now which allows us to control the whole process using LCFG component resources but we’ve been lacking support for configuring the disk partition layout which is created. Although not essential for the development phase of the project this is a requisite for our DICE platform where we want a separate partition for the AFS cache and preferably encrypted swap and
The Debian installer provides a suite of disk partitioning tools, named partman, which provide an impressive range of possibilities – including LVM, software RAID and disk encryption – along with all the standard partitioning, formatting and mount support that are needed. By default the installer supports 3 disk layouts:
- Single partition
Along with those standard recipes there is support for your own custom recipe which allows much more precise control of what is created. This month I’ve been working on a translator which can take the LCFG fstab component resources and generate a custom recipe for the target machine. As with others parts of the install configuration it is all generated by a Perl CGI script using the Template Toolkit. The disk configuration is mainly controlled through the lcfg_disks.seed.tt template with generation of a custom recipe done when the
install.disk_layout resource is set to
lcfg. The custom recipe is created using the custom_recipe.tt template which is part of the lcfg-install-preseed package. Alternatively the
install.disk_layout resource may be set to one of the standard recipe names.
In an LCFG profile the default layout is similar in style to atomic, the
LCFG_DISK_LAYOUT_MULTI macro can be defined to get something like multi. Both layouts support adding an additional local disk (e.g.
/disk/scratch) in the usual way.
Notes on the LCFG custom recipe support:
- Partition Sizes
- Currently I am still trying to improve my understanding of how the disk size algorithm works. It takes 3 numbers for each partition – minimum size, maximum size and a priority – and works out the "best" layout. Currently with EL7 we just specify a single required size and expect to get what we ask for but that’s seemingly not possible. Similarly to what we do in EL7 (usually for a local scratch disk), the Debian installer can support a free partition which uses all remaining disk space but testing suggests that this is not currently working as expected, I will look into that fairly soon.
- Multiple Disks
- The Debian installer supports partitioning multiple disks. Currently with LCFG a custom recipe will only be generated for the first disk specified in the
fstab.disksresource. We plan to add support but this is not a high priority so extra disks will have to be manually partitioned and formatted after install.
- LVM is enabled by default, disabling it is not currently supported and has not been tested. Although probably not required,. a
/bootpartition is created outside of LVM to guarantee that the Linux kernel and initrd files are accessible.
- Software RAID
- Although supported by the Debian installer we do not plan to support software RAID in LCFG.
- Disk Encryption
- The Debian installer clearly supports password-based full-disk encryption but that option has not been tested, there are currently no plans to add support for it into LCFG. We intend to add support for encrypting individual partitions (e.g.
/tmpand swap) with random keys to match what we have in EL7. Due to poor documentation it is not clear if that is supported in partman or if we will have to add a custom shell script as a late command.
- This is enabled by default, we do not expect to need support for MBR
- UEFI / Legacy boot
- For Focal we default to configuring machines to boot using UEFI but legacy is still supported by specifying the
USE_LEGACY_BOOTmacro at the top of the LCFG profile. For UEFI booting an extra
/boot/efipartition is created, it’s formatted as vfat and is 0.5GB in size.
- Preserving partitions
- The Debian installer does support preserving partitions but it is not currently supported in the LCFG custom recipe. In particular it is used for multi-boot machines where an EFI partition already exists and must be retained. We plan to add support but it’s not a high priority, given we’re moving over to LVM it’s unlikely to make much sense at this point of the lifecycle of machines anyway.
- Mount by UUID
- In EL7 we use UUIDs in the
/etc/fstabfile to avoid issues with disks being relabelled (either because new disks are added or because the kernel mixes them up). This is supported by the Debian installer but not currently enabled. It looks easy enough to enable but obviously will require testing.
- Mount options
- Specifiying extra, non-default, mount options is fully supported in the LCFG custom recipe.