2018-08-28 09:25:03 +02:00
|
|
|
|
# FedoraBook
|
|
|
|
|
|
2018-09-05 12:55:22 +02:00
|
|
|
|
Let's put all the fancy features together, we developed in the last years:
|
2018-09-05 12:56:52 +02:00
|
|
|
|
|
2018-09-05 12:55:22 +02:00
|
|
|
|
- Combined kernel+initramfs EFI binaries
|
|
|
|
|
- Secure Boot
|
|
|
|
|
- clevis with TPM2
|
|
|
|
|
- LUKS2
|
|
|
|
|
- dm-verity + squashfs root
|
|
|
|
|
- Flatpak
|
|
|
|
|
- flickerless boot
|
2018-09-05 12:56:52 +02:00
|
|
|
|
|
2018-09-05 12:55:22 +02:00
|
|
|
|
and build a Chromebook like Fedorabook, where you can install all software via Flatpak.
|
|
|
|
|
|
2018-09-05 13:14:58 +02:00
|
|
|
|
This is WIP. Please test and report issues, comments or missing components on https://pagure.io/Fedorabook/issues
|
2018-08-28 09:25:03 +02:00
|
|
|
|
|
2018-09-05 12:37:00 +02:00
|
|
|
|
## Goals
|
|
|
|
|
- secure boot to the login screen
|
2018-09-14 10:24:53 +02:00
|
|
|
|
- immutable base OS
|
2018-09-05 12:37:00 +02:00
|
|
|
|
- ensured integrity to the login screen
|
|
|
|
|
- encrypted volatile data
|
|
|
|
|
- A/B boot switching for updates
|
|
|
|
|
- Flatpak
|
|
|
|
|
- basic desktop
|
|
|
|
|
- optional: bind encrypted data partition to TPM2
|
|
|
|
|
- optional: frequent reencryption of the data partition
|
|
|
|
|
|
|
|
|
|
## Non-Goals
|
2018-09-14 10:24:53 +02:00
|
|
|
|
- can't secure against a remote attacker writing anything to disk
|
|
|
|
|
- can't secure against a remote attacker scraping secret keys from the kernel
|
|
|
|
|
|
|
|
|
|
## FAQ
|
|
|
|
|
### Isn't encrypting everything enough?
|
|
|
|
|
If a remote attacker modifies your binaries in /usr/bin, you cannot be sure of a secure boot
|
|
|
|
|
to the login screen anymore.
|
|
|
|
|
|
|
|
|
|
### Why readonly /etc?
|
|
|
|
|
A remote attacker modifying /etc can completely change your boot sequence and you cannot be sure of a
|
|
|
|
|
secure boot to the login screen anymore.
|
2018-09-05 12:37:00 +02:00
|
|
|
|
|
2018-09-18 12:34:45 +02:00
|
|
|
|
All configurable files have been whitelisted and moved to /cfg.
|
|
|
|
|
|
2018-09-05 12:37:00 +02:00
|
|
|
|
## TODO
|
|
|
|
|
- merge mkimage.sh and clonedisk
|
2018-09-05 15:50:51 +02:00
|
|
|
|
- move all quirks from prepare-root.sh to quirks directory
|
|
|
|
|
- source all quirks depending on package installation on command line options
|
2018-09-05 12:55:22 +02:00
|
|
|
|
- change partition UUIDs for /data
|
2018-09-05 12:56:52 +02:00
|
|
|
|
* UUID for TPM LUKS
|
|
|
|
|
* UUID for LUKS
|
|
|
|
|
* UUID for unencrypted xfs
|
2018-09-05 13:14:58 +02:00
|
|
|
|
- ensure /data to be on same disk as root
|
|
|
|
|
- add "load=<efipath>" to kernel command line via efi stub
|
2018-09-05 13:37:07 +02:00
|
|
|
|
- add admin LUKS key via [public key](https://blog.g3rt.nl/luks-smartcard-or-token.html)
|
|
|
|
|
- sssd
|
2018-09-05 13:42:47 +02:00
|
|
|
|
- support more clevis pins and mixed pins
|
2018-09-05 14:24:25 +02:00
|
|
|
|
- option to always clean data disk on boot
|
2018-09-05 12:55:22 +02:00
|
|
|
|
|
2018-09-05 13:33:02 +02:00
|
|
|
|
## Complete / What works already?
|
|
|
|
|
- boot from single efi binary
|
|
|
|
|
- dm_verity + squashfs immutable, integrity checked root
|
|
|
|
|
- passwd + shadow + group + gshadow decoupled from system in /var
|
|
|
|
|
- bind LUKS2 with tpm2 to machine
|
2018-09-07 16:47:54 +02:00
|
|
|
|
- swap on LUKS2 with tpm2 (no password for resume from disk??)
|
2018-09-18 12:34:45 +02:00
|
|
|
|
- /home /cfg and /var on single data partition
|
|
|
|
|
- Secure Boot
|
2018-09-20 07:24:26 +02:00
|
|
|
|
- selinux
|
2018-10-19 14:32:39 +02:00
|
|
|
|
- firmware update (works, but needs a secure boot signed fwup*.efi)
|
2018-09-05 13:33:02 +02:00
|
|
|
|
|
2018-09-05 12:55:22 +02:00
|
|
|
|
## Known Failures
|
2018-09-05 13:55:47 +02:00
|
|
|
|
- no kernel command line on DELL ( you need a newer systemd https://github.com/systemd/systemd/pull/10001 )
|
|
|
|
|
cp linuxx64.efi.stub to this git repo dir from a compiled upstream systemd
|
2018-09-05 12:55:22 +02:00
|
|
|
|
- gnome-software: can't update firmware repo
|
2018-09-07 16:47:54 +02:00
|
|
|
|
- systemd: failed to umount /var
|
2018-09-20 16:02:21 +02:00
|
|
|
|
- needs a ´´´restorecond -FmvR /cfg /var /home´´´ after first boot, because systemd-tmpfiles does not seem
|
|
|
|
|
to restore all context
|
2018-09-20 16:09:42 +02:00
|
|
|
|
- vga switcheroo is not accessible for lockdown=1, because the kernel does not allow access to /sys/kernel/debug
|
2018-09-05 12:37:00 +02:00
|
|
|
|
|
2018-08-28 09:25:03 +02:00
|
|
|
|
## Create
|
|
|
|
|
|
2018-09-14 10:24:53 +02:00
|
|
|
|
### Prepare the Image
|
|
|
|
|
|
2018-10-24 14:40:18 +02:00
|
|
|
|
For reproducible squashfs builds use https://github.com/squashfskit/squashfskit. Clone it in the
|
|
|
|
|
main FedoraBook directory and build it.
|
|
|
|
|
|
2018-08-28 09:25:03 +02:00
|
|
|
|
```bash
|
|
|
|
|
$ sudo ./prepare-root.sh \
|
|
|
|
|
--pkglist pkglist.txt \
|
|
|
|
|
--excludelist excludelist.txt \
|
2018-09-14 10:24:53 +02:00
|
|
|
|
--name FedoraBook \
|
2018-09-14 16:29:42 +02:00
|
|
|
|
--logo logo.bmp \
|
|
|
|
|
--reposd <REPOSDIR> \
|
|
|
|
|
--releasever 29
|
2018-08-28 09:25:03 +02:00
|
|
|
|
```
|
|
|
|
|
|
2018-09-14 10:24:53 +02:00
|
|
|
|
This will create the following files and directories:
|
2018-10-24 14:40:18 +02:00
|
|
|
|
- ```FedoraBook``` - keep this directory around for updates
|
|
|
|
|
(includes needed passwd/group history and rpmdb)
|
2018-09-14 10:24:53 +02:00
|
|
|
|
- ```FedoraBook-29.<datetime>``` - the resulting <IMGDIR>
|
|
|
|
|
- ```FedoraBook-latest.json``` - a metadata file for the update server
|
|
|
|
|
|
2018-09-05 13:24:27 +02:00
|
|
|
|
or download a prebuilt [image](https://harald.fedorapeople.org/downloads/fedorabook.tgz),
|
2018-09-05 13:23:07 +02:00
|
|
|
|
unpack and use this as ```<IMGDIR>```.
|
|
|
|
|
|
2018-09-14 10:24:53 +02:00
|
|
|
|
## Sign the release
|
|
|
|
|
|
|
|
|
|
Get [efitools](https://github.com/haraldh/efitools.git). Compile and create your keys.
|
|
|
|
|
Copy ```LockDown.efi``` ```DB.key``` ```DB.crt``` from efitools to the fedorabook directory.
|
|
|
|
|
|
2018-10-24 14:40:18 +02:00
|
|
|
|
Rename ```DB.key``` ```DB.crt``` to ```FedoraBook.key``` and ```FedoraBook.crt```
|
|
|
|
|
|
2018-09-14 10:24:53 +02:00
|
|
|
|
Optionally copy ```Shell.efi``` (might be ```/usr/share/edk2/ovmf/Shell.efi```) to the fedorabook directory.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
$ sudo ./mkrelease.sh FedoraBook-latest.json
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
then upload to your update server:
|
|
|
|
|
```bash
|
|
|
|
|
$ TARBALL="$(jq -r '.name' FedoraBook-latest.json)-$(jq -r '.version' FedoraBook-latest.json)".tgz
|
|
|
|
|
$ scp "$TARBALL" FedoraBook-latest.json <DESTINATION>
|
|
|
|
|
```
|
|
|
|
|
|
2018-09-05 13:23:07 +02:00
|
|
|
|
|
2018-08-28 09:25:03 +02:00
|
|
|
|
## QEMU disk image
|
|
|
|
|
```bash
|
2018-09-05 12:37:00 +02:00
|
|
|
|
$ sudo ./mkimage.sh <IMGDIR> image.raw
|
2018-08-28 09:25:03 +02:00
|
|
|
|
```
|
|
|
|
|
|
2018-09-14 10:24:53 +02:00
|
|
|
|
or with the json file:
|
|
|
|
|
```bash
|
|
|
|
|
$ sudo ./mkimage.sh FedoraBook-latest.json image.raw
|
|
|
|
|
```
|
|
|
|
|
|
2018-08-28 09:25:03 +02:00
|
|
|
|
## USB stick
|
|
|
|
|
```bash
|
2018-09-05 12:37:00 +02:00
|
|
|
|
$ sudo ./mkimage.sh <IMGDIR> /dev/disk/by-path/pci-…-usb…
|
2018-08-28 09:25:03 +02:00
|
|
|
|
```
|
|
|
|
|
|
2018-09-14 10:24:53 +02:00
|
|
|
|
or with the json file:
|
|
|
|
|
```bash
|
|
|
|
|
$ sudo ./mkimage.sh FedoraBook-latest.json /dev/disk/by-path/pci-…-usb…
|
|
|
|
|
```
|
|
|
|
|
|
2018-08-28 09:25:03 +02:00
|
|
|
|
## Install from USB stick
|
|
|
|
|
|
2018-09-05 14:10:49 +02:00
|
|
|
|
**Warning**: This will wipe the entire target disk
|
2018-09-05 14:08:50 +02:00
|
|
|
|
|
2018-09-14 10:24:53 +02:00
|
|
|
|
### Preparation
|
|
|
|
|
|
2018-08-28 09:25:03 +02:00
|
|
|
|
- Enter BIOS
|
2018-09-05 12:57:41 +02:00
|
|
|
|
* turn on UEFI boot
|
|
|
|
|
* turn on TPM2
|
2018-09-14 10:24:53 +02:00
|
|
|
|
* set a BIOS admin password
|
2018-08-28 09:25:03 +02:00
|
|
|
|
- Enter BIOS boot menu
|
|
|
|
|
- Select USB stick
|
|
|
|
|
- Login (user: admin, pw: admin)
|
|
|
|
|
- Start gnome-terminal
|
2018-09-14 10:24:53 +02:00
|
|
|
|
|
|
|
|
|
### Installation
|
|
|
|
|
|
|
|
|
|
If you can encrypt your disk via the BIOS, do so.
|
|
|
|
|
|
|
|
|
|
If you cannot:
|
|
|
|
|
|
|
|
|
|
- use the option ```--crypttpm2```, if you have a TPM2 chip
|
|
|
|
|
- use the option ```--crypt``` otherwise
|
|
|
|
|
|
2018-10-19 14:32:39 +02:00
|
|
|
|
```bash
|
|
|
|
|
$ sudo fedorabook-clonedisk <options> <usb stick device> <harddisk device>
|
|
|
|
|
```
|
2018-09-14 10:24:53 +02:00
|
|
|
|
|
|
|
|
|
### Post
|
|
|
|
|
|
2018-08-28 09:25:03 +02:00
|
|
|
|
- reboot
|
|
|
|
|
- remove stick
|
2018-09-05 12:55:22 +02:00
|
|
|
|
|
2018-09-14 10:24:53 +02:00
|
|
|
|
The first boot takes longer as the system tries to bind the LUKS to the TPM2 on the machine.
|
|
|
|
|
It also populates ```/var``` with the missing directories.
|
2018-09-05 13:50:57 +02:00
|
|
|
|
|
|
|
|
|
You can always clear the data partition via:
|
2018-10-19 14:32:39 +02:00
|
|
|
|
```bash
|
2018-09-14 10:24:53 +02:00
|
|
|
|
# wipefs --all --force /dev/<disk partition 5>
|
2018-09-05 13:50:57 +02:00
|
|
|
|
```
|
|
|
|
|
and then either make a xfs
|
2018-10-19 14:32:39 +02:00
|
|
|
|
```bash
|
2018-09-14 10:24:53 +02:00
|
|
|
|
# mkfs.xfs -L data /dev/<disk partition 5>
|
2018-09-05 13:50:57 +02:00
|
|
|
|
```
|
2018-09-14 10:24:53 +02:00
|
|
|
|
or LUKS
|
2018-10-19 14:32:39 +02:00
|
|
|
|
```bash
|
2018-09-14 10:24:53 +02:00
|
|
|
|
# echo -n "zero key" | cryptsetup luksFormat --type luks2 /dev/<disk partition 4> /dev/stdin
|
|
|
|
|
# echo -n "zero key" | cryptsetup luksFormat --type luks2 /dev/<disk partition 5> /dev/stdin
|
2018-09-05 13:50:57 +02:00
|
|
|
|
```
|
|
|
|
|
|
2018-09-14 10:24:53 +02:00
|
|
|
|
On the media created with mkimage.sh, this is partition number *3*.
|
2018-09-05 13:50:57 +02:00
|
|
|
|
|
2018-09-05 12:55:22 +02:00
|
|
|
|
## Post Boot
|
|
|
|
|
|
|
|
|
|
### Persistent journal
|
|
|
|
|
```bash
|
|
|
|
|
$ sudo mkdir /var/log/journal
|
|
|
|
|
```
|
|
|
|
|
|
2018-09-05 15:16:47 +02:00
|
|
|
|
### LUKS
|
2018-09-14 10:24:53 +02:00
|
|
|
|
Set a new LUKS password, if you installed with ```--crypt``` or ```--crypttpm2```.
|
|
|
|
|
The initial password is ```zero key```.
|
|
|
|
|
|
|
|
|
|
## Updating
|
|
|
|
|
|
|
|
|
|
```bash
|
2018-10-19 14:32:39 +02:00
|
|
|
|
# systemd-inhibit fedorabook-update <UPDATE-URL>
|
2018-09-14 10:24:53 +02:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Secure Boot
|
|
|
|
|
|
|
|
|
|
**Warning**: This will wipe all the secure boot keys.
|
|
|
|
|
Make sure the BIOS contains an option to restore the default keys.
|
|
|
|
|
|
|
|
|
|
- Enter BIOS
|
|
|
|
|
* turn on Secure Boot
|
|
|
|
|
* turn on Setup Mode
|
|
|
|
|
- Boot from stick with Shell.efi and LockDown.efi
|
|
|
|
|
- Execute LockDown.efi
|
|
|
|
|
- reset
|
2018-09-18 12:34:45 +02:00
|
|
|
|
- Secure Boot into signed FedoraBook release
|