Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ugrd unable to read LUKS header for LUKS1 device
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
veritysr
n00b
n00b


Joined: 05 Apr 2025
Posts: 2

PostPosted: Sat Apr 12, 2025 2:43 pm    Post subject: ugrd unable to read LUKS header for LUKS1 device Reply with quote

I have an encrypted root filesystem, that is LUKS1.

I'm getting the following error when running ugrd that is preventing me from upgrading my kernel (sys-kernel/gentoo-kernel-bin).

Code:
ERROR    | [root] Unable to read LUKS header.
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/ugrd/main.py", line 167, in main
    generator.build()
  File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 95, in build
    self.run_build()
  File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 235, in run_build
    self.run_hook(task, force_exclude=True)
  File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 151, in run_hook
    if function_output := self.run_func(function, *args, **kwargs):
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 111, in run_func
    if function_output := function(self):
                          ^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/ugrd/crypto/cryptsetup.py", line 388, in export_crypt_sources
    _validate_luks_config(self, name)
  File "/usr/lib/python3.12/site-packages/zenlib/util/dict_check.py", line 36, in _contains
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/ugrd/crypto/cryptsetup.py", line 377, in _validate_luks_config
    _validate_cryptsetup_device(self, mapped_name)
  File "/usr/lib/python3.12/site-packages/zenlib/util/dict_check.py", line 36, in _contains
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/ugrd/crypto/cryptsetup.py", line 288, in _validate_cryptsetup_device
    _validate_cryptsetup_header(self, mapped_name)  # Run header validation, mostly for crypto modules
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/zenlib/util/dict_check.py", line 36, in _contains
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/ugrd/crypto/cryptsetup.py", line 241, in _validate_cryptsetup_header
    raise ValueError("[%s] Unable to read LUKS header." % mapped_name)
ValueError: [root] Unable to read LUKS header.


I took a peek at the code and saw that ugrd is calling the following to read the LUKS header.

Code:
cryptsetup luksDump --dump-json-metadata


Since the "--dump-json-metadata" flag only supports LUKS2, it makes sense why ugrd would fail for a LUKS1 device.

Any help would be appreciated - thank you!
Back to top
View user's profile Send private message
zen_desu
Apprentice
Apprentice


Joined: 25 Oct 2024
Posts: 245

PostPosted: Sat Apr 12, 2025 4:57 pm    Post subject: Reply with quote

Yes, it has not been tested with LUKS1 at all.

I can look into this, but is there a particular reason you can't use LUKS2? If this becomes a supported method, it'll probably include big warnings urging the user to upgrade to LUKS2 if possible.

You may be able to get away with disabling header validation, setting "validate_header = false" under the [cryptsetup.<name>] section for this volume, but I don't see any issue with making it check for LUKS1 headers if LUKS2 header checks fail.

More info: https://github.com/desultory/ugrd/commit/09a13f3c28b8a4edea514530ee94b983fea3219c#diff-3407a2fd7a1655840c16504015cf360a4728b7babbce12f7783268bf957cfc4eR46-R81
_________________
µgRD dev
Wiki writer
Back to top
View user's profile Send private message
veritysr
n00b
n00b


Joined: 05 Apr 2025
Posts: 2

PostPosted: Sat Apr 12, 2025 6:46 pm    Post subject: Reply with quote

Setting "validate_header = false in /etc/ugrd/config.toml did it - Thank you!

I'm using grub for my bootloader and did my initial install of gentoo with a LUKS2 volume, with default options and it would not boot. After a couple days of troubleshooting, I eventually came across a couple articles that suggested using a LUKS1 volume instead of LUKS2 due to grub's limited support for LUKS2. That did the trick, so I stuck with it for a couple of months, and then I started getting errors during kernel upgrades.

Big warnings, urging users to upgrade to LUKS2 is a great idea. I'll look into getting an update to the gentoo articles that touch on setting up full disk encryption such as https://wiki.gentoo.org/wiki/Full_Disk_Encryption_From_Scratch that would include a similar warning.

Thanks again!
Back to top
View user's profile Send private message
zen_desu
Apprentice
Apprentice


Joined: 25 Oct 2024
Posts: 245

PostPosted: Sat Apr 12, 2025 6:52 pm    Post subject: Reply with quote

veritysr wrote:
Setting "validate_header = false in /etc/ugrd/config.toml did it - Thank you!

I'm using grub for my bootloader and did my initial install of gentoo with a LUKS2 volume, with default options and it would not boot. After a couple days of troubleshooting, I eventually came across a couple articles that suggested using a LUKS1 volume instead of LUKS2 due to grub's limited support for LUKS2. That did the trick, so I stuck with it for a couple of months, and then I started getting errors during kernel upgrades.

Big warnings, urging users to upgrade to LUKS2 is a great idea. I'll look into getting an update to the gentoo articles that touch on setting up full disk encryption such as https://wiki.gentoo.org/wiki/Full_Disk_Encryption_From_Scratch that would include a similar warning.

Thanks again!


You're welcome, I'm glad that worked for you.

Personally, I don't see much risk in keeping the kernel/initramfs on unencrypted storage. These files ideally don't hold secrets, and I'm mostly concerned about if these files are signed/unmodified, which is best done using something like secure boot.
Another challenge presented by using an encrypted /boot is that the bootloader has to decrypt the volume to read the kernel, and unless the initramfs has keys included within it, the root will have to be unlocked a second time.
It's also possible to take a bit of a hybrid approach and use luks1 for your /boot, and then luks2 for your root.

You should be able to get grub to work with luks2/argon2 KDF with some patches, but I don't think it's possible with the current stable version.
_________________
µgRD dev
Wiki writer
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum