From ff692999de9fdec625ffab60c57f3cc6cf1ccd16 Mon Sep 17 00:00:00 2001 From: Jaromil Date: Sun, 1 Sep 2024 07:57:08 +0200 Subject: [PATCH] enable btrfs light zstd:1 compression by default at mount 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. --- tomb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tomb b/tomb index 4c193203..a3265675 100755 --- a/tomb +++ b/tomb @@ -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