I try to generate a initrd that contain in /cryptroot/crypttab the name of the LUKS device that I used and not the UUID.
I don't understand the function crypttab_print_entry() of /usr/share/initramfs-tools/hooks/cryptroot, more specifically this part:
if _resolve_device "$CRYPTTAB_SOURCE"; then if [ "$(dmsetup info -c --noheadings -o devnos_used -- "$CRYPTTAB_NAME" 2>/dev/null)" != "$MAJ:$MIN" ]; then cryptsetup_message "ERROR: $CRYPTTAB_NAME: Source mismatch" elif sourcename="$(dmsetup info -c --noheadings -o mangled_name -j "$MAJ" -m "$MIN" 2>/dev/null)" && [ -b "/dev/mapper/$sourcename" ]; then # for mapped sources, use the dm name as the lvm # local-block script doesn't work with UUIDs (#902943) _CRYPTTAB_SOURCE="/dev/mapper/$sourcename" elif uuid="$(_device_uuid "$DEV")"; then # otherwise, use its UUID if possible (eg. for LUKS) _CRYPTTAB_SOURCE="UUID=$uuid" fi # on failure _resolve_device() prints a warning and we try our # luck with the unchanged _CRYPTTAB_SOURCE value fi
The first dmsetup info
verify the MAJ and MIN number of the device, it return OK but the second one when executed with the same MAJ and MIN return no device.What the difference between those 2 dmsetup info
?
From the comment of the function, I can not understand if for LUKS partition it's de default behavior to use the UUID or the device name should work.
In /etc/crypttab, I have nvme0n1p7_crypt /dev/nvme0n1p7 none luks,discard
.I would like to have the same in /cryptroot/crypttab of the initrd but for now I have nvme0n1p7_crypt UUID=xxxx none luks,discard
Best regards
Alexandre