docs(ZFS): Explain adding a new BE-independent dataset (#3)

This commit is contained in:
hygienic-books 2023-03-27 22:53:38 +02:00
parent 9af9572f36
commit ecc33655db

View File

@ -276,6 +276,8 @@ zpool status zpool
# ZFS setup explained
## Overview
The ZFS pool and dataset setup that makes this tick, explained in plain English.
1. Create zpool with options:
@ -310,6 +312,41 @@ The ZFS pool and dataset setup that makes this tick, explained in plain English.
The complete ZFS structure now exists and is mounted at `/mnt` ready for any `pacstrap`, [debootstrap](https://wiki.debian.org/Debootstrap), `dnf --installroot` or other bootstrapping action.
## Adding another boot environment-independent dataset
Assume that in addition to your `/home` data which lives on `zpool/data/home` you want another dataset that is exempt from Arch Linux snapshots.
Consider an example `/opt/git` directory where a bunch of Git repos are checked out on which you work. You don't want them to be snapshotted - and rolled back - when something goes sideways: they are decoupled from everything else that goes on on your machine so you can easily and safely have a static `/opt/git` directory available in all boot environments.
Move your current `/opt/git` data out of the way for a moment:
```
mv '/opt/git'{,'.bak'}
```
Create datasets
```
zfs create -o canmount=off zpool/data/opt
zfs create zpool/data/opt/git
```
Remember that the `zpool/data` dataset already exists and has that it has both `mountpoint=/` and `canmount=off` set. It is not and cannot be mounted itself, it instead conveniently anchors datasets at `/`. Since the `canmount` dataset property cannot be inherited and defaults to `canmount=on` we have to manually specify `-o canmount=off`. Our new `zpool/data/opt` should not automatically mount into `/opt`.
We then create the child dataset `zpool/data/opt/git`, it defaults to `canmount=on` thus immediately shows up at `/opt/git`.
Move data back into place and clean up temp directory
```
rsync -av --remove-source-files '/opt/git'{'.bak',}
find '/opt/git.bak' -type d -empty -delete
```
An example `zpool/data` dataset may now look like so:
```
# zfs list -r -oname,mountpoint,canmount zpool/data
NAME MOUNTPOINT CANMOUNT
zpool/data / off
zpool/data/home /home on
zpool/data/opt /opt off
zpool/data/opt/git /opt/git on
```
# Development
## Conventional commits