After reducing the size of /root volume of an encrypted partition using lvm, I get this error when ubuntu boots:
cryptsetup: cryptsetup failed, bad password or options
The partition itself is fine. I can open the encrypted container, and mount and browse the file system, if I go in manually from a live usb.
I reduced the size of root using the steps given in these guides:
https://ubuntuforums.org/showthread.php?t=726724
https://help.ubuntu.com/community/ResizeEncryptedPartitions
https://askubuntu.com/questions/262211/how-do-i-resize-an-encrypted-lvm-to-install-another-copy-of-ubuntu
Since the resize did actually work, it is not strictly necessary to show what steps I took to do the resize. But I replicate them here for assurance, and the possibility that they are the source of the error.
(I also renamed the logical volume group, for ease of typing, from ubuntu-studio-vg to sys-vg).
Steps I took to reduce the volume size were as follows:
sudo cryptsetup luksOpen /dev/sda5 bonse
sudo e2fsck -f /dev/mapper/sys--vg-root
sudo resize2fs -p /dev/mapper/sys--vg-root 150G
sudo e2fsck -f /dev/mapper/sys--vg-root
sudo lvreduce -L 150.1G /dev/sys-vg/root
sudo lvremove /dev/sys-vg/swap_1
sudo pvresize --setphysicalvolumesize 158.2G /dev/mapper/bonse
sudo lvcreate -L 8G -n swap_1 sys-vg
sudo mkswap -L swap_1 /dev/sys-vg/swap_1
sudo mount /dev/sys-vg/root /mnt
sudo umount /mnt
sudo pvchange -c n /dev/mapper/bonse
sudo cryptsetup status bonse
Last statement gives:
...offset: 4096 sectors ...size: 624136192 sectors
Then:
sudo cryptsetup resize --size 309082032 bonse
sudo vgchange -an
sudo cryptsetup luksClose bonse
sudo fdisk /dev/sda
In fdisk:
- deleted sda5 and sda2
- created new sda2 as an extended partition: size +159G
- created new sda2 as an extended partition: size +159G
- created new sda5 as an extended partition: size +158.9G
- changed sda5 partition type to '8e: linux LVM'
Finally, edited /mnt/etc/fstab mousepad, initially replacing the root and swap devices so that references to ubuntu--studio--vg were replaced with sys--vg. But this didn't work. So I changed the device references to UUID=< and used the LV UUID given for each volume by lvdisplay >.
The result, to recap, was error on boot. But still able to open, mount and read the drive manually.
The problem was that I had used vgrename to change the name of the volume group.
This had seemed sensible because (notwithstanding cut-and-paste) the default ubuntu-studio-vg is a pain to type. So I changed it to sys-vg.
But the rename did not cascade throughout my system settings. The lv documentation gave no warning. Nor did it report the necessity of the change being cascaded. Nor where else it might need to made.
There are two places at least: /etc/fstab and /boot/grub/grub.cfg