Xubuntu 20.04 with LVM on LUKS

Boot Xubuntu installation media, choose “Try”, enter “Terminal emulator” …

First, create three partitions: EFI with 128MB, /boot with 512MB and last with remaining space

sudo fdisk /dev/sda
g

n
1
<ENTER>
+128M
<remove signature>
t
1

n
2
<ENTER>
+512M
t
2
20

n
3
<ENTER>
<ENTER>
t
3
31
Disk model: ST1000VN002-2E41
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: A2C8ED15-47CB-4E4B-929E-E45128441F03
Device Start End Sectors Size Type
/dev/sda1 2048 264191 262144 128M BIOS boot
/dev/sda2 264192 1312767 1048576 512M Linux filesystem
/dev/sda3 1312768 1953525134 1952212367 930.9G Linux LVM
sudo mkfs.fat -F32 /dev/sda1
sudo mkfs.ext2 -m 0 /dev/sda2
sudo cryptsetup luksFormat --hash=sha512 --key-size=512 --cipher=aes-xts-plain64 --verify-passphrase /dev/sda3
sudo cryptsetup luksOpen /dev/sda3 sda3_crypt

sudo pvcreate /dev/mapper/sda3_crypt

sudo vgcreate vg0 /dev/mapper/sda3_crypt

sudo lvcreate -n dskswap -L 16GB vg0
sudo lvcreate -n dskroot -L 100GB vg0
sudo lvcreate -n dskhome -L 100GB vg0
sudo mkswap /dev/mapper/vg0-dskswap
sudo swaplabel -L SWAP_SDA /dev/mapper/vg0-dskswap
sudo mkfs.ext4 /dev/mapper/vg0-dskroot
sudo mkfs.ext4 /dev/mapper/vg0-dskhome

Now, execute “Install Xubuntu 20.04 LTS” with icon on Desktop. Next, next, next… until “Instalation Type”, choose “Something else”

Devicetypemount point
/dev/mapper/vg0-dskhomeext4/home
/dev/mapper/vg0-dskhomeext4/
/dev/mapper/vg0-dskswapswapswap
/dev/sda1fat32/boot/efi
/dev/sda2ext2/boot
Xubuntu 20.04 custom install disk partitions

Device for boot loader installation: /dev/sda

Choose “continue testing”… Now build the chroot environment

Chroot environment

sudo cryptsetup luksOpen /dev/sda3 sda3_crypt
mkdir newpart
sudo mount /dev/mapper/vg0-dskroot newpart
sudo mount /dev/sda2 newpart/boot
sudo mount /dev/sda1 newpart/boot/efi

sudo mount -t proc /proc newpart/proc
sudo mount --rbind /dev newpart/dev
sudo mount --rbind /dev/pts newpart/dev/pts
sudo mount --rbind /sys newpart/sys 
sudo mount --rbind /run newpart/run
sudo chroot newpart

Now, prepare LUKS automount

sudo cryptsetup luksDump /dev/sda3 | grep UUID

>>> /etc/crypttab <<<
sda3_crypt UUID=2945b973-12ea-4f45-9454-8d873da8be9d none luks,discard

Test automount

$ sudo /sbin/cryptdisks_start sda3_crypt
/dev/mapper/vg0-dskroot / ext4 errors=remount-ro 0 1
UUID=45bf98f6-665e-4d9d-9462-e40b017e3881 /boot ext2 defaults 0 2
UUID=662E-6E71 /boot/efi vfat utf8,umask=007,gid=46 0 1
/dev/mapper/vg0-dskhome /home ext4 defaults 0 2
/dev/mapper/vg0-dskswap none swap sw 0 0
apt-get install grub-efi-amd64 efibootmgr

grub-install --target=x86_64-efi /dev/sda

efibootmgr --create --disk /dev/sda --part 1 --loader /boot/efi/EFI/BOOT/BOOTX64.EFI --label "Xubuntu Boot Manager"


## efibootmgr --create --disk /dev/sda --part 1 --loader /boot/efi/EFI/ubuntu/grubx64.efi --label "Xubuntu Boot Manger" --verbose


exit
reboot






# update-grub
# grub-install --recheck /dev/sda
# update-initramfs -u

reboot