Repository navigation
LUKS support for systemd-repart - #2662
Johan-Liebert1 wants to merge 10 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Critical regressions can abort valid installs or select the wrong LUKS key, while broken test fixtures and unsupported integration-test assumptions leave multiple tests failing.
9 open issues
Fix the invalid JSON fixture and mismatched assertions · New Update planned boot partition size expectations for XBOOTLDR · New Include xbootldr in repart argument expectations · New Honor the last effective KeyFile assignment · New Avoid cryptsetup probes for unencrypted installs · New Use the root filesystem for non-repart installs · New Use a symlink-capable filesystem for OSTree tests · New Gate the KeyFile test on repart version support · New Select the encrypted partition independently of the x86 root GUID · New
What changed in this PR
Adds LUKS-encrypted root support to the systemd-repart installation path, alongside XBOOTLDR handling for separate /boot partitions.
Changes:
- Parses LUKS metadata to identify TPM-backed and plain keyslots, unlock root, and configure boot arguments.
- Includes XBOOTLDR during installation and handles its filesystem type and UUID independently of root.
- Adds encrypted-install tests and documents repart-based encryption and bootloader requirements.
| File | Description |
|---|---|
tmt/tests/booted/test-install-repart.nu |
Adds a keyfile-encrypted installation test and shared partition GUID constants. |
docs/src/bootc-filesystem-encryption.7.md |
Documents repart encryption and required boot partitions. |
crates/lib/src/install/baseline.rs |
Implements encrypted-root setup and updates XBOOTLDR handling. |
crates/blockdev/src/luks.rs |
Adds LUKS2 metadata parsing, querying, and a unit test. |
crates/blockdev/src/blockdev.rs |
Exposes the new LUKS module. |
Review effort: Balanced
e95a762 to
c367c88
Compare
| // | ||
| // as we get two services 'systemd-gpt-auto-generator' and 'systemd-cryptsetup@root.service' | ||
| // fighting for the same device | ||
| let mut kargs = if !discoverable { |
There was a problem hiding this comment.
Hummm do we really need to handle systemd-repart without DPS?
There was a problem hiding this comment.
We should be able to do this for ostree systems as well right? At least until we retire it
There was a problem hiding this comment.
But why go to the extra effort? It adds a fair amount of conceptual complexity. Why not just say if you're using repart.d then we expect DPS?
| - **GRUB:** a BIOS boot partition **and** a separate XBOOTLDR | ||
| (unencrypted `/boot`) partition are **both absolutely required** for LUKS |
There was a problem hiding this comment.
In the GRUB case it's not actually XBOOTLDR, just "a classic /boot partition" right?
There was a problem hiding this comment.
It could be either/or iiuc. I'll mention a classic /boot partition as well
|
|
||
| ## Encryption with `systemd-repart` | ||
|
|
||
| A recommended way to provision an encrypted root for a bootc system is to |
There was a problem hiding this comment.
This is of course complex as some people/organizations will want to support generic base images that can be installed in various ways...(relying on cloud provider encryption e.g. or using remote Clevis/Tang style things which aren't covered here but are covered by Ignition etc)
| # NOTE: This is DPS UUID for x86 root | ||
| const ROOT_DPS_UUID = "4f68bce3-e8cd-4db1-96e7-fbcaf984b709" |
There was a problem hiding this comment.
(If we wrote this test in Rust which is now supported we could use our own crate for this stuff)
| } | ||
|
|
||
|
|
||
| def test_repart_luks [] { |
There was a problem hiding this comment.
This isn't new exactly but I will just note here that I think we really need to move these tests into something that's booted and not just install tested
There was a problem hiding this comment.
Yeah, I definitely wanted to do that at first, but wasn't sure how tmt would act if a new disk is booted on the VM. This could be a followup or would you prefer an actual booting test?
418f0d1 to
19c6537
Compare
Assisted-by: LLMs (Claude Opus 4.8) Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Handle all types of LUKS encryption set for the root partition, viz TPM, TPM+keyfile and just keyfile. Add appropriate kargs depending upon the type of LUKS encryption being used which we get by querying LUKS metadata for the root partition. Currently LUKS encryption with grub as bootloader doesn't work and fails with the following error ``` /usr/sbin/grub2-install: error: attempt to install to encrypted disk without cryptodisk enabled. Set `GRUB_ENABLE_CRYPTODISK=y' in file `/etc/default/grub'. ``` Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Similar to how we create BIOS,ESP and ROOT on first install, also include XBOOTLDR Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Assisted-by: LLM (Claude Opus 4.8) Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
If the encryption is done via Key-File+TPM2 then we need to allow interactivly entering password which headless mode prevents Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Fix a few issues related to XBOOTLDR partition 1. We were using the same fstype as rootfs when mouting a parition at /boot, which would fail if XBOOTLDR was vfat formatted 2. vfat partitions don't have 128 bit UUIDs, and install would fail with failing to parse the actual 32-bit UUIDs that vfat partitions do use Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Older systemd versions (< 259) don't support KeyFile= option. In that case fall back to using TPM for luks Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
So we can use struct fields instead of matching on serde values Also, only add LUKS kernel cmdline for non BLS compliant bootloaders Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Move the code block checking for a LUKS root generated by systemd-repart to a separate function. Docs for the function generated by LLM Update the decrypted luks root name to `bootc-root` from just `root` to avoid potential name collisions Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
19c6537 to
f045ea8
Compare
| if bootfstype != "vfat" { | ||
| crate::lsm::ensure_dir_labeled(&target_rootfs, BOOT, None, 0o755.into(), sepolicy) |
There was a problem hiding this comment.
Hmm, maybe better to just handle EOPNOTSUPP cleanly there
| // | ||
| // as we get two services 'systemd-gpt-auto-generator' and 'systemd-cryptsetup@root.service' | ||
| // fighting for the same device | ||
| let mut kargs = if !discoverable { |
There was a problem hiding this comment.
But why go to the extra effort? It adds a fair amount of conceptual complexity. Why not just say if you're using repart.d then we expect DPS?

blockdev: Add LUKS metadata output parser
repart: Handle LUKS encryption
Handle all types of LUKS encryption set for the root partition, viz TPM,
TPM+keyfile and just keyfile. Add appropriate kargs depending upon the
type of LUKS encryption being used which we get by querying LUKS
metadata for the root partition.
repart: Create xbootldr partition on install
Similar to how we create BIOS,ESP and ROOT on first install, also
include XBOOTLDR
man: Add docs about systemd-repart + LUKS
Assisted-by: LLM (Claude Opus 4.8)
luks: Only add 'headless=true' cmdline for TPM only
If the encryption is done via Key-File+TPM2 then we need to allow
interactivly entering password which headless mode prevents
to-disk: Handle XBOOTLDR partition
Fix a few issues related to XBOOTLDR partition
We were using the same fstype as rootfs when mouting a parition at
/boot, which would fail if XBOOTLDR was vfat formatted
vfat partitions don't have 128 bit UUIDs, and install would fail with
failing to parse the actual 32-bit UUIDs that vfat partitions do use