Skip to content

isomarcte/btrfs-systemd-units

Repository files navigation

BTRFS Systemd Units

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.

Usage

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 how systemd 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 standard systemd method of drop in units.
    • Example: systemctl enable [email protected], this will trigger a scrub of /home once a month.
  • [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 the BTRFS_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.
  • [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 standard systemd 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.

Installation

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.

About

Various Systemd units for the BTRFS filesystem

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published