What is the recommended approach for automounting and decrypting a secondary encrypted drive?

I’ve previously described how I set this up: here.

The AI gets it mostly right, but does have some errors, and an unhealthy obsession with forced “one-liners”. Notably:

  • You should mkdir and set correct permissions on the mount point first (e.g. /mnt/wdblue)
  • 512 bytes is unnecessarily small for a crypt keyfile
  • Hiding the crypt keyfile away in /etc/cryptsetup-keys/ is unnecessary and invites forgetting about it (if/when you reinstall OS, you’ll want to remember to keep the keyfile / bring it along to new install). Better to put it directly in / or your home directory.
  • luks,discard is optional and missing in my instructions, has benefits and downsides
  • x-systemd.automount will delay mounting until you access the drive, undesirable IMO
  • The last column of a btrfs fstab should be 0, not 2
  • I don’t think there’s any need to run mkinitcpio for this. Wouldn’t hurt anything though.