I'm here because I ran into the same problem, found this question via Google, and have some information to add. I am attempting to auto-unlock a LUKS drive without having type a passphrase.
First, I edited /etc/crypttab and changed its entry to the following:
sda3_crypt UUID=2d661ff8-d6a8-49c9-ae96-4d6e234bffe2 /dev/zero luks,discard,keyfile-size=32
Then, I added a new key using the following command:
sudo cryptsetup luksAddKey --new-keyfile-size 32 /dev/sda3 /dev/zero
Finally, I ran update-initramfs which produced the following output:
$ sudo update-initramfs -u
update-initramfs: Generating /boot/initrd.img-6.0.0-2-amd64
cryptsetup: WARNING: sda3_crypt: key file /dev/zero has insecure ownership, see
/usr/share/doc/cryptsetup/README.Debian.gz.
cryptsetup: WARNING: Skipping root target sda3_crypt: uses a key file
This already seemed suspicious, but I rebooted anyway. Unfortunately, these actions made the system unbootable:
Gave up waiting for suspend/resume device
Gave up waiting for root file system device: Common problems:
- Boot args (cat /proc/cmdline)
- Check rootdelay= (did the system wait long enough?)
- Missing modules (cat /proc/modules; ls /dev)
ALERT! /dev/mapper/legend--vg-root does not exist. Dropping to a shell!
BusyBox v1.35.0 (Debian 1: 1.135.0-2) built-in shell (ash)
Enter 'help' for a list of built-in commands.
(initramfs) cat /etc/crypttab
cat: can't open '/etc/crypttab': No such file or directory
I was able to successfully boot the system again by entering the following commands at the BusyBox prompt:
cryptsetup luksOpen --key-file /dev/zero --keyfile-size 32 /dev/sda3 sda3_crypt
exit
The original question still stands though: why is /etc/crypttab not available in the initramfs?
Update
After more research, I can now finally answer the original question: /etc/crypttab is not present in initramfs because the default unlock script does not use that location; it uses /cryptroot/crypttab instead.
To make /etc/crypttab available as /cryptroot/crypttab in initramfs, create the following script in the /etc/initramfs-tools/hooks directory and make it executable:
#!/bin/sh
cp /etc/crypttab "${DESTDIR}/cryptroot/crypttab"
exit 0
Finally, let it be noted that using auto-unlocking LUKS devices by using empty passphrases defeats the purpose of encryption. It is just as insecure as using no encryption at all.