Skip to content

LUKS support for systemd-repart - #2662

Open
Johan-Liebert1 wants to merge 10 commits into
bootc-dev:mainfrom
Johan-Liebert1:repart-luks
Open

Johan-Liebert1 wants to merge 10 commits into
bootc-dev:mainfrom
Johan-Liebert1:repart-luks

Conversation

@Johan-Liebert1

Copy link
Copy Markdown
Member

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

  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

Copilot AI balanced review requested due to automatic review settings November 18, 2026 10:04
@github-actions github-actions Bot added area/install Issues related to `bootc install` area/documentation Updates to the documentation labels Nov 18, 2026
@bootc-bot
bootc-bot Bot requested a review from gursewak1997 November 18, 2026 10:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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
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

Comment thread crates/blockdev/src/luks.rs Resolved
Comment thread crates/lib/src/install/baseline.rs Resolved
Comment thread crates/lib/src/install/baseline.rs Resolved
Comment thread crates/lib/src/install/baseline.rs Resolved
Comment thread crates/lib/src/install/baseline.rs Resolved
Comment thread crates/lib/src/install/baseline.rs Resolved
Comment thread tmt/tests/booted/test-install-repart.nu Resolved
Comment thread tmt/tests/booted/test-install-repart.nu Resolved
Comment thread tmt/tests/booted/test-install-repart.nu Resolved
Comment thread crates/lib/src/install/baseline.rs Resolved
Comment thread crates/lib/src/install/baseline.rs Outdated
//
// as we get two services 'systemd-gpt-auto-generator' and 'systemd-cryptsetup@root.service'
// fighting for the same device
let mut kargs = if !discoverable {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hummm do we really need to handle systemd-repart without DPS?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to do this for ostree systems as well right? At least until we retire it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread crates/lib/src/install/baseline.rs Resolved
Comment thread crates/lib/src/install/baseline.rs Resolved
Comment thread crates/xtask/src/tmt.rs Resolved
Comment on lines +66 to +67
- **GRUB:** a BIOS boot partition **and** a separate XBOOTLDR
(unencrypted `/boot`) partition are **both absolutely required** for LUKS

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the GRUB case it's not actually XBOOTLDR, just "a classic /boot partition" right?

@Johan-Liebert1 Johan-Liebert1 Nov 19, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment on lines +15 to +16
# NOTE: This is DPS UUID for x86 root
const ROOT_DPS_UUID = "4f68bce3-e8cd-4db1-96e7-fbcaf984b709"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(If we wrote this test in Rust which is now supported we could use our own crate for this stuff)

}


def test_repart_luks [] {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@Johan-Liebert1
Johan-Liebert1 force-pushed the repart-luks branch 3 times, most recently from 418f0d1 to 19c6537 Compare November 19, 2026 06:49
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>
Comment on lines +1591 to +1592
if bootfstype != "vfat" {
crate::lsm::ensure_dir_labeled(&target_rootfs, BOOT, None, 0o755.into(), sepolicy)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, maybe better to just handle EOPNOTSUPP cleanly there

Comment thread crates/lib/src/install/baseline.rs Outdated
//
// as we get two services 'systemd-gpt-auto-generator' and 'systemd-cryptsetup@root.service'
// fighting for the same device
let mut kargs = if !discoverable {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation Updates to the documentation area/install Issues related to `bootc install`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants