Skip to content

Commit 9839fe0

Browse files
Merge pull request #3145 from balena-io/rahul/sb-and-fde
Add Secure Boot and Full Disk Encryption reference docs
2 parents 106cb18 + 5804f29 commit 9839fe0

File tree

7 files changed

+302
-0
lines changed

7 files changed

+302
-0
lines changed

.cspell/computer-terms.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ client
8686
cloudiotcore
8787
Cloudlink
8888
CMDMON
89+
CMOS
8990
colorbox
9091
colorette
9192
composeyml
@@ -198,6 +199,7 @@ hotswap
198199
hugepages
199200
hummingboard
200201
HWADDR
202+
hwclock
201203
hyperpixel
202204
icss
203205
idfa
@@ -221,6 +223,7 @@ Jetpack
221223
jetson
222224
journalctl
223225
jridgewell
226+
kexec
224227
keyv
225228
klaw
226229
Lamtzidis
@@ -241,6 +244,7 @@ localcommit
241244
lockr
242245
logind
243246
logshipper
247+
LUKS
244248
macbook
245249
MASKROM
246250
maxpoll
@@ -344,6 +348,7 @@ reflashed
344348
reflashing
345349
reinterpolate
346350
relases
351+
relatime
347352
replug
348353
repostiory
349354
reprovision

config/navigation.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ Reference
127127
[/reference/OS/time]
128128
[/reference/OS/advanced]
129129
[/reference/OS/customer-board-support]
130+
Secure Boot & Full Disk Encryption[/reference/OS/secure-boot-and-full-disk-encryption/overview]
131+
Setup Guides
132+
[/reference/OS/secure-boot-and-full-disk-encryption/generic-x86-64-gpt]
133+
130134

