mergerfs icon indicating copy to clipboard operation
mergerfs copied to clipboard

Allow for fnmatch "guesses" for branches

Open xontik opened this issue 5 years ago • 15 comments

General description

I would like to nest mergerfs mount point /mnt/media <--- mergerfs pool : /mnt/disk1 /mnt/disk2 /mnt/media/MoviesMerged <--- mergerfs pool : /mnt/media/Movies /mnt/media/Movies4k

Expected behavior

It should mount properly on fstab

Actual behavior

the second mount fail during systemd initialisation because the first mount point is not done and so "MoviesMerged" folder do not exist

Precise steps to reproduce the behavior

/etc/fstab

/mnt/data* /mnt/cold-storage fuse.mergerfs defaults,allow_other,direct_io,use_ino,hard_remove,minfreespace=150G,fsname=mergerfs 0 0

/mnt/cold-storage/media/Movies:/mnt/cold-storage/media/Movies4K /mnt/cold-storage/media/MoviesMerged fuse.mergerfs defaults,x-systemd.requires-mounts-for=/mnt/cold-storage,allow_other,direct_io,use_ino,hard_remove,fsname=mergerfs 0 0

NOTE: it work perfectly after boot, if i type : mount /mnt/cold-storage/media/Movies I tried tu use x-systemd.requires= option but no luck :/

I dont know if what i ask for is doable or even advisable but that was a simple way to deal with dual radarr instance :)

System information

Please provide as much of the following information as possible:

mergerfs version: 2.28.1 FUSE library version: 2.9.7-mergerfs_2.28.0 fusermount version: 2.9.9 using FUSE kernel interface version 7.29 Linux Qui-Gon 5.4.0-29-generic #33-Ubuntu SMP Wed Apr 29 14:32:27 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Filesystem Size Used Avail Use% Mounted on udev 32G 0 32G 0% /dev tmpfs 6.4G 1.5M 6.4G 1% /run /dev/vda1 27G 6.3G 20G 24% / /dev/vda15 105M 3.9M 101M 4% /boot/efi mergerfs 15T 4.9T 9.5T 35% /mnt/cold-storage /dev/sdb1 7.3T 3.5T 3.8T 49% /mnt/parity1 /dev/sdd1 7.3T 3.5T 3.8T 49% /mnt/data1 /dev/sda1 7.3T 3.5T 3.8T 49% /mnt/parity0 /dev/sdc1 7.3T 1.5T 5.7T 21% /mnt/data0

xontik avatar May 13 '20 14:05 xontik

What do you suggest? There is nothing I know of to address this outside you properly managing dependencies. mergerfs can't hold up the system waiting for a mount path to appear. Modern systems are explicitly async.

trapexit avatar May 13 '20 14:05 trapexit

I dont know if what i ask for is doable or even advisable but that was a simple way to deal with dual radarr instance :)

I don't understand what you're getting at.

trapexit avatar May 13 '20 14:05 trapexit

Maybe something like when we try to mount a sambe share, a timeout periode, during that periode mergefs while try again to create the pool ?

Or maybe it's not up to you and it fail just because the mount point do not exist ?

I also trie to mount manually with a custom systemd script, no luck either

If there is no solution tu use nested mergerfs pool, I'll try to build myself a script to create symlink when necessary, but it could be nice to have this "nested" feature bake into mergerfs :)

If you have any hint on how I should configure the mount go for it !

xontik avatar May 13 '20 14:05 xontik

Or maybe it's not up to you and it fail just because the mount point do not exist ?

Right. It's a mount error for it not to exist. I have no control over that.

What do you mean "nested"? For what reason. You need to explain what you're trying to accomplish generically. It just confuses the situation to propose solutions when I don't even understand what you're trying to do.

trapexit avatar May 13 '20 14:05 trapexit

My "hint" is to properly model the mounting dependencies in systemd so that the underlying drives are mounted, then the first mergerfs, then second. Whether by putting it all in one unit or doing it with proper systemd dependency management.

trapexit avatar May 13 '20 14:05 trapexit

What do you mean "nested"? For what reason. You need to explain what you're trying to accomplish generically. It just confuses the situation to propose solutions when I don't even understand what you're trying to do.

You right.

I want to have a pool of multiple HDD, that where mergerfs come into place:

