btrfsmaintenance
btrfsmaintenance copied to clipboard
skip scrub and trim on virtual hardware
scrub and trim do not make sense on virtual hardware, it should be done on the host system.
I have added to /etc/default/btrfsmaintenance
if grep -qi virtual /sys/devices/virtual/dmi/id/product_name; then
HARDWARE="virtual"
else
HARDWARE="real"
fi
(...)
if [ "$HARDWARE" = "virtual" ]; then
BTRFS_SCRUB_PERIOD="none"
else
BTRFS_SCRUB_PERIOD="monthly"
fi
(...)
if [ "$HARDWARE" = "virtual" ]; then
BTRFS_TRIM_PERIOD="none"
elif systemctl is-enabled fstrim 2>/dev/null | grep -q static; then
# /lib/systemd/system/fstrim.timer
BTRFS_TRIM_PERIOD="none"
else
BTRFS_TRIM_PERIOD="weekly"
fi
I'm not sure it can be said it does not make sense. For a VM that has a dedicated pass-through block device the host will not do it and with this kind of change it would be impossible to do.