trapexit / mergerfs-tools

Optional tools to help manage data in a mergerfs pool
ISC License
385 stars 44 forks source link

[mergerfs.balance] balance only specified disks #86

Closed CWempe closed 5 years ago

CWempe commented 5 years ago

Lets say I have a pool with three disks.

disk1 containes /other_stuff/. disk2 containes /Media/Movies/. disk3 containes /Media/Movies/. disk4 containes /Media/TV Shows/.

Now I created a folder /Media/TV Shows/ on disk3.

If I start mergerfs.balance the tool starts to move files from /Media/TV Shows/ to disk1 instead of disk3 where the parent folder already exists.

Is there a way I can prevent mergerfs.balance from creating new directories when there is already a matching directory on a disk with less free space?

Otherwise I would like to see a feature to exclude (or include) specific disks from the balancing job.

trapexit commented 5 years ago

The general idea is to balance across all drives in the pool so no it doesn't try preserving paths because you can't know without a full scan and somewhat complex binning what would be a optimal "balance".

Exclude from the target drives?

CWempe commented 5 years ago

Exclude from the target drives?

Yes. Like mergerfs.balance /Media/TV Shows -exclude-disk /dev/disk1 -exclude-disk /dev/disk2

I thought it might have been easy to implement because if I copy files manually to /Media/TV Shows mergerfs knows which disks already have the needed directory and balances to files correctly.

But if it is not easy to implement, ok. :)

trapexit commented 5 years ago

Its easy... just want to make sure I understand the behavior you're looking for. The tool doesn't actually write data through mergerfs. It only uses it to query the underlying information needed moves files between the drives directly. That said if its simply removing drives from the list of targets its a simple process of just black listing those drives.

CWempe commented 5 years ago

I manually moved my files like I wanted, now.

So if this feature will be implemented I think I wont need it anytime soon. :)

But thanks for the quick response.

trapexit commented 5 years ago

It just dawned on me that this is already supported.

  -E EXCLUDEPATH, --exclude-path EXCLUDEPATH
                        fnmatch compatible path filter (can use multiple
                        times)

You can exclude the drives based on their mount point.

-E '/mnt/drive_i_dont_want/*' -E '/mnt/other_drive_i_dont_want/*'
undaunt commented 4 years ago

@trapexit I'm not sure if this is doing what I would expect it to do. I am trying to exclude a drive from being balanced to as a destination, not exclude a drive as being balanced from.

Currently, I'm attempting to exclude a drive, let's call it drive 4, from a balance process. Drive 4 currently has the least used disk space. Disk 3 has slightly more used space, and disks 1 and 2 are almost full.

My intent is to wholly exclude any data from winding up on disk 4, and by running balance and excluding disk 4, balance out some portion of data from the more full disk(s) to disk 3.

If I do the following, it immediately begins trying to copy data from disk 1 to disk 4.

mergerfs.balance /mnt/storage/media/ -E '/mnt/disk4/*'

/mnt/storage is the mergerfs mount of disks 1 - 4. Is this what should be happening? Am I just misunderstanding the feature set? Thank you.

Edit: My conceivable workaround right now would be to create a duplicate mergerfs mount of only disks 1 - 3 in a temporary mount point and run balance against that.

trapexit commented 4 years ago

The exclude arguments is about excluding the files from being balanced. Not about excluding targets. As the descriptions mention they are file and path filters. The targets are just the list of branches. If you want that that'd be a new feature.

undaunt commented 4 years ago

Makes sense. I think I was asking similarly for what CWempe wanted above - to prevent the disk with the least used space from having things copied to it if another disk, with more used space but less than the full disk, already has that directory - and then you had said the feature already exists, so maybe I misunderstood.

I'll just stand up a temp mount that doesn't include disk4 to run the balance.

trapexit commented 4 years ago

I was under the impression that the question was about excluding the drive from picking up files from "target" disks. Maybe I misunderstood. Regardless, it's trivial to add removing drives from being targets.

undaunt commented 4 years ago

If it would be simple to add, that would truly be excellent. Thanks either way, I'm sure you're busy.