arkdep/README.md

176 lines
9 KiB
Markdown
Raw Normal View History

2023-12-31 15:50:06 +01:00
# Arkdep
Toolkit for building, deploying and maintaining an immutable, btrfs-based, multi-root system.
2023-08-14 07:27:35 +02:00
2023-12-31 15:50:06 +01:00
Arkdep attempts to be as simple to use as possible and avoid unnecessary abstraction, if you know how to use GNU/Linux picking up Arkdep should be painless for it maintains much of your old familiar workflow.
2023-10-24 11:49:11 +02:00
2024-01-27 00:38:05 +01:00
> [!WARNING]
> Arkdep is still in active development, no more breaking changes are planned since all core functionality is now in, however the current codebase has yet to be thoroughly tested, there may be lingering bugs or other issues
2023-10-23 17:46:23 +00:00
## Usage
2023-12-31 15:50:06 +01:00
### Rolling out Arkdep on a new system
2024-03-06 13:07:06 +01:00
> [!WARNING]
2023-12-31 15:50:06 +01:00
> Arkdep has as of now only been tested on Arch Linux-based systems
2023-10-23 17:46:23 +00:00
2024-03-06 13:07:06 +01:00
> [!NOTE]
> If you are only intend on building images Arkdep does not have to be initted on the system
2023-12-31 15:50:06 +01:00
Arkdep can be easily rolled out and torn down again, it is non-invasive by design. So it _should_ be safe to just toy around with it on your system.
2023-10-23 17:46:23 +00:00
2024-01-12 10:52:53 +01:00
System requirements for usage;
2023-10-23 17:46:23 +00:00
- `/` is partitioned with btrfs
- `/boot` mounted boot partition
2023-11-29 07:12:52 +00:00
- 512MiB boot partition for max 2 deployments, 1GiB recommended
2023-10-23 17:46:23 +00:00
- Systemd-boot bootloader is installed and configured as the primary bootloader
2024-01-12 16:54:16 +01:00
- `dracut`, `wget`, `curl` and `btrfs-progs` are installed
2023-10-23 17:46:23 +00:00
2024-01-12 10:52:53 +01:00
System requirements for image building;
2024-01-12 16:54:16 +01:00
- `arch-install-scripts` and `btrfs-progs` are installed
- A btrfs partitioned workdir, default is `/var/tmp`
2024-01-12 10:52:53 +01:00
2023-12-31 15:50:06 +01:00
The following command will initialize Arkdep, it will deploy a subvolume containing all Arkdep related files excluding kernels and initramfs to `/arkdep`. Kernel and initramfs will instead be stored in `/boot/arkdep` upon generation.
2023-10-23 17:46:23 +00:00
```shell
sudo arkdep init
2024-02-25 07:22:17 +01:00
# Alternatively to init in to a specific directory
2024-03-18 08:22:03 +01:00
sudo ARKDEP_ROOT=/target/dir arkdep init
2023-10-23 17:46:23 +00:00
```
2023-11-20 12:44:58 +00:00
Once ardep is installed you should prepare the overlay located at `/arkdep/overlay`. The overlay is copied directly on to the root filesystem of a new deployment, create directories inside of it as-if it were a root filesystem. For example, `/arkdep/overlay/etc` will be your `/etc` folder.
2023-10-23 17:46:23 +00:00
You will most likely wish to add the following to the overlay;
2023-12-11 19:03:19 +01:00
- passwd, shadow, group, subgid and subuid files containing only entries for root and normal user accounts, system accounts will be supplied via the images and are stored separate in `/usr/lib`.
- fstab file with at least a writable `/var` subvolume configured
- Optionally a locale.conf/locale.gen, localtime symlink and custom dracut configuration
2023-10-23 17:46:23 +00:00
Here is a reference fstab file, take note of the `subvol` mount option;
```shell
2023-11-20 12:44:58 +00:00
UUID=f8b62c6c-fba0-41e5-b12c-42aa1cdaa452 /home btrfs rw,relatime,discard=async,space_cache=v2,subvol=arkdep/shared/home,compress=zstd 0 0
UUID=f8b62c6c-fba0-41e5-b12c-42aa1cdaa452 /var btrfs rw,relatime,discard=async,space_cache=v2,subvol=arkdep/shared/var,compress=zstd 0 0
UUID=f8b62c6c-fba0-41e5-b12c-42aa1cdaa452 /arkdep btrfs rw,relatime,discard=async,space_cache=v2,subvol=arkdep,compress=zstd 0 0
2023-10-24 13:11:38 +00:00
UUID=1223-2137 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 2
2023-10-23 17:46:23 +00:00
```
If you wish to use custom kernel parameters you can edit `/arkdep/templates/systemd-boot`
### Deploying an image
To deploy the latest available image from the default repository run the following command;
```shell
sudo arkdep deploy
```
2023-12-09 04:11:07 +01:00
It will check in with the server defined in `/arkdep/config` as `repo_url` and pull the latest image defined in `$repo_url/$repo_default_image/database`, see [Repository](#Repository) for additional information.
2023-10-23 17:46:23 +00:00
### Deploying a specified image version
A specific image version to pull and deploy can be parsed like so;
```shell
2023-11-12 23:03:29 +00:00
sudo arkdep deploy arkanelinux 00ce35074659538f946be77d9efaefc37725335689
```
The target name may be substituted with a `-` to pull the default target.
```shell
sudo arkdep deploy - 00ce35074659538f946be77d9efaefc37725335689
2023-10-23 17:46:23 +00:00
```
2024-01-04 18:31:33 +01:00
An item may be installed directly from the local `/arkdep/cache` directory, this will skip the database download and checksum check.
```shell
sudo arkdep deploy cache 00ce35074659538f946be77d9efaefc37725335689
```
2024-01-12 10:58:40 +01:00
You do not have to provide the full image name, you can provide it with an impartial image name, the first hit will be pulled and deployed.
2023-10-23 17:46:23 +00:00
```shell
2023-11-12 23:03:29 +00:00
sudo arkdep deploy arkanelinux 00ce
2023-10-23 17:46:23 +00:00
```
2023-08-14 07:27:35 +02:00
## Packaging
### Custom configurations
#### Arch Linux-based
```text
2023-09-21 21:51:57 +02:00
arkdep-build.d
2023-08-14 07:29:46 +02:00
├── customlinux # Directory carrying a custom name
2023-08-14 08:38:13 +02:00
| ├── overlay # (Optional) Root filesystem overlay directory, contents are copied to root
2024-02-22 07:53:03 +01:00
| ├── boostrap.list # Plain text file containing list of packages installed by pacstrap, used for installing the base system
2023-11-12 16:57:40 +00:00
| ├── package.list # (Optional) Plain text file containing list of packages installed by pacman in a chroot, used for aditional package installations
2023-08-14 07:29:46 +02:00
| ├── type # Plain text file, for configs of the Arch type should contain `archlinux`
2024-02-22 14:57:24 +01:00
| ├── extensions # (Optional) Directory for custom scripts
2024-02-22 07:53:03 +01:00
| ├── post-bootstrap.sh # (Optional) Custom bash script which runs after bootstrapping the system
| ├── post-install.sh # (Optional) Custom bash script which runs after system installation is finished
2023-08-14 07:27:35 +02:00
```
### Building an image
2024-02-02 21:01:09 +01:00
> [!NOTE]
> If you are planning to spin custom images you will need to implement some type of mechanism for loading the `/usr/lib` account and group files, Arkane uses a patched [libnss-extrausers](https://github.com/arkanelinux/libnss-extrausers) PAM module to achieve this, Fedora Silverblue uses sssd
2024-01-12 20:00:22 +01:00
Use the arkdep-build script to build your customlinux images, currently the script is assuming to be run from inside of arkdep-build.d's parent directory.
2023-08-14 07:27:35 +02:00
```shell
2023-09-21 21:51:57 +02:00
sudo arkdep-build customlinux
2023-08-14 08:24:10 +02:00
2023-08-14 08:24:46 +02:00
# Or alternatively using a custom image name
sudo ARKDEP_CUSTOM_NAME='customlinux_v1.0' arkdep-build customlinux
2023-08-14 07:27:35 +02:00
```
Once done you can find compressed and uncompressed copies of your new image in the `target` directory.
2023-12-31 15:50:06 +01:00
Arkdep will by default generate a psuedo-random hex string and use this as the name of your image. This behaviour can be overwritten by assigning a custom name to the `ARKDEP_CUSTOM_NAME` environment variable.
2023-08-15 10:31:34 +02:00
## Repository
2023-08-15 10:34:15 +02:00
### Example repository layout
2023-09-21 21:51:57 +02:00
This would be a suitable layout if `repo_url` in `/arkdep/config` is set to `https://repo.example.com/arkdep`.
2023-08-15 10:31:34 +02:00
```text
repo.example.com
2023-09-21 21:51:57 +02:00
├── arkdep
2023-08-15 10:32:55 +02:00
| ├── list # Plain text file containing names of all available image types
2023-08-15 10:31:34 +02:00
| ├── customlinux
2024-03-19 07:00:44 +01:00
| | ├── database # Plain text file containing : delimited lists of all available images `image_name:compression_method:sha_sum`
2023-08-15 10:32:23 +02:00
| | ├── customlinux_v1.0.tar.zst # Compressed disk images
2024-01-19 13:23:04 +01:00
| | ├── customlinux_v1.0.tar.zst.sig # Detached GPG signature
2023-08-15 10:36:30 +02:00
| | ├── customlinux_v2.0.tar.zst # Compressed disk images
2024-01-19 13:23:04 +01:00
| | ├── customlinux_v2.0.tar.zst.sig # Detached GPG signature
2023-12-31 19:15:02 +01:00
| ├── customlinux-gnome
| | ├── database
| | ├── customlinux-gnome_v1.0.tar.zst
| | ├── customlinux-gnome_v2.0.tar.zst
2023-08-15 10:31:34 +02:00
```
### Example repository configuration
2023-12-31 21:30:10 +01:00
The `list` file is in part optional, it not utilized during the deployment process but the user may use it in combination with the `arkdep get-available` command to request a list of all available images in the repository.
2023-08-15 10:31:34 +02:00
```text
customlinux
customlinux-gnome
customlinux-kde
```
2023-08-15 10:45:13 +02:00
The `database` file contains a `:` delimited list of all available images. Each line contains the following information `image_name:compression_method:sha1sum`.
2023-08-15 10:31:34 +02:00
```text
customlinux_v2.0:zst:d5f45b2dac77399b37231c6ec4e864d184d35cf1
2023-08-15 10:45:13 +02:00
customlinux_v1.0:zst:80ba4c7f3ff7a0ebce8e67d5b73f87c56af1b9f3
2023-08-15 10:32:23 +02:00
```
2023-09-21 17:05:47 +02:00
The image name is used to find the actual image, users can also manually refer to a version with `arkdep deploy customlinux customlinux_v1.0`
2023-08-15 10:45:13 +02:00
2023-10-24 11:49:11 +02:00
The compression method is flexible, any compression method tar can infer is supported. Some examples being `xz`, `gz` and `zst`.
2023-08-15 10:45:13 +02:00
2024-03-19 07:00:44 +01:00
The SHA checksum is used to ensure the file was downloaded properly. sha1, sha224, sha256, sha384 and sha512 are all supported.
2023-08-15 10:45:13 +02:00
2023-12-31 15:50:06 +01:00
Arkdep will assume the top most entry in the database is the latest one, when no image version is defined or `latest` is requested it will grab the top most entry.
2023-09-19 21:49:17 +02:00
2024-01-19 13:23:04 +01:00
### Signed images
A GPG signature is by default optional, if available Arkdep will use it instead of the sha1sum to verify image integrity. Arkdep can be configured to require these files to be provided by setting `gpg_signature_check` to `2` in the config file.
A keyring with trusted (private) keys is stored at `/arkdep/keys/trusted-keys`, keys are only accepted in binary format.
2024-03-06 13:02:33 +01:00
Keys can be exported and added to the keyring like so, this process can be repeated to add multiple keys;
```shell
gpg --output example.gpg --export example@example.com
cat example.gpg | sudo tee -a /arkdep/keys/trusted-keys
```
2024-01-19 13:23:04 +01:00
Arkdep assumes the signatures to be identical in name to their parent file with a .sig appended.
Generate a signature like so;
```shell
gpg --output customlinux_v1.0.tar.zst.sig --detach-sig customlinux_v1.0.tar.zst
```
Then simply drop these signatures next to disk image itself.