My laptop is a a Dell Precision 5560 running Ubuntu 20.04.3. It has LUKS disk encryption set up on it.
About a week ago, it completely froze (I'm not sure why) such that my only recourse to get it working again was to do a hard shut down, i.e. by holding down the power button for 10 seconds. After I did this, it seems to have corrupted something, because now when I boot, it momentarily shows the following error:
cryptsetup: Bad password or options?
and after a few seconds this changes to:
cryptsetup: ERROR; system: maximum number of tries exceeded
After a further 30 seconds or so, it drops me into initramfs
. If I type exit
here it shows a few error messages, notably ALERT! /dev/mapper/ubuntu-root does not exist. Dropping to a shell!
.
Thankfully, I was able to workaround this by doing the following:
echo -e '#!/usr/bin/sh
/usr/bin/tpm2_nvread 0x1500016' > /clientbuild/scripts/tpm2-getkey
Run
/clientbuild/scripts/tpm2-getkey
manually and make note of the password.
Open the luks volume, rescan lvm volumes, and continue the scripts that failed to run:
/clientbuild/scripts/tpm2-getkey | cryptsetup luksOpen /dev/nvme0n1p3 ubuntu-p3
lvm lvscan
sh /scripts/local
Press ctrl+D to return control to the initramfs.
At this point I'm then prompted to enter the password that I noted down, which I do, and then I can boot into my system successfully.
However, every time I reboot my machine, I have to complete the above steps again. So what's been corrupted here, and how do I repair it permanently?