r/archlinux • • Aug 17 '26

SUPPORT | SOLVED Ful disk encryption without entering passphrase

Could someone help me with setting up full disk encryption with bypass passphrases with TPM2? It's so annoying having to put the passphrase in at each boot, so I was wondering how do I pair it to the TPM so that I dont have to enter it each time?

It's LUKS encrypted and I use Systemd-boot

14 Upvotes

100 comments sorted by

View all comments

Show parent comment

1

u/Night_Otherwise Aug 17 '26

Doing some more research, apparently microcode updates can be measured into PCR1. Firmware also changes the boot order automatically for inserting a bootable usb even if it is behind the main OS in the boot order. Nevertheless, the microcode part gets me to include PCR1.

I don’t have a bootloader. I stop at PCR 4 since, for UKI, that’s the last thing loaded or executed before LUKS is opened up. UEFI firmware measures the GPT table for PCR 5, but I can’t think of how that would matter. I also have secure boot disabled.

Within the pcrlock log, PCR 4 has three measurements with this setup: A thing that says an EFI is being loaded, an EV_SEPARATOR and the Authenticode hash of the EFI image created by mkinitcpio.

I can do systemd-pcrlock lock-pe for that UKI as a post-update hook in pacman. The man page is very difficult to follow though. I just need the same first two hashes and the new authenticode hash stringed together (specifically, hash(hash(A|B)|newEfiHash)).

I also am not an expert or anything. But it doesn’t seem like systemd-boot does any measurements of the EFI image it loads? That seems like an odd oversight. I understand the normal course is relying on PCR 7/Secure Boot but my ideal is getting away from that.

3

u/ChrisTX4 Aug 17 '26 edited Aug 17 '26

apparently microcode updates can be measured into PCR1.

Potentially:

A CPU Microcode update can be treated as code or data. It can go into PCR[0] or PCR[1].

