Score:0

Installing Ubuntu 21.04 with LVM on LUKS2 with integrity check returns errors when generating initramfs

br flag

TL;DR: I'm unable to generate initramfs after encrypting volumes with LUKS2 with integrity option and LVM on top of those volumes:

cryptsetup: ERROR: first: Source mismatch
cryptsetup: WARNING: target 'first_dif' not found in /etc/crypttab
cryptsetup: ERROR: second: Source mismatch
cryptsetup: WARNING: target 'second_dif' not found in /etc/crypttab
cryptsetup: WARNING: Couldn't determine cipher modules to load for first 
    (kernel crypto API format isn't supported yet)
cryptsetup: WARNING: Couldn't determine cipher modules to load for second 
    (kernel crypto API format isn't supported yet)
root@ubuntu:/# cat /etc/crypttab
first UUID=857883dc-7f1d-470f-9ed7-a06f3624b677 none luks,discard
second UUID=4ca53199-307f-4503-a042-c6bb62ea5a47 none luks,discard
root@ubuntu:/# fdisk -l

Disk /dev/nvme0n1: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Samsung SSD 970 EVO Plus 500GB          
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 8DF308CC-B48D-4834-8B1F-EDE77A831CC7

Device           Start       End   Sectors   Size Type
/dev/nvme0n1p1    2048   1050623   1048576   512M EFI System
/dev/nvme0n1p2 1050624   2099199   1048576   512M Linux filesystem
/dev/nvme0n1p3 2099200 976773134 974673935 464.8G unknown


Disk /dev/nvme1n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: SAMSUNG MZVLB512HBJQ-000H1              
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 03D068B8-37FA-4B26-A8BF-A67455D9AED3

Device         Start        End    Sectors   Size Type
/dev/nvme1n1p1  2048 1000215182 1000213135 476.9G unknown


Disk /dev/mapper/first_dif: 437.35 GiB, 469598490624 bytes, 917184552 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/first: 437.35 GiB, 469598490624 bytes, 917184552 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/second_dif: 448.81 GiB, 481905954816 bytes, 941222568 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/second: 448.81 GiB, 481905954816 bytes, 941222568 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/system-swap: 36 GiB, 38654705664 bytes, 75497472 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/system-root: 850.15 GiB, 912844128256 bytes, 1782898688 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

And here's full info on how I installed the system:

My disk layout is this (unknown to fdisk is 8309, Linux LUKS):

root@ubuntu:~# fdisk -l
Disk /dev/nvme0n1: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Samsung SSD 970 EVO Plus 500GB          
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 8DF308CC-B48D-4834-8B1F-EDE77A831CC7

Device           Start       End   Sectors   Size Type
/dev/nvme0n1p1    2048   1050623   1048576   512M EFI System
/dev/nvme0n1p2 1050624   2099199   1048576   512M Linux filesystem
/dev/nvme0n1p3 2099200 976773134 974673935 464.8G unknown


Disk /dev/nvme1n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: SAMSUNG MZVLB512HBJQ-000H1              
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 03D068B8-37FA-4B26-A8BF-A67455D9AED3

Device         Start        End    Sectors   Size Type
/dev/nvme1n1p1  2048 1000215182 1000213135 476.9G unknown

I have used this command to create a LUKS2 volume and used it for 2 volumes: /dev/nvme0n1p3 and /dev/nvme1n1p1

cryptsetup luksFormat --type luks2 /dev/nvme0n1p3 --integrity hmac-sha256
cryptsetup luksFormat --type luks2 /dev/nvme1n1p1 --integrity hmac-sha256

Then I opened the volumes:

cryptsetup luksOpen /dev/nvme0n1p3 first
cryptsetup luksOpen /dev/nvme1n1p1 second

cryptsetup created 4 volumes:

Disk /dev/mapper/first_dif: 437.35 GiB, 469598490624 bytes, 917184552 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/first: 437.35 GiB, 469598490624 bytes, 917184552 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/second_dif: 448.81 GiB, 481905954816 bytes, 941222568 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/second: 448.81 GiB, 481905954816 bytes, 941222568 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Then I created 2 physical volumes, added them to the volume group, created 2 logical volumes swap and root:

root@ubuntu:~# pvs
  PV                 VG     Fmt  Attr PSize    PFree
  /dev/mapper/first  system lvm2 a--   437.34g    0 
  /dev/mapper/second system lvm2 a--  <448.81g    0 
root@ubuntu:~# vgs
  VG     #PV #LV #SN Attr   VSize   VFree
  system   2   2   0 wz--n- 886.15g    0 
root@ubuntu:~# lvs
  LV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root system -wi-ao---- 850.15g                                                    
  swap system -wi-ao----  36.00g

After that I formatted the partitions and installed Ubuntu 21.04 through graphical installer (no errors occured during the installation):

/dev/nvme0n1p1 as EFI, FAT32
/dev/nvme0n1p2 as /boot, ext4
/dev/system/root as /, ext4
/dev/system/swap as swap

Then I did this and chrooted into /mnt:

mount /dev/system/root /mnt
mount /dev/nvme0n1p2 /mnt/boot
mount /dev/nvme0n1p1 /mnt/boot/efi
mount --bind /dev /mnt/dev
mount --bind /run/lvm /mnt/run/lvm

After chrooting:

mount -t proc proc /proc
mount -t sysfs sys /sys 
mount -t devpts devpts /dev/pts

Then I looked up the UUIDs of those LUKS partitions:

root@ubuntu:~# blkid | grep LUKS
/dev/nvme0n1p3: UUID="857883dc-7f1d-470f-9ed7-a06f3624b677" TYPE="crypto_LUKS" PARTLABEL="Linux LUKS" PARTUUID="ca894a49-5867-4a3a-bff1-fc1a0affaa18"
/dev/nvme1n1p1: UUID="4ca53199-307f-4503-a042-c6bb62ea5a47" TYPE="crypto_LUKS" PARTLABEL="Linux LUKS" PARTUUID="35ce7fcd-2c76-45cf-884a-6c9a8a2439ef"

And created the following /etc/crypttab:

first UUID=857883dc-7f1d-470f-9ed7-a06f3624b677 none luks,discard
second UUID=4ca53199-307f-4503-a042-c6bb62ea5a47 none luks,discard

And after all this the update-initramfs does not work:

root@ubuntu:/# update-initramfs -u -k all
update-initramfs: Generating /boot/initrd.img-5.11.0-25-generic
cryptsetup: ERROR: first: Source mismatch
cryptsetup: WARNING: target 'first_dif' not found in /etc/crypttab
cryptsetup: ERROR: second: Source mismatch
cryptsetup: WARNING: target 'second_dif' not found in /etc/crypttab
cryptsetup: WARNING: Couldn't determine cipher modules to load for first 
    (kernel crypto API format isn't supported yet)
cryptsetup: WARNING: Couldn't determine cipher modules to load for second 
    (kernel crypto API format isn't supported yet)

What should I do in order to fix this?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.