Thanks.grknight wrote:One problem is that CONFIG_BLK_DEV_INITRD is not set in the kernel config.
LUKS needs an initramfs to unlock and prepare the rootfs if contained within.
Oh, and make sure you have created a suitable initramfs and referenced it in your loader, UKI or other kernel options
Actually the top of page explicitly stated thatleyvi wrote:This Arch Wiki page (this specific section) also suggests that decrypting in early userspace is possible without an initramfs, that is using only kernel arguments. Though maybe I misunderstood it...
IMHO Arch Wiki page are very detail but may be too much information all at once especially with all those links that lead to sometime too much that one forgot what was the initial focus.https://wiki.archlinux.org/title/Dm-crypt/System_configuration#Unlocking_in_early_userspace wrote:Booting an encrypted root volume requires that the initramfs contains the necessary tools for early userspace to unlock the volume. The instructions on what to unlock are typically passed via kernel parameters.
The developer of ugrd @zen_desu is very active in our forum ...leyvi wrote:I've heard of dracut and uGRD, and I'm thinking the latter might be better for my use case [...]
Which do you recommend?
Code: Select all
1.
# CONFIG_X86_INTEL_LPSS is not set
CONFIG_X86_AMD_PLATFORM_DEVICE=y
2.
# CONFIG_X86_NATIVE_CPU is not set
3.
CONFIG_MZEN4=y
4.
CONFIG_CMDLINE="cryptdevice=PARTUUID=5c98ed25-6874-46e7-83ac-36c670bdb669:rootfs root=/dev/mapper/rootfs resume=/swap/swapfile hugepagesz=1GB hugepages=8 pcie_aspm=force"
5.
CONFIG_BSD_DISKLABEL=y
CONFIG_EFI_PARTITION=y
CONFIG_NVME_CORE=y
CONFIG_BLK_DEV_NVME=y
# CONFIG_SCSI is not set
# CONFIG_ATA is not set
CONFIG_BLK_DEV_DM_BUILTIN=y
CONFIG_BLK_DEV_DM=y
CONFIG_DM_CRYPT=y
# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed; see USB_STORAGE Help for more info
CONFIG_TYPEC=y
CONFIG_EXT4_FS=m
CONFIG_XFS_FS=m
CONFIG_BTRFS_FS=y
CONFIG_F2FS_FS=mAlright, so I'll use thatpietinger wrote:The developer of ugrd @zen_desu is very active in our forum ...leyvi wrote:I've heard of dracut and uGRD, and I'm thinking the latter might be better for my use case [...]
Which do you recommend?
you more or less need to bundle the initramfs into the signed image, so you can use a UKI or this: https://github.com/desultory/ugrd/blob/ ... the-kernelleyvi wrote:Alright, so I'll use thatpietinger wrote:The developer of ugrd @zen_desu is very active in our forum ...leyvi wrote:I've heard of dracut and uGRD, and I'm thinking the latter might be better for my use case [...]
Which do you recommend?![]()
I messed around with it for a bit, it should be pretty easy.
On a separate note:
I use secure boot to verify my kernel, how do I verify that the initramfs hasn't been tampered with? I realize that this is more of a security question that a kernel/hardware question, so if you think I should post this question on the appropriate part of the forum, I'll happily do that.
Building it into the kernel is a bit trickier, especially if modules end up being needed.leyvi wrote:What do you recommend:
- Building the initramfs into the kernel.
- Making a UKI (however that is done, I have no clue).
This statement is correct ... for the first case.zen_desu wrote:[...] I prefer not to use UKIs that much because you need systemd tools/parts to make them work (at this point in time)
I emphasize: "It is the combination of a UEFI boot stub program like systemd-stub."A unified kernel image (UKI) is a single executable which can be booted directly from UEFI firmware, or automatically sourced by boot loaders with little or no configuration. It is the combination of a UEFI boot stub program like systemd-stub(7), a Linux kernel image, an initramfs, and further resources in a single UEFI PE file.
[...]A unified kernel image (UKI) is a single executable which can be booted directly from UEFI firmware, or automatically sourced by boot-loaders with little or no configuration.
A unified kernel image allows to incorporate all or a subset of the following:
an EFI stub loader like systemd-stub,
...A Unified Kernel Image (UKI) is a combination of an UEFI boot stub program, a Linux kernel image, an optional initrd, and further resources in a single UEFI PE file. [...]
systemd-stub provides the reference implementation of the stub.
Code: Select all
Processor type and features --->
[*] EFI stub supportYes, I have an "UKI" myself, even if it cannot be described as such according to the "academic" interpretation — because it does not have a systemd stub. I have a signed (for SecureBoot) kernel image that contains an embedded initramfs, the kernel command line, and the microcode for the CPU (and also all needed firmware binaries). Even though I use a monolithic kernel (= without module support because everything is configured as built-in), this would not be a mandatory requirement. The only requirement for such an image is that you configure the kernel modules that the kernel needs to address its root partition as built-in (this means you can configure the graphics card modules or sound modules as <M>odule). Then you no longer have to take this "detour" via: build the kernel, install modules, build an initramfs, rebuild the kernel. All you need to do is build the kernel and install the modules. If you even configure a monolithic kernel (like I do), all you need to do is: BUILD KERNEL. (The end, amen, done).This kernel feature allows a bzImage to be loaded directly by EFI firmware without the use of a bootloader.
Code: Select all
CRITICAL | '/rootfs'
Traceback (most recent call last):
File "/usr/lib/python3.13/site-packages/ugrd/main.py", line 175, in main
generator.build()
~~~~~~~~~~~~~~~^^
File "/usr/lib/python3.13/site-packages/ugrd/initramfs_generator.py", line 99, in build
self.run_checks()
~~~~~~~~~~~~~~~^^
File "/usr/lib/python3.13/site-packages/ugrd/initramfs_generator.py", line 278, in run_checks
if check_output := self.run_hook("checks"):
~~~~~~~~~~~~~^^^^^^^^^^
File "/usr/lib/python3.13/site-packages/ugrd/initramfs_generator.py", line 162, in run_hook
if function_output := self.run_func(function, *args, **kwargs):
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/site-packages/ugrd/initramfs_generator.py", line 110, in run_func
if function_output := function(self):
~~~~~~~~^^^^^^
File "/usr/lib/python3.13/site-packages/zenlib/util/dict_check.py", line 36, in _contains
return func(*args, **kwargs)
File "/usr/lib/python3.13/site-packages/ugrd/fs/mounts.py", line 953, in check_mounts
_validate_host_mount(self, mount, "/" if mount_name == "root" else None)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/site-packages/ugrd/fs/mounts.py", line 909, in _validate_host_mount
host_source_dev = _resolve_dev(self, self["_mounts"][destination_path]["device"])
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
KeyError: '/rootfs'Code: Select all
[mounts.rootfs]
# The label of the root filesystem, a uuid or partuuid could be used instead
label = "rootfs"you shouldn't need to set mounts like that, but it will validate mounts against your current mounts, so unless you have something mounted at "/rootfs", it won't pass validation.leyvi wrote:I'm guessing this is where the issue is; I'm trying to mount the root filesystem, which should be named /dev/mapper/rootfs, can I give it that path instead of a label?Code: Select all
[mounts.rootfs] # The label of the root filesystem, a uuid or partuuid could be used instead label = "rootfs"
Completely missed this before, very interesting... thanks pietinger!pietinger wrote:leyvi,
with Gentoo Linux you have always two options:
1. Create something with "automagic" routines (where you don't know who does what and how),or
2. create something yourself with the tools you know, so you know how you created it.![]()
This statement is correct ... for the first case.zen_desu wrote:[...] I prefer not to use UKIs that much because you need systemd tools/parts to make them work (at this point in time)
If you google "linux uki" you will get these three links on the first results page:
a) https://wiki.archlinux.org/title/Unified_kernel_image
->I emphasize: "It is the combination of a UEFI boot stub program like systemd-stub."A unified kernel image (UKI) is a single executable which can be booted directly from UEFI firmware, or automatically sourced by boot loaders with little or no configuration. It is the combination of a UEFI boot stub program like systemd-stub(7), a Linux kernel image, an initramfs, and further resources in a single UEFI PE file.
b) https://wiki.gentoo.org/wiki/Unified_kernel_image
->[...]A unified kernel image (UKI) is a single executable which can be booted directly from UEFI firmware, or automatically sourced by boot-loaders with little or no configuration.
A unified kernel image allows to incorporate all or a subset of the following:
an EFI stub loader like systemd-stub,
I emphasize: "an EFI stub loader like systemd-stub"
c) https://uapi-group.org/specifications/s ... nel_image/
->...A Unified Kernel Image (UKI) is a combination of an UEFI boot stub program, a Linux kernel image, an optional initrd, and further resources in a single UEFI PE file. [...]
systemd-stub provides the reference implementation of the stub.![]()
The plain truth is that every Linux kernel already has a EFI stub (if you activate it in the kernel configuration (*) - this is the default in all our Gentoo distribution kernels) and you don't need this systemd-stub at all ... as long as you do everything yourself ... it's just that many "automagic" routines were written by people who only work with systemd ...![]()
*) =>The <Help> of this option says it clearly:Code: Select all
Processor type and features ---> [*] EFI stub supportYes, I have an "UKI" myself, even if it cannot be described as such according to the "academic" interpretation — because it does not have a systemd stub. I have a signed (for SecureBoot) kernel image that contains an embedded initramfs, the kernel command line, and the microcode for the CPU (and also all needed firmware binaries). Even though I use a monolithic kernel (= without module support because everything is configured as built-in), this would not be a mandatory requirement. The only requirement for such an image is that you configure the kernel modules that the kernel needs to address its root partition as built-in (this means you can configure the graphics card modules or sound modules as <M>odule). Then you no longer have to take this "detour" via: build the kernel, install modules, build an initramfs, rebuild the kernel. All you need to do is build the kernel and install the modules. If you even configure a monolithic kernel (like I do), all you need to do is: BUILD KERNEL. (The end, amen, done).This kernel feature allows a bzImage to be loaded directly by EFI firmware without the use of a bootloader.
And yes, creating your own initramfs is not that difficult:
https://wiki.gentoo.org/wiki/User:Pieti ... s_Overview
(Like @zen_desu, I also have instructions on how to insert an existing external CPIO initramfs into the kernel:
https://wiki.gentoo.org/wiki/User:Pieti ... IO_archive )
I use an activated IMA (ima_appraise=enforce) with signed hashes on my notebook, where I have to load the certificate and policy into the kernel. Look how short the init routine is for this: https://forums.gentoo.org/viewtopic-t-1159297.html
Of course, it takes a considerable amount of time to do everything yourself... but in return, you know what's going on in your system... and you also learn a lot... which you can then use to understand automatic routines.
Thanks, no errors at runtime, gotta see if it boots...zen_desu wrote:you shouldn't need to set mounts like that, but it will validate mounts against your current mounts, so unless you have something mounted at "/rootfs", it won't pass validation.leyvi wrote:I'm guessing this is where the issue is; I'm trying to mount the root filesystem, which should be named /dev/mapper/rootfs, can I give it that path instead of a label?Code: Select all
[mounts.rootfs] # The label of the root filesystem, a uuid or partuuid could be used instead label = "rootfs"
Your root mount should be automatically detected, so I think the default config should be mostly fine. Users can also specify paths to be automatically processed using "auto_mounts = ['/patha', '/pathb']" This is mostly useful if you want something like /boot to be mounted or have a keyfile device that needs to be mounted before cryptsetup runs.
If you need to set special config for a particular cryptsetup device (adding a key file/headers/other options) you can set it under [cryptsetup.<devname>] so in your case, [cryptsetup.rootfs]
The "mounts" are specifically for things to be mounted in the initramfs stage, and the root mount is internally called "[mounts.root]" and uses the path "/target_rootfs" in the initramfs: https://github.com/desultory/ugrd/blob/ ... ml#L76-L79
Unless you disable hostonly mode, or set "autodetect_root = false", it should automatically get this info using the current "/" mount: https://github.com/desultory/ugrd/blob/ ... ts.py#L715
which HID modules did you need to build in?leyvi wrote:Well, it almost got there...
First try there were some issues with the HID modules, so I built those into the kernel (the ones that were giving error messages) and the errors went away.
Everything looks fine, that is, it prompts me for the disk's passphrase, but after I type it and press <Enter>, nothing happens, no matter how long I wait.
What now?
I can't check dmesg since I doubt that the root filesystem got mounted...