Ubuntu 22.04 on encrypted ZFS and wrong crypttab setup

Bug #1979449 reported by Bartosz
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ubiquity (Ubuntu)
New
Undecided
Unassigned

Bug Description

I have installed Ubuntu 22.04 with ZFS and its native encryption (using the official installer, Ubiquity, no hacking at all). And everything was working great!

I decided to add a second NVMe drive, to install Windows on it. And I found a weird Windows behavior, because it was crashing, not booting etc.
The next day I found that my SWAP space is HUGE, more than 200 GB, but should be 2 gigs only.

I have started looking at this weird issue:

root@bzieba-desktop:~# swapon --show
NAME TYPE SIZE USED PRIO
/dev/dm-1 partition 238,5G 0B -2

root@bzieba-desktop:~# grep -i swap /etc/fstab
/dev/mapper/cryptoswap none swap sw 0 0

root@bzieba-desktop:~# cat /etc/crypttab
cryptoswap /dev/nvme0n1p2 /dev/urandom swap,initramfsroot@bzieba-desktop:~#

And here is the issue!
nvme0n1p2 was my Ubuntu NVMe, but now, after adding the second NVMe drive, it's a Windows partition.
Ubuntu started overwriting my Windows data (but I don't care, no worries).

===

Ubuntu uses UUIDs for most FS/partitions:
root@bzieba-desktop:~# grep -i uuid /etc/fstab
UUID=2CCE-15F1 /boot/efi vfat umask=0022,fmask=0022,dmask=0022 0 1

root@bzieba-desktop:~# zpool status -v rpool
  pool: rpool
 state: ONLINE
  scan: scrub repaired 0B in 00:00:46 with 0 errors on Sun Jun 12 00:24:49 2022
config:

 NAME STATE READ WRITE CKSUM
 rpool ONLINE 0 0 0
   4633606d-c5e6-3343-a211-9bb5a2d9ad0b ONLINE 0 0 0

So why it doesn't use UUID for /etc/crypttab and cryptswap device?

===

I found that it comes from Ubiquity, scripts/zsys-setup:

printf "${swap_name}\t${orig_swap_device}\t/dev/urandom\tswap,initramfs" >> "${TARGET}/etc/crypttab"

Where:
orig_swap_device="${swap_device}"
swap_device="${DISK}${PARTBASE}${PARTSWAP}"

===

I believe we should fix that and start using PARTUUID for crypttab and cryptswap device because it already exists:

root@bzieba-desktop:~# blkid -s PARTUUID -o value /dev/nvme1n1p2
5373106c-7691-b448-98c6-718c4458979c

root@bzieba-desktop:~# cat /etc/crypttab
cryptoswap PARTUUID=5373106c-7691-b448-98c6-718c4458979c /dev/urandom swap,initramfs

And now SWAP is working on the correct partition:

root@bzieba-desktop:~# swapon --show
NAME TYPE SIZE USED PRIO
/dev/dm-1 partition 2G 0B -2

===

If someone confirm that it needs a fix, I would love to prepare the fix and push it to the repo :)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.