Repository: archlinux/archinstall

Issue:
cryptdevice and root have same PARTUUID -> unable to boot
Version: archinstall 2.5.4 (official 2023-04 ISO) and 2.5.5 (cloned)

Issue: encrypted root partition (btrfs) does not boot due to /boot/loader/entries .conf having the same UUID for cryptdevice and root

Fix: changing the root uuid to the encrypted partition (or just using /dev/mapper/luksdev) fixed the issue


Discussion:
Can you post before and after changes of your boot entry configurations?
Because I don't think I've ever seen this happen when I'm installing.

For reference, mine looks like this:
```
options cryptdevice=PARTUUID=a9667e09-5b26-4289-8680-392eb101d46b:luksdev root=/dev/mapper/luksdev
```
This happened to me yesterday - dropped me into `initramfs` with `rootfs #` prompt.

Ended up being two `options` lines in the boot entry, one for an encrypted partition and one for not. Removed the 2nd (for non-encrypted) and it worked. This was BTRFS and on the `2023.04.01` ISO.
Yep, as @mewejo pointed out, there are 2 `options` lines. In the first, the root is correctly set, the second overwrtites the values and causes booting into `emergency shell`.

```
options cryptdevice=PARTUUID=a34c8618-c601-4c3a-bfdf-d6d983a17723:luksdev root=/dev/mapper/luksdev zswap.enabled=0 rw rootfstype=btrfs 
options root=PARTUUID=a34c8618-c601-4c3a-bfdf-d6d983a17723 zswap.enabled=0 rw rootfstype=btrfs
```

A question in general: Why doesn't the installer use labels (as in nixos) to be able to clone a system easily without the hassle of changing UUIDs?
This is caused by a portion of code that was duplicated in 5669f3b. I submitted a pull request that fixes the issue.

Resolving patch:
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -919,7 +919,7 @@ def add_systemd_bootloader(self, boot_partition :Partition, root_partition :Part
 
 						kernel_options = f"options"
 
-						if self._disk_encryption.hsm_device:
+						if self._disk_encryption and self._disk_encryption.hsm_device:
 							# Note: lsblk UUID must be used, not PARTUUID for sd-encrypt to work
 							kernel_options += f" rd.luks.name={real_device.uuid}=luksdev"
 							# Note: tpm2-device and fido2-device don't play along very well:
@@ -929,13 +929,6 @@ def add_systemd_bootloader(self, boot_partition :Partition, root_partition :Part
 							kernel_options += f" cryptdevice=PARTUUID={real_device.part_uuid}:luksdev"
 
 						entry.write(f'{kernel_options} root=/dev/mapper/luksdev {options_entry}')
-
-					if self._disk_encryption and self._disk_encryption.hsm_device:
-						# Note: lsblk UUID must be used, not PARTUUID for sd-encrypt to work
-						kernel_options += f" rd.luks.name={real_device.uuid}=luksdev"
-						# Note: tpm2-device and fido2-device don't play along very well:
-						# https://github.com/archlinux/archinstall/pull/1196#issuecomment-1129715645
-						kernel_options += f" rd.luks.options=fido2-device=auto,password-echo=no"
 					else:
 						log(f"Identifying root partition by PARTUUID on {root_partition}, looking for '{root_partition.part_uuid}'.", level=logging.DEBUG)
 						entry.write(f'options root=PARTUUID={root_partition.part_uuid} {options_entry}')


Test patch: