| Post Reply | RetroFed Forum Forum Index » Linux |
| Author | Message | ||
|---|---|---|---|
|
tapdattl
lemmy.world
tapdattl@lemmy.world Joined: 2023-07-12 |
I've been trying to set up hibernation on my laptop while also maintaining an encrypted root partition and swap using secure boot and my laptop's TPM. I've documented the steps I've followed below, but I still am unable to enable hibernation. I was under the impression that the only reason you can't normally have both an encrypted harddrive and hibernation was because swap had to be encrypted as well, but if both the root partition and the swap are encrypted, I'm using UEFI secure boot, and they are automatically decrypted at boot using the TPM, shouldn't that relieve those security concerns? After completing the below, entering My personal documentation below:Drop into root shell
Setup LUKS encryption with automatic unlock with TPMInstall necessary components, regenerate initramfs and reboot
Identify swap and root partition devices, names, and luks UUIDs...
In my case, my home partition is on
Set a timeout before the system asks for a password, to allow time for the TPM to load and enter the password for you Add the below then ctrl+o ctrl+x to save and exit
Create a dracut configuration file to install the systemd-ask-password-plymouth service: Add the below, ensure there are spaces inside the quotation marks on either side of the filename
Regenerate initramfs and reboot
Edit crypttab file (
Regenerate initramfs and reboot: Edit fstab to include swap, append the following to
Rebind your home and swap partitions. You will have to do this every time you update the kernel.
|
||
| 29 Original | |||
|
Flyswat
lemmy.dbzer0.com
Flyswat@lemmy.dbzer0.com Joined: 2023-08-16 |
Why binding specifically to PCRs 1,4,5 and 7? |
||
| 2 | |||
|
tapdattl
lemmy.world
tapdattl@lemmy.world Joined: 2023-07-12 |
Why binding specifically to PCRs 1,4,5 and 7? Are they immutable even with updates that modify db and dbx (I think I saw one recently drop on Ubuntu)?
You know I'm not 100% sure, I was following another tutorial that I can't find anymore, but if I remember right 1 was for the UEFI state, 4 was to make sure the bootloader wasn't changed, 5 was for secure boot, and 7 was for the OS being booted (To make sure someone isn't booting Kali in a live disk or something), but I could be wrong. |
||
| 2 | |||
Ooops
feddit.org
Ooops@feddit.orgJoined: 2024-07-06 |
Wild guess as I'm not using dracut and have only setup encrypted hibernation on an old bios laptop... But did you edit the systemd-sleep.conf (usually |
||
| 2 | |||
|
Corngood
lemmy.ml
Corngood@lemmy.ml Joined: 2020-06-24 |
I've got multiple machines that do this, but all on nixos.
This is weird, so I'd start here. Can you get the exact error and/or whatever it logs to journald? I'd ignore all the TPM stuff until you can hibernate it and resume with a password. Maybe the swap is just too small? Maybe something in /etc/systemd/sleep.conf? In case it helps, my device setup looks like this:
so luks -> lvm -> { swap, btrfs } Edit: https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Hibernation
So far I haven't figured out from the systemd docs what "automatically pick a suitable swap space" actually means, or if that's actually accurate. |
||
| 2 | |||
|
moonpiedumplings
programming.dev
moonpiedumplings@programming.dev Joined: 2023-08-10 |
I don't have/use TPM, but I do have encrypted swap and hibernation on a fully encrypted drive. The trick is to put the kernels in the root partition, which is encrypted by LUKS. Then, you can also put a swapfile in that same partition. The only unencrypted part of my system is Grub automatically scans hard drives, before prompting with a password to decrypt the root and everything on it. Because grub is doing the decryption, rather than the kernels, the kernels and swapfile are decrypted all at once. |
||
| 3 | |||
|
BCsven
lemmy.ca
BCsven@lemmy.ca Joined: 2023-06-17 |
Did you do this ? Get the UUID of swap partion then add it to boot parameter(resume=UUID=xxxx) System needs that in grub line so it knows where to put the hibernation stuff, and obviously swap has to be equal or larger than RAM amount. |
||
| 3 | |||
dieTasse
feddit.org
dieTasse@feddit.orgJoined: 2025-02-24 |
You know I'm not 100% sure, I was following another tutorial that I can't find anymore, but if I remember right 1 was for the UEFI state, 4 was to make sure the bootloader wasn't changed, 5 was for secure boot, and 7 was for the OS being booted (To make sure someone isn't booting Kali in a live disk or something), but I could be wrong.
The thing about automated encrypted drive unlock is that you are missing kernel check pcr (8 or 9 I don't remember) and without that anyone can boot with compromised kernel and unlock your drive. Which makes encryption kind of pointless. The same pcr, however, means that you have to rebind after every kernel update (which is quite often on many distros). The disadvantage is that with current state of the software handling auto unlock on Linux is kinda flaky and rebinding may involve more than one restart. I eventually realized that it's less trouble to just skip this altogether and enter the password every time and then set autologin. |
||
| 2 | |||
mlg
lemmy.world
mlg@lemmy.worldJoined: 2023-07-29 |
I actually just did this recently with a BTRFS subvolume using a swap file and LUKS encryption. The old Fedora magazine article has the overall steps required and someone also made a guide for secure boot on I think the The catch is that secure boot will only allow signed images to be loaded which includes the hibernation swap image, meaning you have to use a customized kernel that allows unsigned hibernation images to load. I'll share both links when I get a chance. EDIT: Fedora Magazine guide: https://fedoramagazine.org/hibernation-in-fedora-36-workstation/ This is slightly outdated as Fedora now uses a proper zram.swap definition with systemd, so you can also do a systemctl edit to disable and enable zram0 with post/pre start on the hibernate service directly instead of using swapon/swapoff. I'll make a second edit with my example I'll have to dig out of some poorly documented notes lol. This is the full forum post guide for FDE + TPM + secure boot. I'm not entirely sure of the kernel patch specific but it seems that the hibernate swap image is technicallly signed because if the bootloader process, but the kernel lockdown mode rejects it regardless by default because there's no guarantee that the swap image was configured with FDE and not tampered with, which would be a vulnerability. Quick glance at the kernel patch makes it seem like it's just a flag check to allow hibernate in lockdown mode, so I assume the secure boot signature check is still completed.
|
||
| 6 | |||
Ooops
feddit.org
Ooops@feddit.orgJoined: 2024-07-06 |
Did you do this ? Get the UUID of swap partion then add it to boot parameter(resume=UUID=xxxx) System needs that in grub line so it knows where to put the hibernation stuff, and obviously swap has to be equal or larger than RAM amount.
I asked the same as |
||
| 3 | |||
Ooops
feddit.org
Ooops@feddit.orgJoined: 2024-07-06 |
I don't have/use TPM, but I do have encrypted swap and hibernation on a fully encrypted drive. The trick is to put the kernels in the root partition, which is encrypted by LUKS. Then, you can also put a swapfile in that same partition. The only unencrypted part of my system is /boot/etfi, which is the EFI partition that holds nothing but the grub binary. Grub configs and kernels are in /boot, w...
OP seems to use the systemd hooks anyway. And with them all disks get decrypted with the first given password (or at least try and only ask for additional passwords if that fails). So it's not neccessary anymore to have everything on the root partition. Several encrypted with the same password will do. (For example I unlock a classic swap partition and 3 differently sized disks creating one btrfs raid1 for root with one password.) |
||
| 2 | |||
|
tapdattl
lemmy.world
tapdattl@lemmy.world Joined: 2023-07-12 |
Did you do this ? Get the UUID of swap partion then add it to boot parameter(resume=UUID=xxxx) System needs that in grub line so it knows where to put the hibernation stuff, and obviously swap has to be equal or larger than RAM amount.
No, I'm using UEFI so from what I read on the ArchWiki that's only needed for older non-UEFI systems |
||
| 1 | |||
|
tapdattl
lemmy.world
tapdattl@lemmy.world Joined: 2023-07-12 |
Wild guess as I'm not using dracut and have only setup encrypted hibernation on an old bios laptop... But did you edit the systemd-sleep.conf (usually /etc/systemd/sleep.conf, although there are some other possible locations)? The other old-school and universal way of telling your system that hibernate is enabled without systemd would be a resume= kernel parameter
I did not, looking at my new laptop that file doesn't even exist, is that something I can just create and add in to folder? On my current computer it exists, so I have a template at the very least. |
||
| 1 | |||
|
tapdattl
lemmy.world
tapdattl@lemmy.world Joined: 2023-07-12 |
I actually just did this recently with a BTRFS subvolume using a swap file and LUKS encryption. The old Fedora magazine article has the overall steps required and someone also made a guide for secure boot on I think the spiceworks framework forum. The catch is that secure boot will only allow signed images to be loaded which includes the hibernation swap image, meaning you have to use a customi...
Oh awesome I had seen the Fedora Magazine article but not the framework guide. I'll give that a shot, thank you! |
||
| 2 | |||
Ooops
feddit.org
Ooops@feddit.orgJoined: 2024-07-06 |
I did not, looking at my new laptop that file doesn't even exist, is that something I can just create and add in to folder? On my current computer it exists, so I have a template at the very least.
As of the manpages systemd-sleep looks for:
Also
So yes, you can use any existing file from another computer as your template (root:root 644 would be the default owner/permissions for it). PS: I tried on my PC and setting You can however set the |
||
| 1 | |||
|
BCsven
lemmy.ca
BCsven@lemmy.ca Joined: 2023-06-17 |
No, I'm using UEFI so from what I read on the ArchWiki that's only needed for older non-UEFI systems
You may me need it for encrypted swap if systems isn't picking it up via systemd automatically. What does cat /sys/power/resume |
||
| 1 | |||
| Post Reply |
Back to top |