You are not logged in.

#1 2020-02-17 14:58:50

7thCore
Member
Registered: 2018-06-09
Posts: 75

Encrypted external ssd installation problems

So i have a SanDisk Extreme Portable SSD 500GB to wich i've decided to make my personal "tool box" if you will. An encrypted arch linux installation with a couple of iso files and using grub as a boot loader.

I've followed this guide to create the hybrid boot with the same paritition scheme but the data partition being used with luks.

I've decided to just use btrfs for the data partition (btrfs on luks if you will).

Here is what i did:

#Prep the luks partition
cryptsetup -q -v luksFormat --type luks1 /dev/sda3
cryptsetup luksOpen /dev/sda3 crypt_btrfs

#Format the file systems
mkfs.fat -F32 /dev/sda2
mkfs.btrfs -f -L "System" /dev/mapper/crypt_btrfs

#Mount the btrfs file system
mount /dev/mapper/crypt_btrfs /mnt

#Create subvolumes
cd /mnt
btrfs subvolume create _active
btrfs subvolume create _active/rootvol
btrfs subvolume create _active/homevol
btrfs subvolume create _snapshots

#Unmount
cd ./..
umount /mnt

#Mount file systems for instal
mount -o rw,relatime,ssd,space_cache,subvol=/_active/rootvol /dev/mapper/crypt_btrfs /mnt
mkdir /mnt/{boot,home}
mkdir /mnt/boot/EFI
mount /dev/sda2 /mnt/boot/EFI
mount -o rw,relatime,ssd,space_cache,subvol=/_active/homevol /dev/mapper/crypt_btrfs /mnt/home

#Create swap file on btrfs (possible since kernel 5.0)
touch /mnt/swapfile
chattr +C /mnt/swapfile
btrfs property set /mnt/swapfile compression none
dd if=/dev/zero of=/mnt/swapfile bs=1M count=$SWAPSIZE status=progress
chmod 600 /mnt/swapfile
mkswap /mnt/swapfile
swapon /mnt/swapfile

#Install Arch Linux
pacstrap /mnt base base-devel linux btrfs-progs mkinitcpio linux-firmware dhcpcd rsync nano

I did the typical install of arch but added the following to mkinitcpio.conf:

MODULES=(ext2 xfs dm_mod xhci-hcd)
FILES=(/root/crypt_btrfs.keyfile)

Created the key so i wouldn't be asked twice for it and added it to the luks partition

dd bs=512 count=4 if=/dev/urandom of=/root/crypt_btrfs.keyfile iflag=fullblock
chmod 000 /root/crypt_btrfs.keyfile
cryptsetup -v luksAddKey /dev/sda3 /root/crypt_btrfs.keyfile
mkinitcpio -p linux

Adjusted the following lines in grub:

GRUB_CMDLINE_LINUX_DEFAULT="locale=sl_SI.utf8 nomodeset"
GRUB_CMDLINE_LINUX="rd.luks.name='uuid_of_sda3'=crypt_btrfs rd.luks.key='uuid_of_sda3'=/root/crypt_btrfs.keyfile"
GRUB_ENABLE_CRYPTODISK=y
GRUB_PRELOAD_MODULES="part_gpt part_msdos cryptodisk crypto luks btrfs"
GRUB_TERMINAL_INPUT=at_keyboard

Created a keyboard layout for grub:

mkdir -p /boot/grub/layouts
ckbcomp si | grub-mklayout -o si.gkb
mv si.gkb /boot/grub/layouts

Created the /etc/grub.d/40_custom file:

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

insmod keylayouts
keymap /boot/grub/layouts/si.gkb

menuentry "System restart" {
        echo "System rebooting..."
        reboot
}

menuentry "System shutdown" {
        echo "System shutting down..."
        halt
}

if [ ${grub_platform} == "efi" ]; then
        menuentry "Firmware setup" {
                fwsetup
        }
fi

And last installed grub itself and generated it's config like it was mentioned in the guide from earlier.

grub-install --target=x86_64-efi --recheck --removable --efi-directory=/boot/EFI --boot-directory=/boot
grub-install --target=i386-pc --recheck --boot-directory=/boot /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

Now the problem is that if i boot the ssd drive, the initial grub prompt for the password does not want to accept it. Even if i just use "test" for password. I also tried hooking up the drive to a pc with an existing arch installation and opening the luks partition that way but it dosen't accept the key. I get the follwoing from grub:

Welcome to grub:

Attempting to decrypt master key...
Enter passphrase for hd1,gpt3 (812949b3d04b4293a752be5ad24d8553)
error: access denied
error: no such cryptodisk found
error: disk '812949b3d04b4293a752be5ad24d8553' not found
Entering rescue mode...
grub rescue>

So simply asking, what am i doing wrong?


The Linux philosophy is 'Laugh in the face of danger'. Oops. Wrong One. 'Do it yourself'. Yes, that's it.

Offline

Board footer

Powered by FluxBB