Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5039

Raspberry Pi OS • Re: Disk Encryption since Bookworm

$
0
0
Okay folks, sorry for the delay. The solution:

First, partition the SD card:

Code:

Disk /dev/mmcblk0: 59.51 GiB, 63900221440 bytes, 124805120 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0xc26ea2d6Device         Boot   Start       End   Sectors  Size Id Type/dev/mmcblk0p1 *       2048   1050623   1048576  512M  c W95 FAT32 (LBA)/dev/mmcblk0p2      1050624 124805119 123754496   59G 83 Linux
Then:

Code:

# xz -d 2023-12-11-raspios-bookworm-arm64-lite.img.xz# losetup -fP 2023-12-11-raspios-bookworm-arm64-lite.img# dd if=/dev/loop0p1 of=/dev/mmcblk0p1 bs=1M# cryptsetup luksFormat --type=luks2 --cipher=xchacha12,aes-adiantum-plain64 /dev/mmcblk0p2# cryptsetup open /dev/mmcblk0p2 root# dd if=/dev/loop0p2 of=/dev/mapper/root bs=1M# e2fsck -f /dev/mapper/root# resize2fs -f /dev/mapper/root# mount /dev/mapper/root /mnt# mount /dev/mmcblk0p1 /mnt/boot/firmware# arch-chroot /mnt
Now, in chroot:

Code:

chroot# apt install cryptsetup-initramfs
Modify /etc/crypttab to the following:

Code:

# <target name><source device><key file><options>root            /dev/mmcblk0p2          none            luks
/etc/fstab:

Code:

proc              /proc           proc    defaults          0       0/dev/mmcblk0p1    /boot/firmware  vfat    defaults          0       2/dev/mapper/root  /               ext4    defaults,noatime  0       1
/boot/firmware/cmdline.txt:

Code:

console=serial0,115200 console=tty1 root=/dev/mapper/root rootfstype=ext4 fsck.repair=yes rootwait quiet cryptdevice=/dev/mmcblk0p2:root
Finally, update the initramfs, umount, and reboot (assuming the boot order: sd -> usb):

Code:

chroot# update-initramfs -uchroot# exit# umount -R /mnt# reboot

Statistics: Posted by 0x67757300 — Sun Jan 28, 2024 10:03 pm



Viewing all articles
Browse latest Browse all 5039

Trending Articles