Comment 4 for bug 443980

Christoph (christoph-thomas) wrote :

Hi,
with my account I can't select 'wishlist', so I changed the status to 'fix released'.

The good news, now I know what happens and there is some fix for the timing problem. If I get it correct, this occurs because there is a dirty trick in libdevmapper. It seems, that in the first step /dev/dm-1 is created ant then moved to /dev/mapper/yourcryptdevicename. If you use UUID=xyz in your /etc/fstab, mountall sees UUID=XYZ connected to /dev/dm-1 and tries to fsck /dev/dm-1. Now fsck returns an error because /dev/dm-1 doesen't exist anymore.

The (dirty) fix is to use /dev/mapper/yourcryptdevicename instead of UUID=xyz in your /etc/fstab.

For the part with the two steps ('early' and 'init') I prefer actually my own script in /usr/share/initramfs-tools/scripts/local-bottom/<_usbkey>. Since this is part of the initrd.img it has some advantages (dont forget to recreate your initrd.img, after creating or changing this file). My script looks like:

#!/bin/sh

set -e

# Hook for mounting encrypted usb stic, change usbdev in ... and USBKEY to reflect your environment

for ask_passphrase in first second third last ; do

 for in usb-0000_Removable_Drive_20112824060840760045-0:0-part5 \
                usb-0000_Removable_Drive_20031424060835920030-0:0-part5 ; do

 if [ -L /dev/disk/by-id/$usbdev ]; then
  if [ -r /dev/mapper/USBKEY ]; then
   /sbin/blkid /dev/mapper/USBKEY && exit 0
   cryptsetup remove USBKEY
   echo "wrong passphrase $ask_passphrase try"
  fi
  cryptsetup create USBKEY /dev/disk/by-id/$usbdev --readonly --tries 1
  sleep 0.2
 fi

 done
done