Auto mount usb key encrypted

Hi,

I’ve been partially successful in automounting encrypted veracrypt volume

  1. MOUNT AT BOOT - VERACRYPT LOCAL HDD

The following works perfectly.

cryptab
veracrypt1 PARTLABEL=vcsda5 /dev/null noauto,tcrypt-veracrypt,tcrypt-hidden,tcrypt-keyfile=/keyfile.bin

fstab
/dev/mapper/veracrypt1 /media/veracrypt1 btrfs defaults,noatime,space_cache,autodefrag,compress=zstd:10 0 2

  1. AUTO MOUNT NOT AT BOOT - VERACRYPT USB KEY

I followed instructions at this link but its not working fully.
fstab - ArchWiki … filesystem

cryptab
veracrypt2 PARTLABEL=usb4gb /dev/null noauto,tcrypt-veracrypt,tcrypt-hidden,tcrypt-keyfile=/keyfile.bin

The cryptab entry with “noauto” works fine. The usb key encryption is opened whether usb key is present at boot time or when inserting after boot time.
I can manually mount this with “sudo mount /dev/mapper/veracrypt2 /media/veracrypt2”

fstab
/dev/mapper/veracrypt2 /media/veracrypt2 btrfs noauto,x-systemd.automount,x-systemd.mount-timeout=5,defaults,noatime,space_cache,autodefrag,compress=zstd:10 0 2

This fstab entry is the problem. It just doesn’t work at all. It actually makes thunar hang and system unstable.

I’ve tried combinations of
noauto,x-systemd.automount,x-systemd.mount-timeout=5
nofail,x-systemd.device-timeout=1ms,noauto,x-systemd.automount
nofail,x-systemd.device-timeout=1ms

What is the correct fstab entry to use so that the usb key auto mounts when inserted not at boot time.

Thanks in advance.

You think can achieve your goal by using a mount unit and the complementary automount unit

3 Likes