trapexit / mergerfs

a featureful union filesystem
http://spawn.link
Other
4.21k stars 170 forks source link

Is it possible to use 'mount -a' to rebuild a mergerfs pool that is defined in fstab? #1328

Closed Betonhaus closed 5 months ago

Betonhaus commented 5 months ago

Let's say in fstab I have all my drives mounted in /disk, so drive one is /disk/1 and drive two is /disk/2 and so on, and I have the mergerfs pool defined as /disk/* so it automatically pulls new drives in when I run mount -a

however, it doesn't disconnect old drives. so if I remove drive seven and delete the disk/7 mount point, mergerfs will still be expecting disk/7 to be there until you reboot the server. this has led to unexpected conditions, like mergerfs.balance moving files into a folder named "7" inside all of the new drives.

would it be possible to make it so when mount -a is run it will automatically disconnect mountpoints that no longer exist, without requiring rebooting the server to remove them?

trapexit commented 5 months ago

I think you mean branches, not mountpoints. mergerfs doesn't care about what the path is. It isn't limited to mountpoints. And by disconnect do you mean remove from config?

A reboot isn't required. Just a remount or changing via the API.

No, there is no way for mergerfs to catch the mount -a. FUSE doesn't have some signal it can send to the server. It simply mounts again. All mergerfs can do is lazy umount the mountpoint which is already an option. And if /disk/7 is gone then it's not possible that mergerfs being mounted would result in that mountpoint having /disk/7 as it simply isn't there to pick up.

I don't know what you mean by "moving files into a folder named "7" inside all of the new drives."

Betonhaus commented 5 months ago

what I mean was that when I was running 'mergerfs.balance /data' I started noticing files become missing. when I checked the new drives, instead of seeing folders like anime, movies, shows, unavailable the drive would just have a single folder labelled '7' and all the missing folders were inside the folder labelled '7' (so /disk/3/7/ and /disk/4/7/). ('7' was the deleted mount point for the drive that was removed). moving those folders to the root of the drive outside of '7' makes them show up properly again, but I had to reboot the server to make mergerfs.balance work properly.

admittedly there may have been some missed step that rebooting fixed

trapexit commented 5 months ago

I'm not sure I really understand what you say mergerfs.balance is doing. The tool simply reads the list of branches from mergerfs' runtime. It doesn't interact with mergerfs otherwise. It sounds like it has nothing to do with mergerfs. You should look at what paths mergerfs.balance is generating. Everything is printed out when it does it.

Betonhaus commented 5 months ago
current pool layout
/data/
|                
+-- movies/ 
|                
+-- shows/
|                
+-- anime/

existing disks layout
disk1/, disk2/, etc
|                
+-- movies/ 
|                
+-- shows/
|                
+-- anime/

expected outcome
disk4/
|                
+-- movies/  
|                
+-- shows/
|                
+-- anime/

actual outcome
disk4/
|                
+-- 7/  
| --- |           
| ---+-- movies/
| --- |           
| ---+-- shows/
| --- |           
| ---+-- anime/
trapexit commented 5 months ago

What you're talking about is mergerfs.balance. Not mergerfs. Should look at that tool and provide details about the setup.

Betonhaus commented 5 months ago

Thank you, after further analysis I believe the entire issue was due to incorrectly typing the command to rsync the contents of the drive to be removed to a new drive, and is completely unrelated to mergerfs and mergerfs.balance. thank you for your time.