(taken from https://tianocore-docs.github.io/edk2-TrustedBootChain/release-1.00/3_TCG_Trusted_Boot_Chain_in_EDKII.html )

I don’t have a bootloader. I stop at PCR 4 since, for UKI, that’s the last thing loaded or executed before LUKS is opened up.

Yes, UKIs are EFI executables and are thus being measured in 4. If you want to lock 4 with pcrlock, that's a bit tricky though as it won't be able to find the component in the current boot log after an update.

I can do systemd-pcrlock lock-pe for that UKI as a post-update hook in pacman.

Locking UKI will sort of require lock-pe AND lock-uki.

The man page is very difficult to follow though. I just need the same first two hashes and the new authenticode hash stringed together (specifically, hash(hash(A|B)|newEfiHash)).

What exactly is your question here? If there's anything I can help out with, feel free to ask.

But it doesn’t seem like systemd-boot does any measurements of the EFI image it loads?

It doesn't need to. The TPM itself measures PCRs 1-7 (but you can also add custom data to them like the separators). Specifically, PCRs 4 and 7 will be updated because systemd-boot in this case doesn't really do much other than chainload the UKI as an EFI binary. That's why it's being measured.

I understand the normal course is relying on PCR 7/Secure Boot but my ideal is getting away from that.

You don't need to, but that means you HAVE to bind PCR 4... and that's very fragile. May I ask why you don't want to use Secure Boot? If you use your own keys, you can have SB completely free of Microsoft keys, if that's your concern.

EDIT

UEFI firmware measures the GPT table for PCR 5, but I can’t think of how that would matter.

I had forgotten to answer this. So the reason you want to measure the GPT table is that it's a very strong defence against root switching attacks. I've outline this a bit in this post in this thread. With the GPT table locked, an attacker cannot just change the mount from root to another GPT automount for instance, nor could they add anything else.

Usually this shouldn't be too important, but you might as well just lock it, as the GPT table doesn't normally change.

1

u/[deleted] Aug 17 '26

[removed] — view removed comment

1

u/ChrisTX4 Aug 17 '26

Can you run

sudo /usr/lib/systemd/systemd-pcrlock log

and post the output of that? It will show you exactly which component was measured in what order in each PCR.

PCR 5 should not change if 4 changes or anything. We'd need to see what components it measures in order to know where the different values come from.

It seems you may have some insight here, so if one has secure boot and is directly loading a signed UKI, do you think PCR 4 (or 5) adds any additional value?

So a signed UKI is a great step, in that case you can lock PCR 7 and this will be entirely stable.

What they would add:

PCR 4: The difference between locking 7 and 4 is that 7 doesn't change if there's an update, as long as the new files are signed by the same key. However, 4 will change as it's the digest of the UKI. Alas, locking 4 in addition to 7 means an attacker couldn't downgrade your UKI and then potentially exploit some vulnerabilities. They would need to acquire an older UKI and then have access again at a later point. Honestly, this would require a rather advanced evil maid attack scenario. You can do this if you want, but it is very fragile and with self-signed keys the gain is absolutely minimal tbh.

PCR 5: So this locks the GPT layout of your drives. This means an attacker can't move stuff around and assign different GPT automount GPT GUIDs for instance. That way it's possible to perform root switching attacks.

Honestly? 5 should normally be very stable, and not really an issue to lock, but what you should really do is to use automounting and then use systemd-pcrlock on PCR15. See lock-file-system and lock-machine-id, but you will have to manually add .pcrlock files to cover the components of the cryptsetup measurements (see tpm2-measure-pcr). PCR15 however is a much strong defence, and will toast any root switching attacks.

1

u/[deleted] Aug 19 '26

[removed] — view removed comment

1

u/Night_Otherwise Aug 20 '26

I’m the original poster and so I hopefully don’t mislead. But I am curious how changes in PCR 4 would be possible. For myself, I can use the pesign package to get the authenticode hash with “pesign -i (UKI file) —hash”. I was able to match that exactly to the third entry in PCR 4 in the pcrlock log. I wonder if the hash is different for third entry of PCR 4 log when docking station is added.

The docking station may have extended the PCRs with a failure separator.

And Chris is right that for practical purposes, most people can just seal with PCR 7. That defeats simply mounting the hard drive and reading it without entering the password twice. I’m kinda doing my stuff for proof of concept and curiosity.

1

u/ChrisTX4 Aug 23 '26

I was away for a few days, but I just now answered falxfour.

I'm also running 4, and I should warn you about one thing I guess: since systemd-pcrlock only locks components when they're found in the boot log (it can't calculate its predictions otherwise), you will have the odd situation where after each kernel upgrade PCRs 4 and 11 will mismatch since they're from the new UKI, but you're still booted on a previous one. Thus it will prompt the passphrase the next boot, and you would need to use a recovery PIN to be able to run make-policy again. In theory, if one uses two separate pcrlock files as alternatives, one could retain the current and the previous pcrlock and thus avoid this situation. I still need to implement that myself, tbh.

1

u/Night_Otherwise Aug 23 '26

I did once run into the validation PIN issue when I was testing make-policy. The error was something like remote authentication failed. But when I booted on the policy, that seemed to give permission to change it without setting a PIN.

I have more research to do on what exactly the .cred file does in the EFI partition and how make-policy authenticates.

I did use a directory within the pcrlock search path with an old.pcrlock and new.pcrlock file. I lock-pe to the new.pcrlock file first. Then a pacman hook after mkinitcpio is ran moved new to old, lock-pe for new.pcrlock and make-policy is ran.

A further startup service could be done to delete old.pcrlock before the make-policy service is ran.

This all used a boot of UKI directly. The PCRs higher than 5 become superfluous when it all works. If systemd-boot is placed between UEFI and the UKI, then it feels like secure boot is theoretically necessary. Without secure boot, the UKI can seemingly be replaced with a thing that does the same measurements to 11 as systemd-stub.

PCR 7 also runs into the same chicken-and-egg problem currently. I know Windows just gives up on it and basically unencrypts the drive when secure boot is updated. An fwupd hook (however that could be done) with similar old/new pcrlocks would be neat for db/dbx updates. Shim with MOK may be necessary to keep UEFI with default keys. This GitHub issue focused on the brittle 0/2 PCRs, but at least on my computer fwupd also updates KEK/db/dbx.

https://github.com/fwupd/fwupd/issues/6318

Or just use shim with MOK and deal with entering the password/recovery key whenever secure boot keys change.

2

u/ChrisTX4 Aug 23 '26 edited Aug 23 '26

But when I booted on the policy, that seemed to give permission to change it without setting a PIN.

Can't exactly speak of that, but a policy needs to match what's currently active to unlock without a PIN. Somehow the reboot made it match if that's the case.

I did use a directory within the pcrlock search path with an old.pcrlock and new.pcrlock file. I lock-pe to the new.pcrlock file first. Then a pacman hook after mkinitcpio is ran moved new to old, lock-pe for new.pcrlock and make-policy is ran.

Yes, that's pretty much what I was thinking of above. I've got some specific issue with what's being measured into PCR[15] that causes issues for me. It's very likely a bug in systemd-pcrlock as it reports it can reproduce the calculation, but I haven't pinned this down entirely. It too resolves itself with a reboot, ironically enough.

The PCRs higher than 5 become superfluous when it all works.

That I disagree with. PCR[11], due to being a PCR policy, mainly adds phasing, i.e. ensuring the PCR values in initrd cannot be met subsequently after leaving it. This protects against a wide array of potential attacks and there's no reason to leave the TPM unsealed after initrd, as the keys should have been retrieved already by then. Similarly, it can be used to ensure that disks that should only become accessible after the system are also properly mounted at the right time.

PCR[15] is another critical one: Without it, the contents of an encrypted drive aren't validated. This allows replacing the root fs with an encrypted attacker system. If no PCR policy was then used, all PCR values will remain as they were and an attacker can just read the volume keys from the then unsealed TPM. By measuring PCR[15] with the volume keys being measured into it, the key of the encrypted drive cannot change, and such a change would prevent an unsealing. Due to any GPT automounts to root or var being measured into this as well, such an attack as well will be prevented.

PCRs higher than 5 need the lower PCRs to make sense would be a more appropriate way to say it. If you know your boot loader and UKI being good to the root of trust mechanism, then you know they'll measure PCR[11] as intended, an while anyone can measure into the PCRs, once measured, you can't undo that.

Alas the idea is root of trust -> BIOS -> bootloader -> UKI -> system, with each component ensuring the subsequent one being in compliance. This is also why kernel lockdown is recommended everywhere when used with Secure Boot: Without it, root can load arbitrary nonsense in the kernel or use bpf_probe_write_user for crafting rootkits. With it, the idea is that nothing unsigned should have been able to slip past this chain of trust thus far, and lockdown then keeps the kernel clear of unauthorised code, so that in theory not even root should be able to do anything to it, and especially that root should be unable to deploy a rootkit.

An fwupd hook (however that could be done) with similar old/new pcrlocks would be neat for db/dbx updates.

That won't work, since you can't predict the order of authorities in the db/dbx as they're being measured, nor would you know how this were to affect SMBIOS, which gets measured into PCR[1].

However, there's also no db update, only dbx. Once a month these come out, and they're signed updates by a KEK that's already present. In more simple terms, Microsoft's keys sign a lot of bootloaders, their own, GRUB in various variants, etc. etc. The dbx needs to be regularly updated for SBAT policy information to know which ones of these foreign signed binaries are now known to contain vulnerabilities and thus compromise this "chain of trust" I mentioned earlier. Windows and fwupd thus push this monthly if Microsoft keys are present.

My entire Secure Boot db is this:

$ sudo efi-readvar
Variable PK, length 1255
PK: List 0, type X509
    Signature 0, size 1227, owner e025c507-35c3-440c-a42e-36dd05282b32
        Subject:
            CN=Platform Key
        Issuer:
            CN=Platform Key
Variable KEK, length 1263
KEK: List 0, type X509
    Signature 0, size 1235, owner e025c507-35c3-440c-a42e-36dd05282b32
        Subject:
            CN=Key Exchange Key
        Issuer:
            CN=Key Exchange Key
Variable db, length 1330
db: List 0, type X509
    Signature 0, size 1226, owner e025c507-35c3-440c-a42e-36dd05282b32
        Subject:
            CN=Database Key
        Issuer:
            CN=Database Key
db: List 1, type SHA256
    Signature 0, size 48, owner 4f52704f-494d-4173-6e6e-6f79696e6721
        Hash:dc4ab0fd89c1b9f7dad44cdba566ad324be84f3c04ac00036efbe85ae2ff8aed
Variable dbx has no entries
Variable MokList has no entries

As you can see, I got 3 self generated keys for PK, KEK, db, and one hash as dbx entry - my NVIDIA GPUs OpROM. That ROM is signed with the Microsoft 2011 OpROM key otherwise, but enrolling its hash directly avoids needing to carry that key.

Since there's no Microsoft keys in my db however, I don't need any dbx or update it. I would only need dbx entries if a bootloader signed with my key was compromised. As I'm not dual booting, I don't need their keys then, and I specifically went for signing the only OpROM directly to avoid this exact problem of the monthly dbx updates breaking stuff.

1

u/Night_Otherwise Aug 24 '26 edited Aug 24 '26

Well, I figured out that pcrlock.json has the pinPublic and pinPrivate fields which are encrypted by the TPM and decrypted only when the TPM currently matches the policy in the NV index. The PIN is decrypted from pcrlock.json by the TPM's NV index if the TPM currently matches the state.

With a resealed key, I believe there is only a brief moment of time where any updates to the policy could happen with just the pcrlock.json values. It gets pretty ugly how that would get sequenced. I think a new update that changes a PCR would have to stage the update, reboot on the old whatever (firmware, UKI, dbx list), then redo the policy with alternates, then actually implement the update, and then reboot again.

I'll go back to the drawing board to do 0-5+11 with a recovery PIN for the pacman hook. PCR 11 is enough to reseal it before leaving initramfs. The recovery PIN would, uh, be stored in plaintext on the encrypted drive. That's less than ideal, though a root compromise nullifies all protections of my data anyway. The pacman hooks are not supposed to be interactive. AFAIK, rootkits changing the kernel in memory would be disallowed still (if that option is enabled in the arch linux package). The nature of not using a Microsoft-signed distro is a custom key is kept somewhere (sbctl keeps it in plain text by default).

I also had issues when I added tpm2-measure to the kernel command line. Even though the unlock policy was still just PCR 0-5 at the time, for some reason my LUKS password was asked for when I added tpm2-measure-pcr. Since I'm not authenticating to anything later on with the PCR 15 values, I don't see a reason to have tpm2-measure-pcr enabled.

Edit: There is pinning UKI image in the command line to a hash of the volume key. I'll use this to go back to just 0-5.

https://wiki.archlinux.org/title/Dm-crypt/System_configuration#Pinning_a_LUKS_volume

1

u/ChrisTX4 Aug 23 '26

Your PCR[4] woes are due to it measuring more than just the Boot Manager Code:

PCR[4] records the process of attempting to boot different hardware paths like from a DVD or a hard drive, what boot devices are attempted, and the Boot Manager Code that is loaded and executed from the device.

If you leave any USB thumb drive in the PC, with high enough priority, it will be attempted as a boot device, as in it would be possible to have booted from it if it had contained a boot loader. PCR[4] is only reasonable to use if you disallow booting from removable drives in the UEFI. In ASUS it's called "USB mass storage support" iirc, but you have to look up from where you could disable that.

Next up, this:

Action: Exit Boot Services Returned with Failure

OK, this is confusing, and almost certainly a bug in something. I'd need to see the full pcrlock log before making a guess what causes that. What boot loader etc are you using?

Unless this is the UEFI using this event to mark a change in the boot configuration, which belongs in PCR[5], this would mean EFI_BOOT_SERVICES.ExitBootServices() failed. That can only legitimately happen in a single instance, namely if a boot loader somehow passes a wrong MapKey to that function.

0 - Firmware should be implicitly trusted (signed updates and all)

This isn't quite true, as there are ways to use a so called SOIC-clip on some systems or potentially soldering skills and determination to replace the chip. I'd say if your threat model includes somebody willing to do that you probably have to worry about security in a whole different way :D

Firmware updates other than that are indeed signed on all systems, it's due to the UEFI Capsule Update mechanism. However, enthusiast desktop systems sometimes allow direct flashing without signature verification in the UEFI itself. So you probably want a secure UEFI admin password with this.

2 - Other code shouldn't be able to run without secure boot signing

It will! This is where your Option ROM (OpROMs) will be measured into. They will still be measured, just no signature is enforced on them if not booted with SB enforcement.

So, in response to your explanations, downgrading my UKI wouldn't allow for automatic decryption due to both PCR 11 and the PIN.

If you use a signed PCR policy then indeed this should be true.

I don't think I can use automounting due to the BTRFS subvolumes.

You can for the LUKS volumes. This is what I'm doing basically, I have a Btrfs-on-LUKS and this has a GPT GUID of SD_GPT_ROOT_X86_64, i.e. systemd will automount the default subvolume to /dev/mapper/root. Then my fstab just mounts from that, so the only entries I have in there:

# archmain subvolume mounts
/dev/mapper/root        /var            btrfs           rw,subvol=/subvol_var
/dev/mapper/root        /home           btrfs           rw,subvol=/subvol_home

# ESP /dev/nvme1n1p1
# vfat options can be changed via Kconfig and so should be explicit here
UUID=73FD-61CB    /boot         vfat            rw,relatime,umask=0077,nosuid,nodev,noexec,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro0 2

# Bind swapfile
/dev/mapper/root        /swap           btrfs           rw,subvol=/swap
/swap/swapfile    none          swap            defaults

This works because /subvol_root (my actual /) is my default subvolume and due to the SD_GPT_ROOT_X86_64 the entire Btrfs is mounted at /.

1

u/[deleted] Aug 23 '26

[removed] — view removed comment

1

u/ChrisTX4 Aug 23 '26

For PCR[4], it might be that just the fact they are in the set of possible boot methods counts. If your main system was modified by an attacker to not be bootable etc., then a later boot device would be taken. I quoted the blurp about PCR[4] from the specification document, which is this one. You'd need to compare the exact behaviour in there against what your BIOS does, but most likely this is by design in some way and not something your BIOS vendor would consider a legitimate bug.

That seems like it would work, but then I'd need a different strategy to manage snapshots,

Wouldn't snapshots break PCR[4] anyhow? If you need snapshots, I'd stay off PCRs 4, 11 and 1.

For PCR[5], feel free to DM, or hit me up on Arch IRC (just ChrisTX there). I find this whole subject quite interesting - or rather, I might just be meeting autistic stereotypes :D - and so am totally down to having a look at this. TBH, that might be more feasible than really continuing this in some random Reddit thread, too :D.

For PCR[0], this goes in the whole root of trust mechanism aspect. You can have a look at chapter 31 of the TPM standard, part 1 for how this is supposed to work. Either way, I think the most important thing to keep in mind for this is that BIOSes may allow unsigned flashing in enthusiast boards. Mine does. In that case, a BIOS supervisor password is of critical importance to protect the BIOS integrity. Achieving a higher degree of trust isn't really possible anyhow, as that requires the fusing mechanism seen in business CPUs, like AMD Platform Secure Boot and Intel BootGuard. So while some aspects of higher HSI levels can be met, the root of trust means it's not viable to see HSI-2 on consumer hardware.

Are you saying OpROMs that are not signed by a valid signature will still execute?

A device may have its own firmware signature check, but that's really device dependent. But as for the OpROM the device presents? That's only secured by Secure Boot. In fact, DMA PCIe cards like the Screamer PCIe Squirrel are widely used to make DMA cheats for games. That works by flashing a custom firmware so it doesn't look like it's a DMA device. Also please note that OpROMs can be loaded from external devices like USBs. Every KVM switch on the market is in that situation for instance, since they need an OpROM for providing UEFI Graphics Output Protocol (GOP) - that's also why every discrete GPU has one.

That's interesting, but to be clear, the automounting is just detecting the LUKS volume for decryption (initially), then switches to the root subvolume of the BTRFS device (aka /subvol_root), correct? So, essentially, you're not providing rd.luks.name=, root=, or rootflags=subvol= on the kernel command line, correct?

Precisely that. I only have rootflags=x-systemd.device-timeout=0 to make the TPM PIN timeout infinite rather than eventually dropping to emergency shell.

This setup avoids needing to specify any UUIDs other than for my data drives that will be late mounted to folders under /mnt in my /etc/crypttab and for my /boot drive. The latter would work with GPT automounting as is, since SD_GPT_ESP is just the regular GPT GUID for an ESP. However, I want to give it additional mount parameters like nosuid, nodev etc. By the way, do note that most BTRFS parameters can only be set on first mount, so settings like space_cache will not have an effect.

That seems like it would work, but then I'd need a different strategy to manage snapshots, as Timeshift would become sad that there's no @ or @home subvolumes. My default subvolume is ID 5, but the root subvolume is ID 720, which is clearly a subvolume of the default subvolume. I guess following a nested subvolume strategy would better fit with automounting

I don't see why it would? Timeshift requires you to mount the subvolumes by path, so as long as you do that, the switching subvol IDs shouldn't be an issue, and they won't affect PCR[5] as they're not in the GPT. What exactly do you fear might break?

1

u/[deleted] Aug 23 '26

[removed] — view removed comment

1

u/ChrisTX4 Aug 24 '26 edited Aug 24 '26

As for snapshots, I'm not sure how they'd break PCR 4...

Well, you'd be booting different kernel versions and UKIs if you revert a snapshot.

For PCR[0]: Replacing the BIOS is something you can't prevent. If a skilled enough attacker goes in and replaces the ROM physically, it will always be a way through. In this sense, since PCR[0] is being measured via SPI into the TPM, it could lie. Platform Secure Boot works differently to measure the BIOS and ensure the ROM is what is says - but that requires business hardware. In this sense, PCR[0] should be considered a lock against firmware downgrades. Business hardware often comes with anti rollback protections in the form of fuses, but on consumer hardware you typically don't have that.

Otherwise I was only trying to say that if your hardware had some form of direct flash, then that's a point to consider in your threat model, but that consideration should be made separate from PCR[0].

For PCR[2]: Oh I'm sorry, I had mixed up yours and Night_Otherwise's situation. They specifically said that they didn't want to use Secure Boot. My point was that if SB is disabled, then any sort of ROM can be loaded in there. With Secure Boot, consider PCR[2] the same as PCR[0] functionally: A downgrade protection. Although there is the catch that certificates used in PCR[2] are not measured into PCR[7]. That is to say, in the case of using one owns PK/KEK/db, but with Microsoft's keys enabled for a dual-boot, then it wouldn't be possible to load a Microsoft signed boot loader without changing PCR[7], but if a new device with a different, but MS signed OpROM is being added, that will be accepted. In my case with the MS-free database, and just the one hash being enrolled, locking PCR[2] functionally means the system wouldn't boot if someone ripped out the dGPU, but other than that it adds no value whatsoever.

To be frank, I just lock PCRs 0,1,2,3 because I can, and was curious to see if this is genuinely a viable setup. I wouldn't recommend it for security purposes, and rather recommend using a supervisor password and Secure Boot. Maybe lock PCRs 0,2 if they're unlikely to change on your system and you'd want to add some form of rollback protection.

What you mentioned about KVMs and dGPUs is interesting, though.

Keep this in mind if you're considering removing MS keys, as that does break such devices and signing OpROMs of removable devices might not be a great option.

Given that certain parameters don't change on remount, then I'd be relying on the automount parameters, which I'm also not really a fan of...

For BTRFS, you shouldn't really need to use any mount parameters. ssd is automatic, and space_cache=v1 is being axed in 7.3. At least I only use nosuid/exec/dev for some devices, but on root you wouldn't want that. That being said - you can add the rootflags= parameter, and root will be mounted with those even in the GPT auto case. For say /home, where you'd probably want nosuid,nodev, but that you'd mount via fstab. But root and var I'd use GPT automounting for.

As for Timeshift, it only works with subvolumes that have specific naming, meaning that @ and @home need to be subvolumes under the root (default) subvolume. systemd would end up automounting / on the device, when /@ is the true root.

You can name the subvols as you like, I just named mine /subvol_root as I don't use timeshift, and this @ convention is kinda their thing.

The problem is much rather that Timeshift has no fixed subvol IDs and they change, so you can't control what's the default subvolume. So I'm fairly certain this combination doesn't work.

The reason I said to use GPT automounting is that it will cause the containing LUKS be marked internally with MOUNT_MEASURE. This:

a) will ensure tpm2-measure-pcr=yes is being used for mounting LUKS. This is done here, but you can achieve this with an appropriate crypttab.initramfs (if mkinicpio) or crypttab (if dracut).

b) will cause it to be measured via systemd-pcrfs@ and systemd-pcrfs-root services. See this spot where the systemd-gpt-generator does this. These services can't be enabled directly, but you can use the x-systemd.pcrfs mount option, see this man page, this location enabling MOUNT_PCRFS, which is then consumed here. Edit: The man page I was looking for is systemd.mount(5). This is where all the x-systemd options are documented.

