This is a simple collection of systemd
unit files for various tasks maintenance tasks for BTRFS file systems which are desirable to automate.
Caution: I have not been able to find good documentation about what may occur if two btrfs operations, such as balance
and scrub
, overlap with each other. Until I can find a clear answer on this or have sufficient experimental evidence to show that it is unsafe these unit files should be considered experimental and used with caution.
The provide units do the following,
[email protected]
- A template unit which will perform the btrfs balance operation on the btrfs volume at the path given as the systemd unit template parameter.
- Example:
systemctl start [email protected]
assuming/home
is a btrfs volume. - Example:
systemctl start [email protected]
which will perform a balance on/
.-
is howsystemd
encodes the/
path in template units.
[email protected]
- A template unit which will perform the btrfs scrub operation on the btrfs volume at the path given as the systemd unit template parameter.
- Example:
systemctl start [email protected]
assuming/home
is a btrfs volume.
[email protected]
- A template timer unit which will trigger the
[email protected]
at a monthly interval. You can customized the timer values using the standardsystemd
method of drop in units. - Example:
systemctl enable [email protected]
, this will trigger a scrub of/home
once a month.
- A template timer unit which will trigger the
[email protected]
- A template unit which will create a read-only snapshot of the btrfs subvolume specified by the
systemd
unit template value. These snapshots will be saved in/var/lib/btrfs-snapshots
by default, but this value can be changed by overriding theBTRFS_SNAPSHOT_PATH
environment variable for the unit. Each snapshot will be suffixed with ISO 8601 date time, with a resolution to the second. - Example:
systemctl start [email protected]
assuming/home
is a btrfs subvolume.
- A template unit which will create a read-only snapshot of the btrfs subvolume specified by the
[email protected]
- A template timer unit which runs the
[email protected]
unit against the btrfs subvolume at the path given by the template parameter. By default this will run daily, but this can be override with a standardsystemd
drop in unit. - Example:
systemctl enable [email protected]
will create a read-only snapshot of/home
saved to/var/lib/btrfs-snapshost
, assuming it is a btrfs subvolume, every day.
- A template timer unit which runs the
You should probably use a package manager.
# ./configure
# make install
This will install the units into the standard systemd
folder for package provided units, e.g. /usr/lib/systemd/system
.