Skip to content

Commit ad61be4

Browse files
authored
Update fde_uefi.md
1 parent 80c3d86 commit ad61be4

File tree

1 file changed

+89
-143
lines changed

1 file changed

+89
-143
lines changed

src/installation/guides/fde_uefi.md

Lines changed: 89 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,21 @@
1-
# Full Disk Encryption
1+
# Full Disk Encryption - UEFI
22

33
**Warning**: Your drive's block device and other information may be different,
44
so make sure it is correct.
55

66
## Partitioning
77

8-
Boot a current Void Linux live image and login.
8+
Boot the right (base/xfce i686/amd64) [Void Linux live image](https://voidlinux.org/download/) and login.
99

10-
Create a single physical partition on the disk using
11-
[cfdisk](https://man.voidlinux.org/cfdisk), marking it as bootable. For an MBR
12-
system, the partition layout should look like the following.
10+
Create 3 physical (gpt) partition on the disk using
11+
[cfdisk](https://man.voidlinux.org/cfdisk).
12+
Type: "EFI System" (/boot/efi) "Linux server data" (swap) "Linux filesystem" ( / )
1313

14-
```
15-
# fdisk -l /dev/sda
16-
Disk /dev/sda: 48 GiB, 51539607552 bytes, 100663296 sectors
17-
Units: sectors of 1 * 512 = 512 bytes
18-
Sector size (logical/physical): 512 bytes / 512 bytes
19-
I/O size (minimum/optimal): 512 bytes / 512 bytes
20-
Disklabel type: dos
21-
Disk identifier: 0x4d532059
22-
23-
Device Boot Start End Sectors Size Id Type
24-
/dev/sda1 * 2048 100663295 100661248 48G 83 Linux
25-
```
26-
27-
UEFI systems will need the disk to have a GPT disklabel and an EFI system
28-
partition. The required size for this may vary depending on needs, but 100M
29-
should be enough for most cases. For an EFI system, the partition layout should
30-
look like the following.
14+
The partition layout should look like the following.
3115

3216
```
3317
# fdisk -l /dev/sda
18+
3419
Disk /dev/sda: 48 GiB, 51539607552 bytes, 100663296 sectors
3520
Units: sectors of 1 * 512 = 512 bytes
3621
Sector size (logical/physical): 512 bytes / 512 bytes
@@ -40,9 +25,9 @@ Disk identifier: EE4F2A1A-8E7F-48CA-B3D0-BD7A01F6D8A0
4025
4126
Device Start End Sectors Size Type
4227
/dev/sda1 2048 264191 262144 128M EFI System
43-
/dev/sda2 264192 100663262 100399071 47.9G Linux filesystem
28+
/dev/sda2 264192 4458495 4194304 2G Linux server data
29+
/dev/sda3 4458496 100663262 100399071 45.9G Linux filesystem
4430
```
45-
4631
## Encrypted volume configuration
4732

4833
[Cryptsetup](https://man.voidlinux.org/cryptsetup.8) defaults to LUKS2, yet GRUB
@@ -56,128 +41,110 @@ which is *not* the default KDF used with LUKS2, that being Argon2i ([GRUB Bug
5641
Argon2i (as well as the other KDF) can *not* be decrypted. For that reason, this
5742
guide only recommends LUKS1 be used.
5843

59-
Keep in mind the encrypted volume will be `/dev/sda2` on EFI systems, since
60-
`/dev/sda1` is taken up by the EFI partition.
61-
6244
```
63-
# cryptsetup luksFormat --type luks1 /dev/sda1
64-
65-
WARNING!
66-
========
67-
This will overwrite data on /dev/sda1 irrevocably.
68-
69-
Are you sure? (Type uppercase yes): YES
70-
Enter passphrase:
71-
Verify passphrase:
45+
# cryptsetup luksFormat --type luks1 /dev/sda3
7246
```
73-
74-
Once the volume is created, it needs to be opened. Again, this will be `/dev/sda2` on EFI systems.
47+
After the volume is created, it need to be opened.
7548

7649
```
77-
# cryptsetup luksOpen /dev/sda1 voidlx
78-
Enter passphrase for /dev/sda1:
50+
# cryptsetup luksOpen /dev/sda3 voidlx
7951
```
8052

8153
Once the LUKS container is opened, format that partition.
8254
The example below uses ext4 the Linux default filesystem. Any filesystem [supported by
83-
GRUB](https://www.gnu.org/software/grub/manual/grub/grub.html#Features) will
84-
work.
55+
GRUB](https://www.gnu.org/software/grub/manual/grub/grub.html#Features) should work.
8556

8657
```
87-
# mkfs.ext4 -L voidlinux /dev/dm-0
88-
# mount /dev/dm-0 /mnt
89-
# dd if=/dev/random of=/mnt/.swapfile bs=1M count=2048 status=progress
90-
# chmod 0600 /mnt/.swapfile
91-
# mkswap -L swapfile /mnt/.swapfile
58+
# mkfs.ext4 -L voidlinux /dev/mapper/voidlx
59+
# mount /dev/mapper/voidlx /mnt
60+
# mkdir -p /mnt/boot/efi
9261
```
62+
## LUKS keyfile setup
9363

94-
## System installation
95-
96-
Next, setup the chroot and install the base system.
64+
And now to avoid having to enter the password twice on boot, a keyfile will be
65+
configured to automatically unlock the encrypted volumes on boot. First, generate
66+
a random keyfile.
9767

9868
```
99-
# mkdir /mnt/home
100-
# mkdir /mnt/boot
101-
69+
# dd bs=1 count=64 if=/dev/urandom of=/mnt/boot/volume.key
10270
```
103-
104-
On a UEFI system, the EFI system partition also needs to be mounted.
105-
71+
Change the permissions to protect the generated key.
10672
```
107-
# mkfs.vfat /dev/sda1
108-
# mkdir -p /mnt/boot/efi
109-
# mount /dev/sda1 /mnt/boot/efi
73+
# chmod 0600 /mnt/boot/volume.key
11074
```
111-
112-
Copy the RSA keys from the installation medium to the target root directory:
113-
75+
Add the keyfile to the possible keys of /dev/sda3
11476
```
115-
# mkdir -p /mnt/var/db/xbps/keys
116-
# cp /var/db/xbps/keys/* /mnt/var/db/xbps/keys/
77+
# cryptsetup luksAddKey /dev/sda3 /mnt/boot/volume.key
11778
```
118-
119-
Before we enter the chroot to finish up configuration, we do the actual install.
120-
Do not forget to use the [appropriate repository
121-
URL](../../xbps/repositories/index.md#the-main-repository) for the type of
122-
system you wish to install.
123-
12479
```
125-
64 Bit (glibc):
126-
# XBPS_ARCH=x86_64 xbps-install -Sy -R https://repo-default.voidlinux.org/current -r /mnt base-system cryptsetup grub
127-
32 Bit:
128-
# XBPS_ARCH=i686 xbps-install -Sy -R https://repo-default.voidlinux.org/current -r /mnt base-system cryptsetup grub
129-
[*] Updating `https://repo-default.voidlinux.org/current/x86_64-repodata' ...
130-
x86_64-repodata: 1661KB [avg rate: 2257KB/s]
131-
130 packages will be downloaded:
132-
...
80+
# mkfs.vfat /dev/sda1
81+
# mount /dev/sda1 /mnt/boot/efi
13382
```
13483

135-
UEFI systems will have a slightly different package selection. The installation
136-
command for a UEFI system will be as follows.
137-
84+
### Encrypted swap /dev/sda2
13885
```
139-
64 Bit (glibc):
140-
# XBPS_ARCH=x86_64 xbps-install -Sy -R https://repo-default.voidlinux.org/current -r /mnt base-system cryptsetup grub-x86_64-efi
141-
32 Bit:
142-
# XBPS_ARCH=i686 xbps-install -Sy -R https://repo-default.voidlinux.org/current -r /mnt base-system cryptsetup grub-efi
86+
# cryptsetup luksFormat --type luks1 /dev/sda2 --key-file=/mnt/boot/volume.key
87+
# cryptsetup luksOpen /dev/sda2 swap --key-file=/mnt/boot/volume.key
88+
# mkswap -L cryptswap /dev/mapper/swap
14389
```
90+
## System installation
14491

145-
When it's done, we can enter the chroot with
92+
Start the installation process.
93+
```
94+
# void-installer
95+
```
96+
Configure all the settings.
97+
* Filesystems
98+
99+
need special attention.
100+
101+
Change /dev/mapper/voidlx to ext4. Mount point /
102+
103+
"Do you want to create a filesystem on /dev/mapper/voidlx ?"
104+
105+
***No***
106+
107+
Change /dev/sda1 to vfat. Mount point /boot/efi
108+
109+
"Do you want to create a filesystem on /dev/sda1 ?"
110+
111+
***No***
112+
113+
114+
* Install
115+
116+
The following operations will be executed:
117+
118+
/dev/mapper/voidlx (46G) mounted on / as ext4
119+
120+
When it's done, ***possible with ERROR: faild to install GRUB on /dev/sda!*** (that's OK the void-installer don't know about our crypt setup),
121+
we can enter the chroot with
146122
[`xchroot(1)`](https://man.voidlinux.org/xchroot.1) (from `xtools`) and finish
147123
up the configuration. Alternatively, entering the chroot can be [done
148124
manually](../../config/containers-and-vms/chroot.md#manual-method).
149125

150126
```
151127
# xchroot /mnt
152-
[xchroot /mnt] # chmod 0755 /
153-
[xchroot /mnt] # passwd root
154-
[xchroot /mnt] # echo voidlinux >/etc/hostname
155-
```
156-
157-
and, for glibc systems only:
158-
159-
```
160-
[xchroot /mnt] # echo "LANG=en_US.UTF-8" >/etc/locale.conf
161-
[xchroot /mnt] # echo "en_US.UTF-8 UTF-8" >>/etc/default/libc-locales
162-
[xchroot /mnt] # xbps-reconfigure -f glibc-locales
163128
```
164129

165130
### Filesystem configuration
166131

167-
The next step is editing `/etc/fstab`, which will depend on how you configured
168-
and named your filesystems. For this example, the file should look like this:
132+
First,
133+
find the UUID of the / device.
169134

170135
```
171-
# <file system> <dir> <type> <options> <dump> <pass>
172-
tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0
173-
/dev/dm-0 / ext4 defaults,relatime 0 1
174-
/.swapfile swap swap defaults 0 0
136+
[xchroot /mnt] # blkid -o value -s UUID /dev/sda3
137+
135f3c06-26a0-437f-a05e-287b036440a4
175138
```
176139

177-
UEFI systems will also have an entry for the EFI system partition.
140+
The next step is editing `/etc/fstab`. For this example, the file should look like this:
178141

179142
```
180-
/dev/sda1 /boot/efi vfat defaults 0 0
143+
# <file system> <dir> <type> <options> <dump> <pass>
144+
tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0
145+
/dev/mapper/luks-135f3c06-26a0-437f-a05e-287b036440a4 / ext4 defaults,relatime 0 1
146+
/dev/sda1 /boot/efi vfat defaults 0 0
147+
/dev/mapper/swap none swap defaults 0 0
181148
```
182149

183150
### GRUB configuration
@@ -189,55 +156,34 @@ to `/etc/default/grub`:
189156
GRUB_ENABLE_CRYPTODISK=y
190157
```
191158

192-
Next, the kernel needs to be configured to find the encrypted device. First,
193-
find the UUID of the device.
194-
195-
```
196-
[xchroot /mnt] # blkid -o value -s UUID /dev/sda1
197-
135f3c06-26a0-437f-a05e-287b036440a4
198-
```
199-
200-
Edit the `GRUB_CMDLINE_LINUX_DEFAULT=` line and the `GRUB_CMDLINE_LINUX=` line
159+
Next, the kernel needs to be configured to find the encrypted device.
160+
Edit the `GRUB_CMDLINE_LINUX_DEFAULT=` line
161+
and the `GRUB_CMDLINE_LINUX=` line
201162
in `/etc/default/grub` and add/change
202-
GRUB_CMDLINE_LINUX_DEFAULT="cryptdevice=UUID=135f3c06-26a0-437f-a05e-287b036440a4:voidlx cryptkey=rootfs:/boot/volume.key rd.luks.key=/boot/volume.key:/ rw"
203-
GRUB_CMDLINE_LINUX="rd.auto=1"
204-
to it. Make sure the UUID matches the one for the `sda1` device found in the output of the
205-
[blkid(8)](https://man.voidlinux.org/blkid.8) command above. This will be
206-
`/dev/sda2` on EFI systems. No "root=..." nessecary. Grub takes care about this.
207-
This is working with both initrd systems: dracut and mkinitcpio with no change.
208-
209-
## LUKS key setup
210-
211-
And now to avoid having to enter the password twice on boot, a keyfile will be
212-
configured to automatically unlock the encrypted volume on boot. First, generate
213-
a random keyfile.
214-
215163
```
216-
[xchroot /mnt] # dd bs=1 count=64 if=/dev/urandom of=/boot/volume.key
217-
64+0 records in
218-
64+0 records out
219-
64 bytes copied, 0.000662757 s, 96.6 kB/s
164+
GRUB_CMDLINE_LINUX_DEFAULT="cryptdevice=UUID=135f3c06-26a0-437f-a05e-287b036440a4:voidlx cryptkey=rootfs:/boot/volume.key rd.luks.key=/boot/volume.key:/ rw"
220165
```
221-
Change the permissions to protect the generated key.
222-
223166
```
224-
[xchroot /mnt] # chmod 0400 /boot/volume.key
167+
GRUB_CMDLINE_LINUX="rd.auto=1"
225168
```
169+
to it. Make sure the UUID matches the one for the `sda2` device found in the output of the
170+
[blkid(8)](https://man.voidlinux.org/blkid.8) command above.
171+
No "root=..." nessecary. Grub takes care about this.
172+
This is working with both initrd systems: dracut and mkinitcpio with no change.
226173

227-
Next, add the key to the encrypted volume.
228-
174+
Change `/etc/crypttab`
229175
```
230-
[xchroot /mnt] # cryptsetup luksAddKey /dev/sda1 /boot/volume.key
231-
Enter any existing passphrase:
176+
# crypttab: mappings for encrypted partitions
177+
#
178+
# <name> <device> <password> <options>
179+
swap /dev/sda2 /boot/volume.key luks
232180
```
233-
234-
The keyfile and need to be included in the initramfs. Create
181+
The keyfile and crypttab need to be included in the initramfs. Create
235182
a new file at `/etc/dracut.conf.d/10-crypt.conf` with the following line:
236183

237184
```
238-
install_items+=" /boot/volume.key "
185+
install_items+=" /boot/volume.key /etc/crypttab "
239186
```
240-
241187
## Complete system installation
242188

243189
Next, install the boot loader to the disk.
@@ -246,7 +192,7 @@ Next, install the boot loader to the disk.
246192
[xchroot /mnt] # grub-install /dev/sda
247193
```
248194

249-
Ensure a fresh initramfs is generated:
195+
Ensure a fresh initramfs is generated with all our changes and additions:
250196

251197
```
252198
[xchroot /mnt] # xbps-reconfigure -fa

0 commit comments

Comments
 (0)