[GUIDE] Balancing disks using mergerfs


KyleS

Recommended Posts

As Unraid continues to be completely worthless at managing data, I've gone back to the roots which is mergerfs. Thankfully, there's a modicum of thought, and they have a balance utility. Spinning a container and running balance still maintains the data consistency rules of shfs, and automates splitting as appropriate. It's completely unbelievable how terrible mover is, and how it ignores all placement rules.

 

Of course the container needs to be privileged, with /mnt passed to the container, and /dev/fuse passed as a device. Cheers.

 

FROM alpine:3.17

RUN apk add --no-cache curl && \
    curl -L https://github.com/trapexit/mergerfs-tools/archive/master.tar.gz -o /tmp/mergerfs-tools.tar.gz && \
    tar xvf /tmp/mergerfs-tools.tar.gz mergerfs-tools-master/src/ -C /usr/local/bin --strip-components=2 && \
    chmod +x /usr/local/bin/mergerfs.* && \
    rm -rf /tmp/mergerfs-tools.tar.gz && echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing" | tee -a /etc/apk/repositories && apk add --no-cache mergerfs@testing bash python3 rsync
CMD ["/bin/ash", "-c", "/bin/mkdir /tmp/balance && /bin/mount -t mergerfs '/mnt/disk[0-9]*' /tmp/balance && /usr/local/bin/mergerfs.balance /tmp/balance"]

 

Link to comment

re mergerfs.balance: The original idea was to leave things like that to tools outside the main program so the community could do whatever they want and the it would minimize the risk of having such behavior inside the app where it wasn't really necessary to live. But it really didn't work out that way. Those tools were really just examples which is why I never properly packaged them. For mergerfs v3 (which is still a ways off) I'm considering incorporating some sort of active balance behavior. For me I just spin up another pool and rsync to it where I've removed the underlying drive in question. That way I don't need to recreate any of the policy behavior. I might still keep "balance" and "draining" or whatnot as external to the main app but reuse the code.

  • Like 1
Link to comment
15 minutes ago, trapexit said:

re mergerfs.balance: The original idea was to leave things like that to tools outside the main program so the community could do whatever they want and the it would minimize the risk of having such behavior inside the app where it wasn't really necessary to live. But it really didn't work out that way. Those tools were really just examples which is why I never properly packaged them. For mergerfs v3 (which is still a ways off) I'm considering incorporating some sort of active balance behavior. For me I just spin up another pool and rsync to it where I've removed the underlying drive in question. That way I don't need to recreate any of the policy behavior. I might still keep "balance" and "draining" or whatnot as external to the main app but reuse the code.

 

Yeah, I have a couple war games apps to keep the logic sane, but they never went quite right after hacking on them for a couple hours. I'm still on the road for the holidays, so haven't spent the time to sit down and finish them properly. Really pisses me off that Unraid is this closed paid product that doesn't even get the basics correct.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.