Skip to content

Commit

Permalink
enable btrfs light zstd:1 compression by default at mount
Browse files Browse the repository at this point in the history
this comes free and is handled gracefully by btrfs according to
pre-compression heuristics, making it an ideal filesystem choice for
tomb volumes that have compressable contents.

A `compress-force=zstd:1` custom option would deactivate the heuristic
test and compress everything.
  • Loading branch information
jaromil committed Sep 8, 2024
1 parent 4783456 commit ff69299
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tomb
Original file line number Diff line number Diff line change
Expand Up @@ -2384,10 +2384,18 @@ mount_tomb() {
_sudo mkdir -p "$tombmount"

# Default mount options are overridden with the -o switch
local oldmountopts
{ option_is_set -o } && {
local oldmountopts=$MOUNTOPTS
oldmountopts=$MOUNTOPTS
# TODO: safety check MOUNTOPTS coming from user
MOUNTOPTS="$(option_value -o)" }
# TODO: safety check MOUNTOPTS

# default btrfs compression zstd:1 (oportunistic according to pre-compression heuristics)
# see: https://btrfs.readthedocs.io/en/latest/Compression.html#pre-compression-heuristics
[[ "$filesystem" = "btrfs" ]] && {
MOUNTOPTS="$MOUNTOPTS,compress=zstd:1"
}

# safe_mount_options &&
_sudo mount -o $MOUNTOPTS /dev/mapper/${TOMBMAPPER} "${tombmount}"
# Clean up if the mount failed
Expand Down

0 comments on commit ff69299

Please sign in to comment.