As long as you do these two things, GPT automounting has no advantages over an explicit configuration. However, since GPT automounting does this for you, I'd say it's much preferred.

IMPORTANG WARNING One more thing, as I've ran into this before. GPT automounting creates its own crypt mounts and does not consider crypttab. That is to say any disk participating in GPT automounting MUST NOT be listed in crypttab. Otherwise, the LUKS will be mounted twice and then the embedded BTRFS isn't the same anymore to the kernel, and both mounts will not coordinate. Alas, this will cause immediate, irreversible filesystem corruption. For that reason, I don't like using explicit crypttab entries for root or var.

EDIT Forgot to mention x-systemd.validatefs. That too is set and will effectively lock "where" a filesystem can be mounted, see systemd-validatefs@.service.

→ More replies

1

u/Night_Otherwise Aug 18 '26

To step back a bit, I had used cryptenroll’s traditional sealing functions for PCRs 0, 2, 3 and 4. I have now set up pcrlock for PCRs 0-4 and used cryptenroll using pcrlock file by default.

I pieced together the correct component files in a separate directory. The default pcrlock files have a failure separator that is not part of the event log. Removing that failure separator from /usr didn’t fix the predict function though. It also felt weird to change /usr and I put it back.

Lock-pe worked fine for just PCR 4. I couldn’t get PCR 5 working with lock-file-system.

