kdave / btrfsmaintenance

Scripts for btrfs maintenance tasks like periodic scrub, balance, trim or defrag on selected mountpoints or directories.
GNU General Public License v2.0
900 stars 79 forks source link

Provide auto argument for BTRFS_DEFRAG_PATHS #54

Open krichter722 opened 6 years ago

krichter722 commented 6 years ago

Like for other path specifications it'd be nice to have the option to specifcy auto as value for BTRFS_DEFRAG_PATHS and let paths considered for defragment be detected automatically.

sten0 commented 6 years ago

Hi @krichter722,

I'm not sure about the feasibility of this, because a snapshot could exist anywhere. One would have to: for each btrfs volume, for each directory (find -type d), and then additionally do something like this for each directory https://github.com/sten0/btrfs-borg/blob/devel/btrfs-borg-functions#L175 P.S. the devel branch of that project isn't in a usable or consistent state at the moment. [edit: oh, and additionally rw snapshots need to be checked and excluded, because snapshots should never be defragmented... There's another function for that in that file]

margau commented 2 months ago

Hi, sorry for bringing up such an old issue again, but I thought about this topic recently while embedding the tooling into config management.

Would it be an option to use https://github.com/kdave/btrfsmaintenance/blob/b1e70f6c99797def13c1d302a603e18cce701a8d/btrfsmaintenance-functions#L25C10-L25C84 without --first-only? This would of course not include snapshots, but at least all "actively used" mounts and subvolumes, and could be documented as such.

For my use case (different subvolumes mounted), this would definitively help, as i usually only want to defragment the "actively used" volumes.