131135
Device supervisor
132136
Supervisor API[/reference/supervisor/supervisor-api]
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
---
2+
title: Secure Boot and Full Disk Encryption for Generic x86_64 (GPT)
3+
excerpt: Setup secure boot and full disk encryption for Generic x86_64 (GPT)
4+
---
5+
6+
# Setup secure boot and full disk encryption for Generic x86_64 (GPT)
7+
8+
This section describes how to setup a device with secure boot and full disk encryption using `Generic x86_64 (GPT)` {{ $names.os.lower }} image. This image should be compatible on a wide range of x86_64 devices. Note that `Generic x86-64 (legacy MBR)` and `Intel NUC` images do not provide secure boot and full disk encryption.
9+
10+
11+
Before diving into how to provision a device with secure boot and full disk encryption, let's look at some important considerations around this feature specifically for x86_64 devices. For more information on the general approach to secure boot, see our docs on a [general overview of our secure boot and full disk encryption implementation][general-sb-fde-overview].
12+
13+
14+
## Important Considerations and Caveats
15+
16+
- {{ $names.os.upper }} does not use the shim first stage bootloader that other Linux distributions do and is usually signed with Microsoft platform keys. {{ $names.os.upper }} is an embedded distribution, and when secure boot is enabled only {{ $names.company.lower }} signed operating systems are allowed to boot.
17+
- Disk encryption and decryption is unattended - there is no user interaction when mounting the encrypted disks as it is expected from an embedded device.
18+
- Secure boot and disk encryption have been designed to work as a bundle in {{ $names.os.lower }} and they cannot be configured separately.
19+
- Only system partitions are encrypted. Any extra storages are not encrypted.
20+
- OS images are signed images and {{ name.company.lower }} manages a secure signing server. We currently use a single key for the platform and consequently we can never provide the key to end users. You can read further on [how we handle keys][key-management-approach].
21+
- It is not possible to configure GRUB or kernel parameters
22+
- There are [other trade-offs][other-considerations] pertaining to debugging and system configuration.
23+
24+
25+
26+
## System requirements
27+
28+
- **Secure Element: Trusted Platform Module (TPM) 2.0**
29+
30+
To use secure boot and full disk encryption, your device must have a Trusted Platform Module (TPM) 2.0 which is the [secure element][secure-element] on x86_64 devices. For initial setup, the TPM must be in a mode that allows enrolling new keys, often called "Setup Mode" in the BIOS/UEFI settings. While most modern x86_64 devices support this, some models may be locked into "Deployed Mode," which prevents key enrollment and is therefore incompatible.
31+
32+
Moreover, TPMs can be of two types:
33+
- Firmware TPM (fTPM): The TPM is integrated directly into the main CPU's firmware.
34+
- Discrete TPM (dTPM): The TPM is a separate, physical chip on the motherboard, external to the CPU.
35+
36+
While {{ $names.os.lower }} technically supports both, we **only** recommend using devices with a firmware TPM (fTPM) for deployments requiring secure boot and disk encryption. The primary reason we advise against using discrete TPMs (dTPMs) is the physical security risk they introduce. A dTPM communicates with the CPU over a bus on the motherboard, typically using protocols like SPI or I2C. This external communication path creates a potential attack vector, which is not present in fTPM.
37+
38+
- **The device should support Unified Extensible Firmware Interface (UEFI)**
39+
40+
- **Persist UEFI settings for the expected lifetime of the device**
41+
42+
As a necessary part of the provisioning process, customers will almost certainly change some UEFI settings to non-default values. The customer should test that these settings will persist for the expected lifetime of their device. For instance, customers should use an RTC / CMOS battery that will endure through the expected lifetime of the device. Note that extended periods without AC / mains power will shorten the life of an RTC battery.
43+
44+
## Setup
45+
46+
There are two steps required to install a secure boot enabled and disk encrypted system:
47+
48+
- Opt-in secure boot mode in the {{ $names.os.lower }} installer
49+
- Configure the device’s Unified Extensible Firmware Interface (UEFI) firmware for secure boot and setup mode
50+
51+
Note that {{ $names.os.lower }} currently does not support updating from a non-secure boot enabled system into a secure boot enabled one. The only way to install a secure boot and disk encrypted system at this moment is by using a {{ $names.os.lower }} installer image.
52+
53+
54+
### Configuring {{ $names.os.lower }} image to opt-in secure boot mode
55+
56+
`Generic x86_64 (GPT)` {{ $names.os.lower }} images ship with the capability to provision a device with secure boot and full disk encryption. While the feature was introduced in {{ $names.os.lower }} `v2.114.21`, it has since been has been hardened for security and updated for broader device compatibility in version `v6.6.1`. {{ $names.company.upper }} recommends that all customers use the most recent releases.
57+
58+
59+
#### Using {{ $names.cloud.lower }}
60+
61+
1. Add a device to your fleet. You should be presented with the following new option:
62+
63+
<img alt="Add a device modal with secure boot and full disk encryption modal" src="/img/common/sb-fde/x86/add-device-modal-sb-fde-x86.webp" width="100%">
64+
65+
2. As mentioned, there are [important considerations and caveats][considerations-caveats] when enabling secure boot and full disk encryption. You will be presented with the following disclaimer when enabling the feature:
66+
67+
<img alt="Warning for considerations when enabling secure boot and full disk encryption" src="/img/common/sb-fde/x86/sb-fde-x86-disclaimer.webp" width="100%">
68+
69+
You can optionally surpress the disclaimer by selecting "Don't show me this warning again for this device type".
70+
71+
You can then proceed to download the configured image.
72+
73+
#### Using {{ $names.cli.lower }}
74+
75+
{{ $names.cli.upper }} versions `16.2.0` or newer allow you to [configure](https://docs.balena.io/reference/balena-cli/#os-configure-image) a {{ $names.os.lower }} installer image to opt-in secure boot by using the following command:
76+
77+
````
78+
balena os configure <image> --secureBoot --version <version> --fleet <fleetName> --device-type generic-amd64
79+
80+
````
81+
82+
### Flash the image to a USB key
83+
84+
The configured image should be flashed to a USB key.
85+
86+
- Insert the USB key into your laptop or computer.
87+
- Write the {{ $names.os.lower }} file you downloaded to the USB key. We recommend using Etcher.
88+
- Wait for writing of {{ $names.os.lower }} to complete.
89+
- Remove the USB key from the host machine.
90+
- Insert the freshly flashed USB key into the Generic x86_64 (GPT).
91+
92+
### Provision the device
93+
94+
Once the image is ready, the device needs to be configured in secure boot setup mode. This depends on the UEFI/BIOS implementation, but in general there are the following steps to consider:
95+
96+
- Reset to the default UEFI configuration.
97+
- Make sure the device is configured to boot in UEFI mode, for example by checking the Compatibility Support Module (CSM) used for Master Boot Record (MBR) booting is disabled.
98+
- Change the boot options to allow booting only from the USB installer/flasher device and the main storage, and choose the USB as first boot option. The flasher will then set the UEFI configuration to boot from the main storage before rebooting.
99+
- Disable restoring factory keys. Some systems default to restoring factory (Microsoft) keys rather than using the {{ $names.company.lower }} keys that will be installed during setup.
100+
- Enable secure boot.
101+
- Reset device to setup mode
102+
103+
On booting in setup mode, the installer will enroll the keys into UEFI variables and encrypt the disks using the TPM device. Note that enrolling the keys manually via the UEFI setup application, while possible on some systems, is not currently supported by {{ $names.os.lower }} as the installer’s bootloader is not signed.
104+
105+
Wait for the device to finish flashing and shutdown. Please wait until all LEDs are off. You can then remove the USB key from the device and turn on the device again.
106+
107+
The device should show up on {{ $names.cloud.lower }}.
108+
109+
### Checking if it worked
110+
111+
__Note__ We are working on adding support for the device to report it's secure boot and full disk encryption status to {{ $names.cloud.lower }}. In the meantime, you can use the following instructions to manually check the status.
112+
113+
1. SSH into the hostOS [using the dashboard web terminal][ssh-dashboard-terminal] or [using the CLI][ssh-cli]
114+
2. Run the following command to check if secure boot is enabled:
115+
116+
```
117+
source /usr/libexec/os-helpers-sb
118+
is_secured && echo "secured" || echo "not secured"
119+
```
120+
121+
The above command returns `secured` if secure boot is enabled and the device is in user mode.
122+
3. Run the following command to check if the disks are encrypted:
123+
124+
```
125+
mount | grep luks
126+
```
127+
You should see a similar output as below:
128+
129+
````
130+
/dev/mapper/luks-ac97b9b4-8708-4095-bf2d-484ab8fd66b9 on /mnt/sysroot/active type ext4 (rw,relatime)
131+
/dev/mapper/luks-422d5d4f-bfec-499f-8cfe-1603d93e52ed on /mnt/state type ext4 (rw,relatime)
132+
/dev/mapper/luks-422d5d4f-bfec-499f-8cfe-1603d93e52ed on /etc/machine-id type ext4 (rw,relatime)
133+
/dev/mapper/luks-9cfb5e61-9a10-48f0-8df9-a1b94db6ccc5 on /mnt/data type ext4 (rw,relatime)
134+
/dev/mapper/luks-f935e12f-a564-426d-b511-e10c35786763 on /mnt/boot type ext4 (rw,relatime)
135+
/dev/mapper/luks-422d5d4f-bfec-499f-8cfe-1603d93e52ed on /etc/fake-hwclock type ext4 (rw,relatime)
136+
/dev/mapper/luks-9cfb5e61-9a10-48f0-8df9-a1b94db6ccc5 on /resin-data type ext4 (rw,relatime)
137+
/dev/mapper/luks-9cfb5e61-9a10-48f0-8df9-a1b94db6ccc5 on /var/lib/docker type ext4 (rw,relatime)
138+
````
139+
140+
[general-sb-fde-overview]:/reference/OS/secure-boot-and-full-disk-encryption/overview/
141+
[key-management-approach]:/reference/OS/secure-boot-and-full-disk-encryption/overview/#keys-and-certificates-in-secure-boot
142+
[other-considerations]:/reference/OS/secure-boot-and-full-disk-encryption/overview/#other-considerations
143+
[considerations-caveats]:/reference/OS/secure-boot-and-full-disk-encryption/generic-x86-64-gpt/#important-considerations-and-caveats
144+
[ssh-dashboard-terminal]:/learn/manage/ssh-access/#using-the-dashboard-web-terminal
145+
[ssh-cli]:/learn/manage/ssh-access/#using-balena-device-ssh-from-the-cli
146+
[secure-element]:/reference/OS/secure-boot-and-full-disk-encryption/overview/#secure-element

0 commit comments

Comments
 (0)