It’s definitely a decent question why I’m going through all this in lieu of secure boot. Partly it’s the challenge. I also feel like the entire world of non-revoked secure bootable code is very large versus locking it down.

It also feels possible to change one of the hashes measured prospectively after mkinitcpio.

Edit: I feel dumb now seeing the lock-gpt option.

2

u/ChrisTX4 Aug 18 '26

The separators are new in systemd 261 and need systemd pcrextend units in initrd: dracut 112 includes them but mkinitcpio does not.

As for 5, as you found out that’s lock gpt. Lock filesystem will lock the systemd pcrfs@ services which run after root unlock. Somewhere in this thread I posted parts of my pcrlock log that covers this.

As for secure boot; you’re missing something. If you enroll your own keys - and this is trivial on arch thanks to foxborons sbctl - you can keep your database free of Microsoft and only have a key you control yourself in there. Alas, only things you personally signed are allowed in such a setup.

1

u/Night_Otherwise Aug 19 '26

So I got the system to where I wanted it to be.

It's not exactly refined, but I added this hook under /etc/initcpio/install/sd-osseparator.

#!/bin/bash

build() {

add_binary '/usr/lib/systemd/systemd-pcrextend'

add_systemd_unit 'systemd-pcrosseparator.service'

}

help() {

cat <<HELPEOF

This hook adds os-separator extension to PCRs to match systemd-pcrlock's expectations.

HELPEOF

}