/mnt/disk1 & /mnt/disk2 are merged into /mnt/cold-storage Then, in this directory I have a media directory structure

  • media -- Movies -- Shows -- Movies4K

The problem is that emby, my media server, want all file for ONE movie in the same directory, so i need all files & dir in Movies and Movies4K to be merged in case I have the same movie in 1080p & 4K

And i need to have the Movies & Movies4k separated because radarr, my movie download manager, can't work with multiple movie definition. So i have a radarr and radarr4k, each one with their one directory.

underlying drives are mounted, then the first mergerfs, then second.

Problem is that the mount point of the first mergerfs mount do not seems to be a correct target for systemd dependency ?

xontik avatar May 13 '20 14:05 xontik

Emby can't have multiple sources like other software? That's pretty terrible design.

You shouldn't be merging mergerfs paths. You will seriously harm performance. All you need to do is set the source for the second one to be /mnt/disk*/Movies:/mnt/disk*/Movies4K and set the mountpoint to be wherever. If it's just for Emby you don't need it in the same directory path as everything else.

Problem is that the mount point of the first mergerfs mount do not seems to be a correct target for systemd dependency ?

Shouldn't you just need proper Before and After clauses for the mount files? I'm not sure I follow. Worse case you can setup services that depend on the mounts and each other.

trapexit avatar May 13 '20 14:05 trapexit

You shouldn't be merging mergerfs paths. You will seriously harm performance.

Noted !

All you need to do is set the source for the second one to be /mnt/disk*/Movies:/mnt/disk*/Movies4K and set the mountpoint to be wherever. If it's just for Emby you don't need it in the same directory path as everything else.

Great idea

Shouldn't you just need proper Before and After clauses for the mount files?

I did : x-systemd.requires-mounts-for=/mnt/cold-storage and x-systemd.requires=/mnt/cold-storage None worked

And for pure systemd service I did not searched enough I think.

Thanks for your time and this amazing piece of software !

xontik avatar May 13 '20 16:05 xontik

Got two drive /mnt/data0 and /mnt/data1 (many more on the road), I tried to do what you told me before

  • That is working : /mnt/data* /data/raw fuse.mergerfs defaults,allow_other,direct_io,use_ino,hard_remove,minfreespace=150G,fsname=mergerfs 0 0
  • That is not : /mnt/data*/raw /data/raw fuse.mergerfs defaults,allow_other,direct_io,use_ino,hard_remove,minfreespace=150G,fsname=mergerfs 0 0

I dont undertand why

xontik avatar May 13 '20 23:05 xontik

Doesn't work how? At boot? At runtime? If at boot are you sure you've got all the underlying drives mounted before mergerfs starts?

trapexit avatar May 13 '20 23:05 trapexit

sorry missing details again ! And this works /mnt/data0/raw:/mnt/data1/raw /data/raw fuse.mergerfs defaults,allow_other,direct_io,use_ino,hard_remove,minfreespace=150G,fsname=mergerfs 0 0

Indeed in the non working case my drive are mounted after the mergefs pool, i don't undersant the priority system :/

xontik avatar May 13 '20 23:05 xontik

You have to use x-systemd.requires like described https://copyninja.info/blog/systemd_automount_entry.html

It fails because the drives mount after mergerfs and mergerfs isn't able to find anything. Being explicit works because it's not searching for anything. If it can't find it it just takes it as a literal. /mnt/disk*/raw doesn't mean anything to it. Unfortunately, fnmatch can't just "guess". It won't resolve what's not actually found.

I could maybe come up with a way to do that but not sure when I'll have the time to do it.

trapexit avatar May 14 '20 00:05 trapexit

ok so if I use x-systemd.requires I need to be explicite too ? If yes I'd be better listing all drive to begin with.

if no it's perfect

I'll go check right now !

I could maybe come up with a way to do that but not sure when I'll have the time to do it. It could be great :) but thanks again for what you've already done

I'll go check ko-fi.com page after that I finish testing this setup

xontik avatar May 14 '20 00:05 xontik

Ok you need to be explicite with x-systemd.requires or it will wreck the boot process :') I don't close this time if by chance you have time to come up with something :)

xontik avatar May 14 '20 00:05 xontik

Yeah, either way you have to be a bit explicit. Either by defining the dependencies or by listing them to mergerfs.

trapexit avatar May 14 '20 00:05 trapexit