Score:0

Installing Ubuntu 22.04 with full disk encryption (LUKS) and swap partitions

us flag

I`m just trying to install Ubuntu 22.04 in my notebook, but I need to have full disk encryption enabled and I would like to define the size of my swap partition.

When searching for answers I saw multiple mentions that Ubuntu 22 doesn`t need a swap partition, because it would use swapfile. However If I proceed with the default installation (plus enabling FDE) I get a swap partition anyway:

nvme0n1               259:0    0 238.5G  0 disk  
├─nvme0n1p1           259:1    0   512M  0 part  
├─nvme0n1p2           259:2    0   1.7G  0 part  
└─nvme0n1p3           259:3    0 236.3G  0 part  
  └─crypt             253:0    0 236.3G  0 crypt 
    ├─vgubuntu-root   253:1    0 234.4G  0 lvm   
    └─vgubuntu-swap_1 253:2    0   1.9G  0 lvm   

So I went for a new install following these tutorials: (They are mostly the same)

  1. https://help.ubuntu.com/community/Full_Disk_Encryption_Howto_2019
  2. https://www.tecmint.com/encrypt-disk-installing-ubuntu/

Note: Its a nvme notebook

Following the tutorial, I ran command for command with no error, but got a warning when partitioning:

Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)

The sgdisk --print $DEV returns as expected:

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1574911   768.0 MiB   8301  /boot
   2         1574912         1579007   2.0 MiB     EF02  GRUB
   3         1579008         1841151   128.0 MiB   EF00  EFI-SP
   5         1841152       500118158   237.6 GiB   8301  rootfs

However when I get to the point of using LUKS, the first time it works as expected, but the second command fails: This command works:

cryptsetup luksFormat --type=luks1 ${DEVP}1 

And then this command fails:

# cryptsetup luksFormat --type=luks1 ${DEVP}5
Device /dev/nvme0n1p5 does not exist or access denied.

I`ve also tried like this:

# cryptsetup luksFormat ${DEVP}5
Device /dev/nvme0n1p5 does not exist or access denied.

Because that is a difference between both tutorials so far... I`m on a live boot from USB.

How can I encrypt the last partition so I can continue on?

OR how can I achieve the Ubuntu 22 install + LUKS FDE + Custom SWAP?

ar flag
It is easier to run the default installation with LVM and LUKS and then change the size of the swap partition as needed. That's what I did.See [Changing Swap Partition on encrypted LVM](https://askubuntu.com/questions/1240217/changing-swap-size-on-encrypted-lvm-kubuntu-20-04-installation) for how.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.