Last active
July 12, 2026 11:50
-
-
Save tabletseeker/29eaf62d24be327f15bc27c534ea3d1d to your computer and use it in GitHub Desktop.
calamares
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-FileCopyrightText: no | |
| # SPDX-License-Identifier: CC0-1.0 | |
| # /etc/calamares/modules/shellprocess/shellprocess@luksfix.conf | |
| --- | |
| id: luksfix | |
| dontChroot: false | |
| timeout: 90 | |
| name: "Configuring single-passphrase boot bypass..." | |
| script: | |
| # 1. Write the clean, standalone script file using a literal text block | |
| - | | |
| cat << 'EOF' > /tmp/luks-bypass.sh | |
| #!/bin/bash | |
| set -x | |
| set -e | |
| mkdir -p /boot/cryptsetup-keys.d | |
| dd bs=512 count=8 if=/dev/urandom of=/boot/cryptsetup-keys.d/root.key iflag=fullblock | |
| chmod 400 /boot/cryptsetup-keys.d/root.key | |
| echo "# Automatically generated by Mobian FDE Fix" > /etc/crypttab | |
| ls /dev/mapper/luks-* 2>/dev/null | while read -r mapper_path; do | |
| MAP_NAME=$(basename "$mapper_path") | |
| UUID_HEX=$(cryptsetup luksUUID "$mapper_path" 2>/dev/null || echo "") | |
| if [ -n "$UUID_HEX" ]; then | |
| PHYS_PART=$(blkid -U "$UUID_HEX" 2>/dev/null || echo "") | |
| if [ -n "$PHYS_PART" ]; then | |
| echo "Enrolling keyfile into LUKS slot for: $PHYS_PART" | |
| echo -n "$PASSPHRASE_TOKEN" | cryptsetup luksAddKey "$PHYS_PART" /boot/cryptsetup-keys.d/root.key | |
| echo "${MAP_NAME} UUID=${UUID_HEX} /boot/cryptsetup-keys.d/root.key luks,initramfs" >> /etc/crypttab | |
| fi | |
| fi | |
| done | |
| mkdir -p /etc/cryptsetup-initramfs | |
| echo 'KEYFILE_PATTERN="/boot/cryptsetup-keys.d/*.key"' >> /etc/cryptsetup-initramfs/conf-hook | |
| EOF | |
| # 2. Make the script executable | |
| - "chmod +x /tmp/luks-bypass.sh" | |
| # 3. Execute the script while safely injecting the Calamares password variable from the host | |
| - "PASSPHRASE_TOKEN=${PASSWORD} /tmp/luks-bypass.sh" | |
| # 4. Clean up the temporary script file | |
| - "rm -f /tmp/luks-bypass.sh" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # /etc/calamares/modules/shellprocess@cryptfix.conf | |
| --- | |
| dontChroot: true # Keep this TRUE so the script can map the host's real disk layout | |
| timeout: 30 | |
| script: | |
| - description: "Dynamically mapping host LUKS parameters to the target configuration..." | |
| command: | | |
| # 1. Locate where Calamares has currently mounted the target root image on the live host | |
| TARGET_MOUNT=$(mount | grep 'calamares-root' | grep 'on /tmp/' | head -n 1 | awk '{print $3}') | |
| # Validate that a mount target was actually discovered before continuing | |
| if [ -z "$TARGET_MOUNT" ]; then | |
| echo "ERROR: Calamares target mount point could not be detected!" | |
| exit 1 | |
| fi | |
| # 2. Extract the underlying mapper device node handling the filesystem | |
| TARGET_DEV=$(mount | grep "on ${TARGET_MOUNT}" | awk '{print $1}') | |
| # 3. Retrieve the matching true physical LUKS disk partition UUID | |
| REAL_UUID=$(blkid -o value -s UUID ${TARGET_DEV}) | |
| if [ -z "$REAL_UUID" ]; then | |
| echo "ERROR: Failed to resolve the underlying LUKS container UUID!" | |
| exit 1 | |
| fi | |
| # 4. Mount target is on the host, so write directly to its absolute path offset | |
| echo "cryptroot UUID=${REAL_UUID} none luks,initramfs" > "${TARGET_MOUNT}/etc/crypttab" | |
| # Output confirmation directly to Calamares logs for clean debugging | |
| echo "SUCCESS: Wrote cryptroot entry with UUID=${REAL_UUID} directly to ${TARGET_MOUNT}/etc/crypttab" |
tabletseeker
commented
Jul 12, 2026
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment