[Bug 1979449] [NEW] Ubuntu 22.04 on encrypted ZFS and wrong crypttab setup

Bartosz 1979449 at bugs.launchpad.net
Wed Jun 22 09:26:56 UTC 2022


Public bug reported:

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 at bzieba-desktop:~# swapon --show
NAME      TYPE        SIZE USED PRIO
/dev/dm-1 partition 238,5G   0B   -2

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

root at bzieba-desktop:~# cat /etc/crypttab 
cryptoswap	/dev/nvme0n1p2	/dev/urandom	swap,initramfsroot at 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 at bzieba-desktop:~# grep -i uuid /etc/fstab 
UUID=2CCE-15F1  /boot/efi       vfat    umask=0022,fmask=0022,dmask=0022      0       1

root at 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 at bzieba-desktop:~# blkid -s PARTUUID -o value /dev/nvme1n1p2
5373106c-7691-b448-98c6-718c4458979c

root at 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 at 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 :)

** Affects: ubiquity (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: cryptswap crypttab encryption swap zfs

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to ubiquity in Ubuntu.
https://bugs.launchpad.net/bugs/1979449

Title:
  Ubuntu 22.04 on encrypted ZFS and wrong crypttab setup

Status in ubiquity package in Ubuntu:
  New

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 at bzieba-desktop:~# swapon --show
  NAME      TYPE        SIZE USED PRIO
  /dev/dm-1 partition 238,5G   0B   -2

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

  root at bzieba-desktop:~# cat /etc/crypttab 
  cryptoswap	/dev/nvme0n1p2	/dev/urandom	swap,initramfsroot at 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 at bzieba-desktop:~# grep -i uuid /etc/fstab 
  UUID=2CCE-15F1  /boot/efi       vfat    umask=0022,fmask=0022,dmask=0022      0       1

  root at 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 at bzieba-desktop:~# blkid -s PARTUUID -o value /dev/nvme1n1p2
  5373106c-7691-b448-98c6-718c4458979c

  root at 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 at 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 manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ubiquity/+bug/1979449/+subscriptions




More information about the foundations-bugs mailing list