Skip to content

Commit df5ca38

Browse files
committed
HOW_TO_SECURE_USB_DEVICE.md : minor updates
1 parent 907a6a2 commit df5ca38

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

docs/HOW_TO_SECURE_USB_DEVICE.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Goals:
66
- Data must be encrypted so that only you can read it
77
- The USB device must be bootable to access encrypted data on any physical computer you have access to
88
- If the USB device is lost and someone plugs it in its own computer, contact details must be readable
9-
- Using the device must be seemless, we already have a hardened setup, we don't want to bother having to type one more password
9+
- Using the device must be seamless, we already have a hardened setup, we don't want to bother having to type one more password
1010

1111
First, identify the USB device using lsblk, example:
1212

@@ -27,10 +27,10 @@ WARNING: think twice before running any command or you might lose data !
2727

2828
## Prepare the device
2929

30-
Write random data to the whole device:
30+
Write random data to the whole device (this will take some time, plug the device to a USB 3 port if you have one):
3131

3232
```
33-
sudo dd if=/dev/random of=/dev/sdb status=progress
33+
sudo dd bs=1M if=/dev/urandom of=/dev/sdb status=progress
3434
```
3535

3636
Remove any FS magic bytes (in case dd randomly created valid ones) otherwise some tools will complain:
@@ -138,7 +138,7 @@ We want it to :
138138
- Be bootable on any secure boot enabled computer
139139
- Auto-mount the storage partition
140140

141-
Debian has been choosen for two reasons:
141+
Debian has been chosen for two reasons:
142142

143143
- Because it's very stable, if we have to boot into this USB device it probably means something went wrong at some point and we don't want to deal with a broken install
144144
- Because it supports secure boot out of the box, meaning we will be able to boot into it on any computer (as long as it allows us to boot into external USB)
@@ -163,8 +163,9 @@ Then run debootstrap to install debian:
163163
```
164164
sudo debootstrap --arch amd64 --components main,contrib,non-free-firmware stable /mnt http://ftp.us.debian.org/debian
165165
```
166+
(Don't forget to use the `proxify` script if you use my setup)
166167

167-
When it's done, mount additionnal resources:
168+
When it's done, mount additional resources:
168169

169170
```
170171
sudo mount --mkdir /dev/sdb2 /mnt/boot/efi
@@ -189,7 +190,7 @@ echo 'deb http://security.debian.org/ stable-security main contrib non-free-firm
189190
sudo LANG=C.UTF-8 TERM=xterm-color chroot /mnt bash --login -c 'apt-get update && apt-get upgrade -y'
190191
```
191192

192-
Install additionnal packages:
193+
Install additional packages:
193194

194195
```
195196
sudo LANG=C.UTF-8 TERM=xterm-color chroot /mnt bash --login -c 'apt-get install -y linux-image-amd64 firmware-linux firmware-iwlwifi zstd grub-efi cryptsetup cryptsetup-initramfs btrfs-progs fdisk gdisk sudo neovim network-manager xserver-xorg xinit lightdm xfce4 dbus-x11 thunar xfce4-terminal firefox-esr keepassxc network-manager-gnome'
@@ -261,7 +262,7 @@ If your external USB device **filesystem is ext4**, run the following command:
261262
echo "/dev/mapper/$luks_storage_uuid /storage ext4 defaults,noatime,nodiratime 0 2" | sudo tee -a /mnt/etc/fstab
262263
```
263264

264-
Now let's setup the bootlader and the initramfs:
265+
Now let's setup the bootloader and the initramfs:
265266

266267
```
267268
echo 'GRUB_ENABLE_CRYPTODISK=y' | sudo tee -a /mnt/etc/default/grub
@@ -345,7 +346,7 @@ Warning: the keyfile should be readable only by root !!
345346
Create a folder where the USB drive will be mounted:
346347

347348
```
348-
sudo mkdir -m 700 -p "/backups/$luks_storage_uuid"
349+
sudo mkdir -m 700 -p "/media/usb/my_device"
349350
```
350351

351352
Run the following command to open the LUKS container automatically using the keyfile:
@@ -357,13 +358,13 @@ echo "$luks_storage_uuid UUID=$luks_storage_uuid /root/luks_${luks_storage_uuid}
357358
If your external USB device **filesystem is btrfs**, run the following command:
358359

359360
```
360-
echo "/dev/mapper/$luks_storage_uuid /backups/$luks_storage_uuid btrfs defaults,noatime,nodiratime,subvol=@snapshots,compress=zstd,space_cache=v2,nofail,x-systemd.device-timeout=100ms 0 2" | sudo tee -a /etc/fstab
361+
echo "/dev/mapper/$luks_storage_uuid /media/usb/my_device btrfs defaults,noatime,nodiratime,subvol=@snapshots,compress=zstd,space_cache=v2,nofail,x-systemd.device-timeout=100ms 0 2" | sudo tee -a /etc/fstab
361362
```
362363

363364
If your external USB device **filesystem is ext4**, run the following command:
364365

365366
```
366-
echo "/dev/mapper/$luks_storage_uuid /backups/$luks_storage_uuid ext4 defaults,noatime,nodiratime,nofail,x-systemd.device-timeout=100ms 0 2" | sudo tee -a /etc/fstab
367+
echo "/dev/mapper/$luks_storage_uuid /media/usb/my_device ext4 defaults,noatime,nodiratime,nofail,x-systemd.device-timeout=100ms 0 2" | sudo tee -a /etc/fstab
367368
```
368369

369370
And boom, you're done, you can now unmount the Linux partition:

0 commit comments

Comments
 (0)