| 1 |
= Support for TCG Opal 2-compliant Self-Encrypting Disks |
| 2 |
:sedutil-cli-version: 1.15.1 |
| 3 |
|
| 4 |
Beginning with version 2.4, Relax-and-Recover supports self-encrypting disks |
| 5 |
(SEDs) compliant with the TCG Opal 2 specification. |
| 6 |
|
| 7 |
The term "SED" refers to any kind of self-encrypting disk. |
| 8 |
A "TCG Opal 2-compliant disk" or short "Opal disk" is a variant of an SED which implements the Opal 2 standard. |
| 9 |
There are/were other SED variants on the market using proprietary protocols. |
| 10 |
|
| 11 |
In general, these disks all provide full disk encryption in hardware, similar to what LUKS does in software. |
| 12 |
|
| 13 |
Self-encrypting disk support includes |
| 14 |
|
| 15 |
* recovery (saving and restoring the system's SED configuration), |
| 16 |
* setting up SEDs, including assigning a disk password, |
| 17 |
* providing a pre-boot authentication (PBA) system to unlock SEDs at boot time. |
| 18 |
|
| 19 |
== Prerequisites |
| 20 |
|
| 21 |
To enable Relax-and-Recover's TCG Opal 2 support, install the `sedutil-cli` |
| 22 |
(version {sedutil-cli-version}) executable into a directory within root's search |
| 23 |
path. `sedutil-cli` is available for |
| 24 |
https://github.com/Drive-Trust-Alliance/exec/blob/master/sedutil_LINUX.tgz?raw=true[download from Drive Trust Alliance] |
| 25 |
(check version compatibility), or see |
| 26 |
<<How to Build sedutil-cli Version {sedutil-cli-version}>>. |
| 27 |
|
| 28 |
== Quick Start: Setting up Self-Encrypting Disks |
| 29 |
|
| 30 |
NOTE: This section assumes that ReaR was installed from a package repository. If you are using ReaR locally from GitHub: `cd` into the project's base directory, use the configuration file `etc/rear/local.conf`, invoke `usr/sbin/rear`. |
| 31 |
|
| 32 |
=== Step 1: Install Prerequisites |
| 33 |
[arabic] |
| 34 |
. Download the low-level utility `sedutil-cli` (version 1.15.1) from https://github.com/Drive-Trust-Alliance/exec/blob/master/sedutil_LINUX.tgz?raw=true[Drive-Trust-Alliance on GitHub]. |
| 35 |
. Install it into a directory within root's search path (e.g. `/usr/local/sbin`). |
| 36 |
|
| 37 |
=== Step 2: Create Disk Images for PBA and Rescue System |
| 38 |
[arabic] |
| 39 |
. In `/etc/rear/local.conf` add these two lines: |
| 40 |
+ |
| 41 |
[source,bash] |
| 42 |
---- |
| 43 |
OUTPUT=RAWDISK |
| 44 |
OUTPUT_URL="file:///var/lib/rear/output" |
| 45 |
---- |
| 46 |
** To support secure boot, add another line specifying your secure boot loader, e.g. on Ubuntu: |
| 47 |
+ |
| 48 |
[source,bash] |
| 49 |
---- |
| 50 |
SECURE_BOOT_BOOTLOADER="/boot/efi/EFI/ubuntu/shimx64.efi" |
| 51 |
---- |
| 52 |
. Run `sudo rear mkopalpba` (ignore messages about keyboard mappings) |
| 53 |
. Run `sudo rear mkrescue` (ignore messages about keyboard mappings) |
| 54 |
|
| 55 |
=== Step 3: Create a Bootable USB Stick with the Rescue System |
| 56 |
[arabic] |
| 57 |
. Plug in the USB stick to use. |
| 58 |
. Use `lsblk -o +MODEL` to find the correct disk device path for your USB stick (typically `/dev/sdX`). |
| 59 |
. *RE-CHECK. The following command will overwrite the entire USB stick.* |
| 60 |
. Use the following command, replacing `USB-DEVICE` with the USB stick's device name. |
| 61 |
+ |
| 62 |
[source,bash] |
| 63 |
---- |
| 64 |
sudo zcat "/var/lib/rear/output/$(hostname)/rear-$(hostname).raw.gz" | sudo dd bs=1M of=/dev/USB-DEVICE |
| 65 |
---- |
| 66 |
|
| 67 |
=== Step 4: Set up Opal 2 Disk Drives |
| 68 |
|
| 69 |
WARNING: Setting up an SED normally *ERASES ALL DATA ON THE DISK*, as a new data |
| 70 |
encryption key (DEK) will be generated. While `rear opaladmin` includes safety |
| 71 |
measures to avoid accidentally erasing a partitioned disk, do not rely on this |
| 72 |
solely. *Always back up your data and have a current rescue system available.* |
| 73 |
|
| 74 |
. Boot the rescue system just created. |
| 75 |
. *RE-CHECK. The following command will erase selected disks.* |
| 76 |
. Run `rear opaladmin setupERASE _DEVICE_ ...` |
| 77 |
* `_DEVICE_` is the disk device path like `/dev/sda`, or `ALL` for all available |
| 78 |
devices. |
| 79 |
. Verify that disk unlocking works: |
| 80 |
.. Turn off power. |
| 81 |
.. Remove the rescue USB stick. |
| 82 |
.. Turn on power. |
| 83 |
.. Check the PBA boots and unlocks disks. |
| 84 |
+ |
| 85 |
NOTE: After unlocking, there is no OS. This is expected. |
| 86 |
|
| 87 |
=== Step 5: Install the Operating System |
| 88 |
. Boot the rescue system. |
| 89 |
. Deactivate locking: |
| 90 |
+ |
| 91 |
[source,bash] |
| 92 |
---- |
| 93 |
rear opaladmin deactivate |
| 94 |
---- |
| 95 |
. Install the Operating System. |
| 96 |
. Boot the rescue system. |
| 97 |
. Reactivate locking: |
| 98 |
+ |
| 99 |
[source,bash] |
| 100 |
---- |
| 101 |
rear opaladmin reactivate |
| 102 |
---- |
| 103 |
. Remove the rescue USB stick and shutdown the system. |
| 104 |
|
| 105 |
== TCG Opal 2-compliant Self-Encrypting Disks |
| 106 |
|
| 107 |
NOTE: This is a simplified explanation to help understand self-encrypting disks |
| 108 |
in the context of Relax-and-Recover support. |
| 109 |
|
| 110 |
An Opal 2-compliant self-encrypting disk (SED) encrypts disk contents in |
| 111 |
hardware. The SED can be configured to store a user-assigned password and to |
| 112 |
lock itself when powered off. Unlocking the disk after powering up requires the |
| 113 |
user to supply the password. |
| 114 |
|
| 115 |
=== Booting From a Self-Encrypting Disk |
| 116 |
|
| 117 |
How can a system boot from a disk which is locked? The Opal solution is |
| 118 |
metamorphosis. An Opal disk hides or presents different contents depending on |
| 119 |
whether it is locked or not: |
| 120 |
|
| 121 |
* In addition to its regular contents, an Opal disk contains a special area for |
| 122 |
additional boot code, the (unfortunately named) _shadow MBR_. It is small (the |
| 123 |
spec guarantees just 128 MB), write-protected, and normally hidden. |
| 124 |
|
| 125 |
* When *unlocked*, an Opal disk shows its regular contents like any other disk. |
| 126 |
In this state, the system firmware would boot the regular operating system. |
| 127 |
|
| 128 |
* When *locked*, an Opal boot disk exposes its _shadow MBR_ at the start, |
| 129 |
followed by zeroed blocks. In this state, the system firmware would boot the |
| 130 |
code residing in the shadow MBR. |
| 131 |
|
| 132 |
The shadow MBR, when enabled, can be prepared with a _pre-boot authentication_ |
| 133 |
(PBA) system. The PBA system is a purpose-built operating system which |
| 134 |
|
| 135 |
. is booted by the firmware like any other operating system, |
| 136 |
. asks the user for the disk password, |
| 137 |
. unlocks the boot disk (and possibly other Opal 2-compliant SEDs as well), and |
| 138 |
. continues to boot the regular operating system. |
| 139 |
|
| 140 |
== Administering Self-Encrypting Disks |
| 141 |
|
| 142 |
=== Creating a Pre-Boot Authentication (PBA) System |
| 143 |
|
| 144 |
NOTE: This is only required if an SED is to be used as boot disk. |
| 145 |
|
| 146 |
To create a pre-boot authentication (PBA) system image: |
| 147 |
|
| 148 |
. Run `sudo rear mkopalpba` |
| 149 |
|
| 150 |
* The PBA image will appear below the `OPAL_PBA_OUTPUT_URL` directory (see |
| 151 |
`default.conf`) as `$HOSTNAME/TCG-Opal-PBA-$HOSTNAME.raw`. |
| 152 |
|
| 153 |
. If you want to test the PBA system image, |
| 154 |
|
| 155 |
* copy it onto a disk boot medium (a USB stick will do) with `dd |
| 156 |
if="$image_file" bs=1MB of="$usb_device"` (use the entire disk device, not a |
| 157 |
partition), |
| 158 |
|
| 159 |
* boot from the medium just created. |
| 160 |
|
| 161 |
To create a rescue system with an integrated PBA system image: |
| 162 |
|
| 163 |
. Verify that the `OPAL_PBA_OUTPUT_URL` configuration variable points to a local |
| 164 |
directory (which is the default), or set `OPAL_PBA_IMAGE_FILE` to the image |
| 165 |
file's full path. |
| 166 |
|
| 167 |
. Run `sudo rear mkrescue` |
| 168 |
|
| 169 |
=== Setting Up Self-Encrypting Disks |
| 170 |
|
| 171 |
WARNING: Setting up an SED normally *ERASES ALL DATA ON THE DISK*, as a new data |
| 172 |
encryption key (DEK) will be generated. While `rear opaladmin` includes safety |
| 173 |
measures to avoid accidentally erasing a partitioned disk, do not rely on this |
| 174 |
solely. *Always back up your data and have a current rescue system available.* |
| 175 |
|
| 176 |
To set up SEDs: |
| 177 |
|
| 178 |
. Boot the Relax-and-Recover rescue system. |
| 179 |
|
| 180 |
* If SED boot support is required, ensure that the rescue system was built with |
| 181 |
an integrated PBA system image. |
| 182 |
|
| 183 |
. Run `rear opaladmin setupERASE _DEVICE_ ...` |
| 184 |
|
| 185 |
* `_DEVICE_` is the disk device path like `/dev/sda`, or `ALL` for all available |
| 186 |
devices |
| 187 |
* This will set up Opal 2-compliant disks specified by the `_DEVICE_` arguments. |
| 188 |
* You will be asked for a new disk password. The same password will be used for |
| 189 |
all disks being set up. |
| 190 |
* If a PBA is available on the rescue system, you will be asked for each disk |
| 191 |
whether it should act as a boot device for disk unlocking (in which case the PBA |
| 192 |
will be installed). |
| 193 |
* *DISK CONTENTS WILL BE ERASED*, with the following exceptions: |
| 194 |
** If the disk has mounted partitions, the disk's contents will be left |
| 195 |
untouched. |
| 196 |
** If unmounted disk partitions are detected, you will be asked whether the |
| 197 |
disk's contents shall be erased. |
| 198 |
|
| 199 |
. On UEFI systems, see |
| 200 |
<<Setting up UEFI Firmware to Boot From a Self-Encrypting Disk>>. |
| 201 |
|
| 202 |
=== Verifying Disk Setup |
| 203 |
|
| 204 |
If you want to ensure that disks have been set up correctly: |
| 205 |
|
| 206 |
. Power off, then power on the system. |
| 207 |
|
| 208 |
. Boot directly into the Relax-and-Recover rescue system. |
| 209 |
|
| 210 |
. Run `rear opaladmin info` and verify that output looks like this: |
| 211 |
+ |
| 212 |
[options="nowrap"] |
| 213 |
---- |
| 214 |
DEVICE MODEL I/F FIRMWARE SETUP ENCRYPTED LOCKED SHADOW MBR |
| 215 |
/dev/sda Samsung SSD 850 PRO 256GB ATA EXM04B6Q y y y visible |
| 216 |
---- |
| 217 |
+ |
| 218 |
The device should appear with _SETUP_=`y`, _ENCRYPTED_=`y` and _LOCKED_=`y`, |
| 219 |
_SHADOW MBR_ on boot disks should be `visible`, otherwise `disabled`. |
| 220 |
|
| 221 |
. Run `rear opaladmin unlock`, supplying the correct disk password. |
| 222 |
|
| 223 |
. Run `rear opaladmin info` and verify that output looks like this: |
| 224 |
+ |
| 225 |
[options="nowrap"] |
| 226 |
---- |
| 227 |
DEVICE MODEL I/F FIRMWARE SETUP ENCRYPTED LOCKED SHADOW MBR |
| 228 |
/dev/sda Samsung SSD 850 PRO 256GB ATA EXM04B6Q y y n hidden |
| 229 |
---- |
| 230 |
+ |
| 231 |
The device should appear with _SETUP_=`y`, _ENCRYPTED_=`y` and _LOCKED_=`n`, |
| 232 |
_SHADOW MBR_ on boot disks should be `hidden`, otherwise `disabled`. |
| 233 |
|
| 234 |
=== Routine Administrative Tasks |
| 235 |
|
| 236 |
The following tasks can be safely performed on the original system (with `sudo`) |
| 237 |
or on the rescue system. |
| 238 |
|
| 239 |
* Display disk information: `rear opaladmin info` |
| 240 |
|
| 241 |
* Change the disk password: `rear opaladmin changePW` |
| 242 |
|
| 243 |
* Upload the PBA onto the boot disk(s): `rear opaladmin uploadPBA` |
| 244 |
|
| 245 |
* Unlock disk(s): `rear opaladmin unlock` |
| 246 |
|
| 247 |
* Persistently deactivate the locking mechanism on disk(s): `rear opaladmin deactivate` |
| 248 |
|
| 249 |
* Reactivate the locking mechanism on disk(s): `rear opaladmin reactivate` |
| 250 |
|
| 251 |
* For help: `rear opaladmin help` |
| 252 |
|
| 253 |
=== Erasing a Self-Encrypting Disk |
| 254 |
|
| 255 |
To *ERASE ALL DATA ON THE DISK* but retain the setup: |
| 256 |
|
| 257 |
. Boot the Relax-and-Recover rescue system. |
| 258 |
|
| 259 |
. Run `rear opaladmin resetDEK _DEVICE_ ...` |
| 260 |
* `_DEVICE_` is the disk device path like `/dev/sda`, or `ALL` for all available |
| 261 |
devices |
| 262 |
* If mounted disk partitions are detected, the disk's contents will not be |
| 263 |
erased. |
| 264 |
* If unmounted disk partitions are detected, you will be asked whether the |
| 265 |
disk's contents shall be erased. |
| 266 |
|
| 267 |
To *ERASE ALL DATA ON THE DISK* and reset the disk to factory settings: |
| 268 |
|
| 269 |
. Boot the Relax-and-Recover rescue system. |
| 270 |
|
| 271 |
. Run `rear opaladmin factoryRESET _DEVICE_ ...` |
| 272 |
* `_DEVICE_` is the disk device path like `/dev/sda`, or `ALL` for all available |
| 273 |
devices |
| 274 |
* If mounted disk partitions are detected, the disk's contents will not be |
| 275 |
erased. |
| 276 |
* If unmounted disk partitions are detected, you will be asked whether the |
| 277 |
disk's contents shall be erased. |
| 278 |
|
| 279 |
== Details |
| 280 |
|
| 281 |
=== How to Build sedutil-cli Version {sedutil-cli-version} |
| 282 |
|
| 283 |
. Download https://github.com/Drive-Trust-Alliance/sedutil/archive/{sedutil-cli-version}.tar.gz[Drive-Trust-Alliance/sedutil version {sedutil-cli-version}] source code. |
| 284 |
|
| 285 |
. Extract the archive, creating a directory `sedutil-{sedutil-cli-version}`: |
| 286 |
+ |
| 287 |
[source,bash,subs="attributes"] |
| 288 |
---- |
| 289 |
tar xof sedutil-{sedutil-cli-version}.tar.gz |
| 290 |
---- |
| 291 |
|
| 292 |
. Configure the build system: |
| 293 |
+ |
| 294 |
[source,bash,subs="attributes"] |
| 295 |
---- |
| 296 |
cd sedutil-{sedutil-cli-version} |
| 297 |
aclocal |
| 298 |
autoconf |
| 299 |
./configure |
| 300 |
---- |
| 301 |
+ |
| 302 |
NOTE: Ignore the following error: `configure: error: cannot find install-sh, |
| 303 |
install.sh, or shtool in "." "./.." "./../.."` |
| 304 |
+ |
| 305 |
NOTE: If there are any other error messages, you may have to install required |
| 306 |
packages like `build-essential`, then re-run `./configure`. |
| 307 |
|
| 308 |
. Compile the executable (on the x86_64 architecture in this example): |
| 309 |
+ |
| 310 |
[source,bash,subs="attributes"] |
| 311 |
---- |
| 312 |
cd linux/CLI |
| 313 |
make CONF=Release_x86_64 |
| 314 |
---- |
| 315 |
|
| 316 |
. Install the executable into a directory root's search path (`/usr/local/bin` |
| 317 |
in this example): |
| 318 |
+ |
| 319 |
[source,bash,subs="attributes"] |
| 320 |
---- |
| 321 |
cp dist/Release_x86_64/GNU-Linux/sedutil-cli /usr/local/bin |
| 322 |
---- |
| 323 |
|
| 324 |
=== Setting up UEFI Firmware to Boot From a Self-Encrypting Disk |
| 325 |
|
| 326 |
If the UEFI firmware is configured to boot from the disk _device_ (instead of |
| 327 |
some specific operating system entry), no further configuration is necessary. |
| 328 |
|
| 329 |
Otherwise, the UEFI firmware (formerly BIOS setup) must be configured to boot two |
| 330 |
different targets: |
| 331 |
|
| 332 |
. The PBA system (which is only accessible while the disk is locked). |
| 333 |
|
| 334 |
. The regular operating system (which is only accessible while the disk is |
| 335 |
unlocked). |
| 336 |
|
| 337 |
This can be configured as follows: |
| 338 |
|
| 339 |
. Ensure that the PBA system has been correctly installed to the boot drive. |
| 340 |
|
| 341 |
. Power off, then power on the system. |
| 342 |
|
| 343 |
. Enter the firmware setup. |
| 344 |
|
| 345 |
. Configure the firmware to boot from the (only) EFI entry of the boot drive. |
| 346 |
|
| 347 |
. Once a regular operating system has been installed: |
| 348 |
[arabic] |
| 349 |
.. Unlock the disk. |
| 350 |
|
| 351 |
.. Reboot without powering off. |
| 352 |
|
| 353 |
.. Enter the firmware setup. |
| 354 |
|
| 355 |
.. Configure the firmware to boot from the EFI entry of your regular operating |
| 356 |
system. Do not delete the previously configured boot entry for the PBA system. |
| 357 |
|
| 358 |
=== References |
| 359 |
|
| 360 |
* https://github.com/Drive-Trust-Alliance/sedutil[Drive-Trust-Alliance/sedutil:DTA sedutil Self encrypting drive software] |
| 361 |
|
| 362 |
* https://trustedcomputinggroup.org/wp-content/uploads/TCG_Storage-Opal_SSC_v2.01_rev1.00.pdf[TCG Storage Security Subsystem Class: Opal Specification Version 2.01] |
| 363 |
|
| 364 |
* https://trustedcomputinggroup.org[Trusted Computing Group] |