1

I have Ubuntu 24.04 installed with the default disk partitioning settings chosen by the installer, including LVM encryption. I have two SSDs:

First disk with the following partitions:

/boot/efi

/boot

/

Second disk (/dev/sda)

My goal is to:

Allocate a 20GB swap partition from the first disk, which is encrypted, and activate it. Format the second disk to Ext4, encrypt it, add it to LVM, and move the /home partition to this disk.

Issue:

After rebooting, the system prompted for the decryption password (same password for both partitions), attempted to load the system, but then dropped to a initramfs with alert: "/dev/mapper/ubuntu--vg-ubuntu--lv does not exist". I noticed that the fstab and crypttab files were empty. Manually filling them didn't resolve the issue.

Question:

How can I properly configure the swap partition and move /home to the second encrypted disk without causing boot issues? What steps might I be missing or doing incorrectly?

Here are the steps I performed from a LiveCD environment:

Adding Swap:

ubuntu@ubuntu:~$ sudo pvs
ubuntu@ubuntu:~$ sudo vgs
ubuntu@ubuntu:~$ sudo lvs
ubuntu@ubuntu:~$ sudo e2fsck -f /dev/mapper/ubuntu--vg-ubuntu--lv
ubuntu@ubuntu:~$ sudo umount /target/boot/efi
ubuntu@ubuntu:~$ sudo umount /target/boot
ubuntu@ubuntu:~$ sudo umount /target/*
ubuntu@ubuntu:~$ sudo umount /target
ubuntu@ubuntu:~$ sudo e2fsck -f /dev/mapper/ubuntu--vg-ubuntu--lv
ubuntu@ubuntu:~$ sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv 95G
ubuntu@ubuntu:~$ sudo lvreduce -L 95G /dev/mapper/ubuntu--vg-ubuntu--lv
ubuntu@ubuntu:~$ sudo lvcreate -L 20G -n swap_1 ubuntu-vg
ubuntu@ubuntu:~$ sudo mkswap /dev/ubuntu-vg/swap_1
ubuntu@ubuntu:~$ sudo swapon /dev/ubuntu-vg/swap_1
ubuntu@ubuntu:~$ sudo nano /etc/fstab
#Added line: /dev/ubuntu-vg/swap_1 none swap sw 0 0

Working with the Second Disk:

ubuntu@ubuntu:~$ sudo cryptsetup luksFormat /dev/sda1
ubuntu@ubuntu:~$ sudo cryptsetup open /dev/sda1 sda1_crypt
ubuntu@ubuntu:~$ sudo pvcreate /dev/mapper/sda1_crypt
ubuntu@ubuntu:~$ sudo vgextend ubuntu-vg /dev/mapper/sda1_crypt
ubuntu@ubuntu:~$ sudo blockdev --getbsz /dev/mapper/sda1_crypt
ubuntu@ubuntu:~$ sudo blockdev --getbsz /dev/mapper/dm_crypt-0
ubuntu@ubuntu:~$ sudo vgscan
ubuntu@ubuntu:~$ sudo vgchange -ay
ubuntu@ubuntu:~$ sudo vgextend ubuntu-vg /dev/mapper/sda1_crypt
ubuntu@ubuntu:~$ sudo lvdisplay /dev/mapper/ubuntu--vg-ubuntu--lv
ubuntu@ubuntu:~$ sudo vgscan --mknodes
ubuntu@ubuntu:~$ cat /etc/lvm/lvm.conf | grep -i "allow_mixed_block_sizes" | grep -v "#"
ubuntu@ubuntu:~$ sudo fdisk -l /dev/sda1
ubuntu@ubuntu:~$ sudo nano /etc/lvm/lvm.conf
# Find allow_mixed_block_sizes and set it to 1
ubuntu@ubuntu:~$ sudo vgextend ubuntu-vg /dev/mapper/sda1_crypt
ubuntu@ubuntu:~$ sudo lvcreate -L 476.9G -n home ubuntu-vg
ubuntu@ubuntu:~$ sudo mkfs.ext4 /dev/ubuntu-vg/home
ubuntu@ubuntu:~$ sudo mount /dev/ubuntu-vg/home /mnt
ubuntu@ubuntu:~$ sudo rsync -aXS /home/. /mnt/.
ubuntu@ubuntu:~$ sudo nano /etc/fstab
# Added line: /dev/ubuntu-vg/home /home ext4 defaults 0 0
ubuntu@ubuntu:~$ sudo umount /mnt
ubuntu@ubuntu:~$ sudo mount -a
New contributor
LocalUser is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

1 Answer 1

0

I have found the hack that helps me and fix my problem Link to same problem

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
New contributor
LocalUser is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .