btrfsmaintenance icon indicating copy to clipboard operation
btrfsmaintenance copied to clipboard

skip scrub and trim on virtual hardware

Open Framsfex opened this issue 1 year ago • 1 comments

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                                                                                                                                                                                             
                                                                                                                                                                                         

Framsfex avatar Sep 16 '24 13:09 Framsfex

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.

kdave avatar Jan 23 '25 18:01 kdave