FuseFS Mounting in Jails - TN12b2

tsnives

Dabbler
Joined
Jan 1, 2019
Messages
12
Great news to all of the rclone lovers like myself out there. With the move to TrueNAS 12 and the new FuseFS structure our friends at iX have been working on we can now use FuseFS mounts inside of jails. When used with rclone, this means being able to mount remote storage on cloud services and such locally.

So here's what you'll want to do to make it work for you.
1) Make sure the Fuse kernel module is being loaded for the host system. To check if it is already loaded for you, we use the handy-dandy "lsvfs" command in shell. There are two things we'll be looking for here. fusefs module being on the list at all and jail being on the list of flags.
Code:
Snives@SnivesNAS:~ # lsvfs
Filesystem                              Num  Refs  Flags
-------------------------------- ---------- -----  ---------------
devfs                            0x00000071     5  synthetic, jail
tmpfs                            0x00000087     3  jail
nfs                              0x0000003a     0  network
fusefs                           0x000000ed     1  synthetic, jail
msdosfs                          0x00000032     0
ufs                              0x00000035     0
nullfs                           0x00000029    10  loopback, jail
procfs                           0x00000002     0  synthetic, jail
unionfs                          0x00000041     0  loopback
fdescfs                          0x00000059     5  synthetic, jail
zfs                              0x000000de    45  jail, delegated-administration
cd9660                           0x000000bd     0  read-only


If it isn't loaded, you've two ways to do it. We can manually load it when we want to using "kldload fuse" which will load fuse.ko for the current session. When you reboot, fuse goes bye-bye. This is obviously good for testing and annoying for long-term usage. I'd recommend starting off this way so you can always reboot through catastrophe. Once you are comfortable with you're setup, you can make this load automatically on boot every time using a system tunable.
Code:
Tunable Setup
Variable: fuseload
Value:yes
Type:loader
Description:Load FuseFS at boot
Enabled : This better be self explanatory :P


Step 2) Make a jail! While FreeBSD has supported FuseFS in jails for a while now, it wasn't enabled in TrueNAS until 12 so I'd use a minimum release of 12.1-RELEASE. I've only tested this successfully in 12.1-RELEASE-p8, but wouldn't expect it to magically break somehow. Be sure to enable Allow_Mount in your config Jail Properties. Maybe I'm blind, but I did not find the other settings I needed in the config wizard so it's time to hop over to the jails config.json. To ensure it's fully built properly, I'd start and stop the jail once to get things going.

Step 3) Editing config.json. So config.json is located in your jail pool at the location [JAILPOOL]/iocage/jails/[JAILNAME]/config.json. For me, my jails are on a small mirrored SSD pool I brilliantly call "SmallMirror" and my jail name was plexpass. Can you guess what software runs in this jail? I'm partial to the nano editor. You use whatever you want. Unless it's vi... vi works fine, but I hate it.

You're going to see plenty of other lines in there. Don't mess with them if you don't know what they do. The lines below are the ones you definitely need to have though so you'll need to add them if they don't exist. Pay attention to formatting, all lines but the last end with a comma to end the line. I've not tried tossing an extra comma onto the last line. Maybe it works, maybe your system becomes self-aware, maybe it won't boot. I'm here to use FuseFS not to find out how that gets parsed.

Code:
nano /mnt/SmallMirror/iocage/jails/plexpass/config.json

{    "allow_mount": 1,
     "allow_mount_devfs": 1,
     "allow_mount_fusefs": 1,
     "enforce_statfs": 1
}


4) Start your jail up!

5) SSH or terminal into that jail

6) Make sure fuse accepts you as a disciple by using out lsvfs command from inside the jail. Depending on what all you pass through to the jail it may well look identical to your host machine. Mine does, because I did a terrible job securing this jail when making it for testing.

7) Install rclone. "pkg install rclone". I don't think anyone reading about tips on how to enable an alternate filesystem in TrueNAS should really get hung up on that detail. If you are, call your geeky buddy that recommended it or tell me what your secret is to finding and having the guts to dive into a beta OS for a file server.

8) rclone config. I'll let you read up more on how to config rclone seperately, but my personal setup uses several remotes. drive to connect to GDrive, crypt to encrypt the data, cache to add a caching mechanism so Google stops temp-banning me, and union to merge my local files and my remote into a single view that I can feed into Plex.

9) Mount the drive! About the most basic you can get is the following... (read up on rclone to learn about optimizing your setup).

Code:
mkdir -p /PlexRemote
mkdir -p /PlexRemoteDB/
nohup rclone mount gunion: /PlexRemote/ --allow-non-empty --allow-other --cache-db-path=/PlexRemoteDB/ 


When you're confident your setup is good, you can take your mount line and drop it into a script to run on boot or you can supposedly mount directly from fstab but I've not tested it well enough yet to recommend that. I'm currently manually mounting myself right now, and I pretty much never reboot so that's been fine :P. I strongly recommend assigning a cache-db-path as I've in the past run into system crashes thanks to the db consuming way too much of my memory when writing to a temp/memory location automatically.
 

naguz

Cadet
Joined
Nov 7, 2020
Messages
1
Thanks!
I was really struggling with this, until google led me to this post. The "enforce_statfs": 1 in the jail config was what I missed.

I have another issue though. I would like the mountpoint to be outside of the jail. The jail has access to a folder on the host, and I would like the mountpoint to be there, so it could be shared by SMB. When I try to mount it outside of the jail. however, nothing ever shows up in the mountpoint. I get no error messages, it simply does not work. Is this at all possible?
 

tsnives

Dabbler
Joined
Jan 1, 2019
Messages
12
Thanks!
I was really struggling with this, until google led me to this post. The "enforce_statfs": 1 in the jail config was what I missed.

I have another issue though. I would like the mountpoint to be outside of the jail. The jail has access to a folder on the host, and I would like the mountpoint to be there, so it could be shared by SMB. When I try to mount it outside of the jail. however, nothing ever shows up in the mountpoint. I get no error messages, it simply does not work. Is this at all possible?

Yeah, it's definitely possible. You need to do it from the main shell though, not from inside the jail. Doing it from inside the jail the virtual file system (vfs) won't be visible. Gotta remember, its not actual data being written to the disk it just pretends like it is there essentially. If the jail was able to fool the host system, that'd be a MAJOR security problem. I really hesitate to recommend doing it from outside the jail though, and if you do be sure you don't have any cloud sync tasks or anything enabled as that has caused me plenty of other issues in the past when the processes managed to collide. You can also create a share from inside the jail instead of doing anything at the host level at all.

These should get you through setting up a basic SAMBA share inside of a jail.


In the most basic sense, you'll create the same user account in the jail you have on your host system if you want it to be seamless for the client. Install SAMBA. Configure SAMBA for the path and add the user you want to allow access to.
 

leafyelin

Cadet
Joined
May 5, 2020
Messages
9
hi
i mount the onedrive to local dir, now i can see files, But when I download files, the whole truenas system crashed and reboot.
i donot know why
 
Top