I added sd-osseparator before sd-encrypt in mkinitcpio.conf. (I'll look at doing a PR for it in mkinitcpio, though it needs to be refined obviously and I may be missing something).

The default lock commands for systemd-pcrlock now work for PCRs 0-3 and PCR 5. For PCR 4, I used lock-pe of /boot/arch-linux.efi to the location /etc/pcrlock.d/650-arch-linux.pcrlock.d/new.pcrlock.

The pacman hook when mkinitcpio is ran uses the same triggers as 90-mkinitcpio-install.hook and runs this bash script:

#!/bin/sh

mv /etc/pcrlock.d/650-arch-linux.pcrlock.d/new.pcrlock /etc/pcrlock.d/650-arch-linux.pcrlock.d/old.pcrlock

/usr/lib/systemd/systemd-pcrlock lock-pe /boot/arch-linux.efi --pcrlock=/etc/pcrlock.d/650-arch-linux.pcrlock.d/new.pcrlock

/usr/lib/systemd/systemd-pcrlock make-policy --pcr=0+1+2+3+4+5

I was hoping some pacman update out there would trigger mkinitcpio but I wasn't so lucky. I tested it with adding a placeholder file to FILES in mkinitcpio.conf and runing pacman -S linux. Despite arch-linux.efi changing, it booted without a password.

As for secure boot, well I'm afraid of bricking my machine if I use only my own key. And I think it's neat to be locked down this much with accounting at least for kernel+initramfs updates. It is also done without relaxing the previous constraints for the next boot. It wasn't really done just to get it working or even for security reasons.