View previous topic :: View next topic |
Author |
Message |
vrghost n00b
Joined: 03 Oct 2003 Posts: 56 Location: London
|
Posted: Sat Nov 16, 2024 8:31 pm Post subject: ugrd reporting RuntimeError: Unknown device mapper device ty |
|
|
Currently trying to move to a encrypted root fs, following this article:
https://wiki.gentoo.org/wiki/Full_Disk_Encryption_From_Scratch
So far, I have managed to create the volume, encrypt it, reboot the server using live CD, mount the encrypted volume using the key stored on the efi volume, then mounted everything, chrooted into the environment and at the stage of trying to run ugrd, but I am getting the following error message:
Code: |
DEBUG | ugrd.InitramfsGenerator | [root] Device mapper info: {'major': '253', 'minor': '0', 'holders': [], 'slaves': ['nvme0n1p7'], 'uuid': 'CRYP
T-LUKS2-2713385e5e674394964d3814c52a425f-root', 'name': 'root'}
Device config: {'partuuid': '327a9d8a-1990-4ae7-b6b9-0145dd51fb03'}
INFO | ugrd | Dumping config dict:
ERROR | ugrd | Unknown device mapper device type: None
Traceback (most recent call last):
File "/usr/lib/python3.12/site-packages/ugrd/main.py", line 66, in main
generator.build()
File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 76, in build
self.run_build()
File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 207, in run_build
self.run_hook(task, force_exclude=True)
File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 126, in run_hook
if function_output := self.run_func(function, *args, **kwargs):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 92, in run_func
if function_output := function(self):
^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/zenlib/util/dict_check.py", line 31, in _contains
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/zenlib/util/dict_check.py", line 31, in _contains
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/ugrd/fs/mounts.py", line 415, in autodetect_root_dm
_autodetect_dm(self, '/')
File "/usr/lib/python3.12/site-packages/zenlib/util/dict_check.py", line 31, in _contains
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/ugrd/fs/mounts.py", line 382, in _autodetect_dm
raise RuntimeError("Unknown device mapper device type: %s" % blkid_info.get('type'))
RuntimeError: Unknown device mapper device type: None
|
Full debug log can be found at
https://bpa.st/HXNQ
And the config.toml
/etc/ugrd/config.toml
Looking at blkid
Code: |
/dev/sda3: BLOCK_SIZE="2048" LABEL="Gentoo-amd64-20241103" TYPE="hfsplus" PARTLABEL="HFSPLUS" PARTUUID="f2196140-2caf-4dc9-95d2-d046c3259d84"
/dev/nvme0n1p5: UUID="5b60094d-fadd-4116-954b-8544ee0e7280" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="5bb7f630-99aa-4de1-b0ce-82caf81ca76e"
/dev/nvme0n1p3: BLOCK_SIZE="512" UUID="4E42EFAC42EF974D" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="b2c07de3-3012-425f-9691-1e249ef480c8"
/dev/nvme0n1p1: UUID="6EA6-1714" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="Basic data partition" PARTUUID="28907a67-617d-44e7-92b3-ec2627aab188"
/dev/nvme0n1p6: UUID="254ea3a9-0131-465d-bf89-7def5aa063e2" TYPE="swap" PARTUUID="cbb85061-5429-49f3-98f6-2a724a4f8767"
/dev/nvme0n1p4: BLOCK_SIZE="512" UUID="78D493E8D493A742" TYPE="ntfs" PARTUUID="4d23f5b8-743c-40a2-beb1-4a4f8a9a271b"
/dev/loop0: BLOCK_SIZE="131072" TYPE="squashfs"
/dev/mapper/root: LABEL="rootfs" UUID="f84e336d-06d5-4eba-9278-330861fb604b" UUID_SUB="3ab52124-63e3-41ea-b0ce-63e184fb90b7" BLOCK_SIZE="4096" TYPE="btrfs"
/dev/sda2: SEC_TYPE="msdos" UUID="4B0E-13DB" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI boot partition" PARTUUID="f2196140-2caf-4dc9-95d3-d046c3259d84"
/dev/nvme0n1p7: PARTUUID="327a9d8a-1990-4ae7-b6b9-0145dd51fb03"
/dev/nvme0n1p2: PARTLABEL="Microsoft reserved partition" PARTUUID="406656e7-33e7-4955-bc66-5c47eb17a002"
/dev/sda4: PARTLABEL="Gap1" PARTUUID="f2196140-2caf-4dc9-95d5-d046c3259d84"
/dev/sda1: PARTLABEL="Gap0" PARTUUID="f2196140-2caf-4dc9-95d0-d046c3259d8
|
/dev/nvme0n1p7 does not have a type; this is where the encrypted data for /dev/mapper/root is; not certain if that is the issue, but should it have a type, or is used looking at the wrong device? |
|
Back to top |
|
|
zen_desu n00b
Joined: 25 Oct 2024 Posts: 19
|
Posted: Sat Nov 16, 2024 10:22 pm Post subject: |
|
|
Can you share your config?
blkid won't be able to detect the device type if the LUKS headers are detached.
If you have detached headers, you must define that in the config, and the name for the cryptsetup entry should match the name it's opened/mapped to.
Here's an example for detached headers:
https://github.com/desultory/ugrd/blob/main/examples/detached_headers.toml
You can define the mountpoint used for the external storage which contains the header file under auto_mounts. _________________ µgRD dev
Wiki writer |
|
Back to top |
|
|
vrghost n00b
Joined: 03 Oct 2003 Posts: 56 Location: London
|
Posted: Sat Nov 16, 2024 10:47 pm Post subject: |
|
|
Sorry zen_desu, did not check the above link, seems like it is broken
Here is my config file. Tried to add efi as a mount point to ensure it mounts it for the key header
[URL] https://bpa.st/NAPA[/url]
But not certain I've understood how ugrd correctly, can I just define a new mount by adding:
Code: |
auto_mounts = ['/efi']
[mounts.efi]
type = "vfat"
uuid = "6EA6-1714"
|
And is it even the right thing to do, my expectation was to get to the header_file
Code: |
[cryptsetup.root]
# The UUID of the encrypted volume, mounted at /dev/mapper/root
uuid = "327a9d8a-1990-4ae7-b6b9-0145dd51fb03"
header_file = "/efi/lheader/luks_header.img"
|
|
|
Back to top |
|
|
zen_desu n00b
Joined: 25 Oct 2024 Posts: 19
|
Posted: Sat Nov 16, 2024 11:02 pm Post subject: |
|
|
I would not set the kernel version in the config file unless you can't pass the --kver arg or it's just there for testing.
If you specify "/efi" in auto_mounts, it will automatically make the mount config for whatever is mounted at /efi, so the manual config is not required.
I think that 'label = "rootfs"' is not doing anything, you could have that specified under a mount config, but it will detect your root config by default.
For your "cryptsetup.root" config section, you do not need to define the uuid or partuuid, it will detect it, but that uuid you have defined seems to be the partuuid, so that is an issue.
Code: | modules = [
"ugrd.kmod.standard_mask",
"ugrd.crypto.cryptsetup",
]
# specify the output directory for the created image
out_dir = "/usr/src/initramfs"
# Optionally supply a kernel version, uses the current kernel version if not specified
#kernel_version = "linux-6.6.58-gentoo-r1"
# lspci based detection is usually helpful
kmod_autodetect_lspci = true
auto_mounts = ['/efi'] # Automatically create mount config for /efi on the host
# Maps the root LUKS device to /dev/mapper/root
[cryptsetup.root]
# The header must be specified since it's detached
header_file = "/efi/lheader/luks_header.img"
|
I think this config should work as long as you pass --kver as a cmdline arg (installkernel will do this for you) _________________ µgRD dev
Wiki writer |
|
Back to top |
|
|
vrghost n00b
Joined: 03 Oct 2003 Posts: 56 Location: London
|
Posted: Sat Nov 16, 2024 11:46 pm Post subject: |
|
|
Much appreciated @zen_desu
Think I followed all your suggestions
Code: |
# The initramfs will be built in /tmp/initramfs if "build_dir" is not specified not specified
out_dir = "/usr/src/initramfs"
# Optionally supply a kernel version, uses the current kernel version if not specified
kernel_version = "linux-6.6.58-gentoo-r1"
# lspci based detection is usually helpful
kmod_autodetect_lspci = true
# lsmod detection can be helpful, but can bring in unnecessary modules
#kmod_autodetect_lsmod = true
# Wait a few seconds for storage to settle after modules are loaded if external or slow storage is used
#mount_wait = true
#mount_timeout = 3
# The location of the gpg public key, if using a smartcard and gpg encrypted keyfile
#sc_public_key = "/etc/ugrd/pubkey.gpg"
auto_mounts = ['/efi'] # Automatically create mount config for /boot on the host
# Optionally specify the root mountpoint information manually
#[mounts.root]
# The label of the root filesystem, a uuid or partuuid could be used instead
label = "rootfs"
# This is necessary if the keyfile is on another device.
# The keyfile could be added as a dependency. if it's on the same device.
#[mounts.efi]
#type = "vfat"
#uuid = "6EA6-1714"
# If the root is a LUKS volume, specify the LUKS volume information
[cryptsetup.root]
# The UUID of the encrypted volume, mounted at /dev/mapper/root
#uuid = "327a9d8a-1990-4ae7-b6b9-0145dd51fb03"
header_file = "/efi/lheader/luks_header.img"
# If a GPG encrypted key file is used, the key_type must be set to gpg.
#key_type = "gpg"
# The key file must either be included as a dependency, or it must be under an external mountpoint.
#key_file = "/efi/lheader/rootfs.luks.gpg"
|
Still same result, still the error message
Code: |
ERROR | Unknown device mapper device type: None
Traceback (most recent call last):
File "/usr/lib/python3.12/site-packages/ugrd/main.py", line 66, in main
generator.build()
File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 76, in build
self.run_build()
File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 207, in run_build
self.run_hook(task, force_exclude=True)
File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 126, in run_hook
if function_output := self.run_func(function, *args, **kwargs):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 92, in run_func
if function_output := function(self):
^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/zenlib/util/dict_check.py", line 31, in _contains
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/zenlib/util/dict_check.py", line 31, in _contains
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/ugrd/fs/mounts.py", line 415, in autodetect_root_dm
_autodetect_dm(self, '/')
File "/usr/lib/python3.12/site-packages/zenlib/util/dict_check.py", line 31, in _contains
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/ugrd/fs/mounts.py", line 382, in _autodetect_dm
raise RuntimeError("Unknown device mapper device type: %s" % blkid_info.get('type'))
RuntimeError: Unknown device mapper device type: None |
|
|
Back to top |
|
|
zen_desu n00b
Joined: 25 Oct 2024 Posts: 19
|
Posted: Sat Nov 16, 2024 11:54 pm Post subject: |
|
|
vrghost wrote: | Much appreciated @zen_desu
Still same result, still the error message
Code: |
ERROR | Unknown device mapper device type: None
Traceback (most recent call last):
File "/usr/lib/python3.12/site-packages/ugrd/main.py", line 66, in main
generator.build()
File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 76, in build
self.run_build()
File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 207, in run_build
self.run_hook(task, force_exclude=True)
File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 126, in run_hook
if function_output := self.run_func(function, *args, **kwargs):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 92, in run_func
if function_output := function(self):
^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/zenlib/util/dict_check.py", line 31, in _contains
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/zenlib/util/dict_check.py", line 31, in _contains
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/ugrd/fs/mounts.py", line 415, in autodetect_root_dm
_autodetect_dm(self, '/')
File "/usr/lib/python3.12/site-packages/zenlib/util/dict_check.py", line 31, in _contains
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/ugrd/fs/mounts.py", line 382, in _autodetect_dm
raise RuntimeError("Unknown device mapper device type: %s" % blkid_info.get('type'))
RuntimeError: Unknown device mapper device type: None |
|
Can you share the full output? https://github.com/desultory/ugrd/blob/1.24.2/src/ugrd/fs/mounts.py#L375-L382
it's throwing that error because you have detached headers, so blkid doesn't report partition type. The only way for it to treat it as a luks partition is if you have cryptsetup config defined with the name found in the virtual block device info, like "/sys/block/dm-x/dm/name". That name must match the name in the config.
The error message there could be improved, this typically happens for detached headers with a mismatched name.
https://github.com/desultory/ugrd/pull/122 _________________ µgRD dev
Wiki writer |
|
Back to top |
|
|
vrghost n00b
Joined: 03 Oct 2003 Posts: 56 Location: London
|
Posted: Sun Nov 17, 2024 8:08 am Post subject: |
|
|
Good morning zen_desu
Sorry, I went to sleep. Thank you so very much for this help, and guessing that was your PR to ugrd.
Think I got one step forward, or one step back, if the issue is that it just can't figure out what to do with the rootfs mount without the hederfile
Here is the full output (without change)
https://bpa.st/BUUA
I was trying to mount efi rather than boot, but I don't know enough about ugrd.
Am I understand correctly that when you add
Code: | auto_mounts = ['/efi'] |
Or in the original one
Code: | auto_mounts = ['/boot'] |
Are we telling ugrd to mount it when building initramfs OR are we telling initramfs to mount it during its load/boot?
Same with the three lines:
Code: |
[mounts.efi]
type = "vfat"
uuid = "6EA6-1714"
|
Are we telling ugrd or initramfs to mount it
Also where would I put my header_file, and do I put root before or after efi (as initramfs presumably need to mount root then efi to complete the boot, but needs efi to get hold of the key file open the encrypted file
I tried the above, moving header_dfile to the section of mounts.efi, but then it seems to read it as a mount parameter
Quote: |
Traceback (most recent call last):
File "/usr/lib/python-exec/python3.12/ugrd", line 8, in <module>
sys.exit(main())
^^^^^^
File "/usr/lib/python3.12/site-packages/ugrd/main.py", line 63, in main
generator = InitramfsGenerator(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/zenlib/logging/loggify.py", line 50, in __init__
super().__init__(*args, **kwargs)
File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 27, in __init__
self.load_config(config) # The user config is loaded over the base config, clobbering kwargs
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 50, in load_config
self[config] = value
~~~~^^^^^^^^
File "/usr/lib/python3.12/site-packages/ugrd/initramfs_generator.py", line 55, in __setitem__
self.config_dict[key] = value
~~~~~~~~~~~~~~~~^^^^^
File "/usr/lib/python3.12/site-packages/ugrd/initramfs_dict.py", line 62, in __setitem__
return self.handle_parameter(key, value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/ugrd/initramfs_dict.py", line 112, in handle_parameter
return handle_plural(func)(self, value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/zenlib/util/handle_plural.py", line 35, in wrapper
function(self, *(other_args + (key, value,)))
File "/usr/lib/python3.12/site-packages/ugrd/fs/mounts.py", line 110, in _process_mounts_multi
_process_mount(self, mount_name, mount_config)
File "/usr/lib/python3.12/site-packages/ugrd/fs/mounts.py", line 69, in _process_mount
_validate_mount_config(self, mount_name, mount_config)
File "/usr/lib/python3.12/site-packages/zenlib/util/dict_check.py", line 31, in _contains
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/ugrd/fs/mounts.py", line 47, in _validate_mount_config
raise ValueError("Invalid parameter in mount: %s" % parameter)
ValueError: Invalid parameter in mount: header_file
|
|
|
Back to top |
|
|
vrghost n00b
Joined: 03 Oct 2003 Posts: 56 Location: London
|
Posted: Sun Nov 17, 2024 8:44 am Post subject: |
|
|
@zen_desu
Tried to understand your comment:
Quote: | It's throwing that error because you have detached headers, so blkid doesn't report partition type. The only way for it to treat it as a luks partition is if you have cryptsetup config defined with the name found in the virtual block device info, like "/sys/block/dm-x/dm/name". That name must match the name in the config. |
So looking at the device
Code: | (chroot) livecd /efi/lheader # ls /sys/block/dm-0/
alignment_offset capability discard_alignment dm events_async ext_range holders integrity power range ro slaves subsystem uevent
bdi dev diskseq events events_poll_msecs hidden inflight partscan queue removable size stat trace |
That SHOULD be the decrypted device (mounted as /dev/mapper/root), but may have misunderstood things
How would I confirm the name is the same as what is configured with cryptsetup?
Think I named the FS on the device roofs (because the instructions told me to), is that the issue?
Quote: | mkfs.btrfs -L rootfs /dev/mapper/root | [/code] |
|
Back to top |
|
|
|
|
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
|
|