Full Disk Encryption for uConsole CM5 (Debian Trixie)
This guide encrypts the uConsole completely, including root! Thanks a ton to mclbin’s previous guide on this forum, I could not have written this without their excellent work.
What you need: A uConsole CM5 (not tested with CM4 or others), a second Linux computer, a card reader, and about 30 minutes.
1. Flash Image & Prepare Storage
Download Rex’s Debian Trixie image for the uConsole CM5: [Trixie 6.12.y for the uConsole and DevTerm]
Flash it to your SD card / eMMC using your tool of choice (I like Fedora Media Writer).
Before booting, open the flashed media in GParted (or similar). The root filesystem on the fresh image is small, and we need some room to install updates before encrypting.
In GParted:
- Create a new ~5 GiB partition directly after the root partition (p2)
- Create another partition filling the remaining empty space after that
- Delete the 5 GiB partition you just created
This leaves a ~5 GiB gap of unallocated space right after root. On first boot, the system expands into the empty space, and the partition at the end blocks it from eating the whole card so we don’t have to wait three hours when we flash the FS back later.
Apply changes, eject, insert into uConsole, and boot.
Once booted, update and reboot:
sudo apt update && sudo apt full-upgrade -y
sudo reboot
2. Install Packages
sudo nano etc/initramfs-tools/initramfs.conf
Find the line with modules=dep and change it to modules=most.
Then install prerequisite packages.
sudo apt install busybox cryptsetup cryptsetup-initramfs initramfs-tools
3. Add Kernel Modules to Initramfs
Append the following to /etc/initramfs-tools/modules:
# --- Crypto modules (AES-XTS + SHA256, ARM hardware-accelerated) ---
aes_arm64
aes_ce_blk
aes_ce_cipher
sha256_arm64
sha256_ce
dm-crypt
xts
# --- Display modules (needed so the password prompt shows on the uConsole screen) ---
drm
drm_kms_helper
drm_shmem_helper
drm_dma_helper
drm_ttm_helper
drm_display_helper
drm_panel_orientation_quirks
ttm
cec
backlight
ocp8178_bl
panel-cwu50
vc4
v3d
drm-rp1-dsi
The display modules need to be included so we can see the password prompt on boot.
4. Create Display Init Script
Create the file:
sudo nano /etc/initramfs-tools/scripts/init-top/display
Contents:
#!/bin/sh
PREREQ=""
prereqs() { echo "$PREREQ"; }
case $1 in prereqs) prereqs; exit 0;; esac
# Load display stack. Order matters.
modprobe drm
modprobe drm_kms_helper
modprobe backlight
modprobe ocp8178_bl # uConsole backlight controller
modprobe panel-cwu50 # uConsole LCD panel driver
modprobe vc4 # Broadcom VideoCore GPU
modprobe v3d # Broadcom V3D 3D engine
sleep 1 # Give the panel time to initialize
modprobe drm-rp1-dsi # RP1 DSI bridge (connects SoC to panel)
modprobe fbcon # Framebuffer console (renders text on screen)
Make it executable:
sudo chmod +x /etc/initramfs-tools/scripts/init-top/display
The sleep 1 is critical, don’t remove it!! Without it, drm-rp1-dsi tries to bind before the panel is ready and you get a blank screen.
5. Create Kernel Postinst Hook
Create the file:
sudo nano /etc/kernel/postinst.d/initramfs-rebuild
Contents:
#!/bin/sh -e
version="$1"
# Only rebuild for the currently running kernel
[ "$version" = "$(uname -r)" ] || exit 0
# Back up existing initramfs before overwriting
[ -e /boot/firmware/initramfs_2712 ] && \
cp /boot/firmware/initramfs_2712 /boot/firmware/initramfs_2712.bak
update-initramfs -c -k "$version"
mkinitramfs -o /boot/firmware/initramfs_2712 "$version"
Make it executable:
sudo chmod +x /etc/kernel/postinst.d/initramfs-rebuild
6. Build Initramfs
sudo update-initramfs -c -k "$(uname -r)"
sudo mkinitramfs -o /boot/firmware/initramfs_2712 "$(uname -r)"
7. Configure Boot
config.txt
Append under [all] in /boot/firmware/config.txt:
auto_initramfs=1
cmdline.txt
Replace the contents of /boot/firmware/cmdline.txt with:
console=serial0,115200 console=tty1 root=/dev/mapper/sdcard rootfstype=ext4 fsck.repair=yes rootwait fbcon=rotate:1 psi=1 quiet loglevel=3
8. Configure fstab & crypttab
/etc/fstab
Find the line that mounts / and replace it with:
/dev/mapper/sdcard / ext4 defaults,noatime 0 1
/etc/crypttab
Append this line:
sdcard /dev/mmcblk0p2 none luks
9. Backup & Encrypt (On Another Linux Machine)
Power off the uConsole. Move your storage media to another Linux computer.
Make sure you install:
partclone,zstd,cryptsetup,parted,e2fsprogsandsfdisk.
Your device is assumed to be /dev/mmcblk0 below. Don’t forget to adjust each command it if it shows up as /dev/sdX or something.
Back up
# Save the partition layout
sudo sfdisk -d /dev/mmcblk0 > uconsole-partitions.txt
# Clone both partitions with compression
sudo partclone.fat32 -c -s /dev/mmcblk0p1 | zstd -T0 > uconsole-boot.img.zst
sudo partclone.ext4 -c -s /dev/mmcblk0p2 | zstd -T0 > uconsole-root.img.zst
Encrypt and restore
Delete the big partition at the end of your disk you made to fill up space.
# Resize partition to fill available space
sudo parted /dev/mmcblk0 resizepart 2 100%
# Format as LUKS2 with AES-XTS-256 and Argon2id KDF
sudo cryptsetup luksFormat \
--type luks2 \
--cipher aes-xts-plain64 \
--hash sha256 \
--key-size 512 \
--pbkdf argon2id \
--iter-time 5000 \
/dev/mmcblk0p2
# Open the new LUKS volume
sudo cryptsetup luksOpen /dev/mmcblk0p2 sdcard
# Restore the root filesystem into the encrypted container
zstd -d -c uconsole-root.img.zst | sudo partclone.ext4 -r -C -o /dev/mapper/sdcard
# Expand the filesystem to fill the LUKS volume
sudo e2fsck -f /dev/mapper/sdcard
sudo resize2fs /dev/mapper/sdcard
sudo cryptsetup luksClose sdcard
Move the storage back to the uConsole and boot it up.
10. First Boot and Finalize
The first boot will take a while, then drop you into an initramfs shell. This is expected!
You just have to login manually:
cryptsetup luksOpen /dev/mmcblk0p2 sdcard
Then continue the boot by exiting:
exit
You should now boot into your encrypted system!
Rebuild the initramfs one final time so the LUKS prompt triggers automatically on future boots:
sudo update-initramfs -c -k "$(uname -r)"
sudo mkinitramfs -o /boot/firmware/initramfs_2712 "$(uname -r)"
Reboot. The password prompt should now appear on the uConsole screen at boot.
Tadaa!