Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ugrd reporting RuntimeError: Unknown device mapper device ty
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
vrghost
n00b
n00b


Joined: 03 Oct 2003
Posts: 54
Location: London

PostPosted: Sat Nov 16, 2024 8:31 pm    Post subject: ugrd reporting RuntimeError: Unknown device mapper device ty Reply with quote

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
View user's profile Send private message
zen_desu
n00b
n00b


Joined: 25 Oct 2024
Posts: 19

PostPosted: Sat Nov 16, 2024 10:22 pm    Post subject: Reply with quote

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
View user's profile Send private message
vrghost
n00b
n00b


Joined: 03 Oct 2003
Posts: 54
Location: London

PostPosted: Sat Nov 16, 2024 10:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
zen_desu
n00b
n00b


Joined: 25 Oct 2024
Posts: 19

PostPosted: Sat Nov 16, 2024 11:02 pm    Post subject: Reply with quote

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
View user's profile Send private message
vrghost
n00b
n00b


Joined: 03 Oct 2003
Posts: 54
Location: London

PostPosted: Sat Nov 16, 2024 11:46 pm    Post subject: Reply with quote

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
View user's profile Send private message
zen_desu
n00b
n00b


Joined: 25 Oct 2024
Posts: 19

PostPosted: Sat Nov 16, 2024 11:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware 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