Trying to understand mountpoints and datasets

Dord

Dabbler
Joined
Oct 3, 2016
Messages
15
Very basic question, but I'm trying to validate my understanding of how files are managed between datasets/jails to make sure I don't lose any data in future migrations.

So I have a dataset with all of my files (let's call it Storage-Dataset), and then I have a few jails in a separate dataset (let's call it Jails-Dataset). Each jail has mountpoints so it can access the files/directories relevant to them from Storage-Dataset. My understanding is that those mountpoints essentially act as links between those two foreign datasets, but that the apps running within the jails will still have the ability to alter the files in Storage-Dataset even though they are in a separate dataset, unless the mountpoint is set a read-only.

In a read-only scenario, it seems pretty clear to me, it's just a read-only link, the jail and the app running within it can read and serve files from Storage-Dataset, but can't alter them, and if you delete the jail, the mountpoint/link disappears but the files within Storage-Dataset remain untouched.

Where it gets muddier to me is when it's a read-write scenario, here are my questions:

- When I mount a directory within a jail, and if say I were to FTP into the server, I will see that directory in 2 different places: the source (Pool/Storage-Dataset/FolderA) and also the destination within the jail where I mounted it (say /Pool/Jails-Dataset/Jail1/FolderA). So does that folder actually exist in two places and is constantly synced by the system, or is it really only stored in Storage-Dataset and what I see in Jails-Dataset is only a symlink?

- What happens when the Jail creates a new file in a folder that's mounted from another dataset - I can see a new file created by the jail in both datasets as well, so the mountpoint appears to work both ways. So for example you have NextCloud installed in a jail, with a mountpoint that give the NextCloud jail access to Pool/Storage-Dataset/FolderA and that mounted folder within the jail is also a NextCloud user's folder and they upload a new file in it, then that new file will appear in the jail of course, but in Storage-Dataset as well because of the mountpoint, and if the user deletes the file, then it will be deleted from Storage-Dataset. But what happens if the NextCloud jail and/or dataset is completely deleted, will all files also be deleted from Storage-Dataset?

Thanks!
 
Joined
Oct 22, 2019
Messages
3,641
So does that folder actually exist in two places and is constantly synced by the system, or is it really only stored in Storage-Dataset and what I see in Jails-Dataset is only a symlink?
It only exists in one place. The mountpoint, within your jail's own private filesystem, is actually listing and reading data of the real dataset. Destroy the jail, and nothing happens to the real dataset.

What happens when the Jail creates a new file in a folder that's mounted from another dataset - I can see a new file created by the jail in both datasets as well, so the mountpoint appears to work both ways. So for example you have NextCloud installed in a jail, with a mountpoint that give the NextCloud jail access to Pool/Storage-Dataset/FolderA and that mounted folder within the jail is also a NextCloud user's folder and they upload a new file in it, then that new file will appear in the jail of course, but in Storage-Dataset as well because of the mountpoint, and if the user deletes the file, then it will be deleted from Storage-Dataset. But what happens if the NextCloud jail and/or dataset is completely deleted, will all files also be deleted from Storage-Dataset?
See above.

If it helps, think of the jail's mountpoint as a "drinking straw", and think of the real dataset as a "glass of juice". If your friend, Jailey, wants access to some juice (and for whatever gross reason wants to spit into the juice), the moment you take her straw away, the glass of juice still exists. You can give her the straw once again, and she can continue to drink or spit. You can even hand out straws to other people to access the same glass of juice, but things might get messy.

No matter what, the straw is just a straw. The straw itself has no juice. There is only one glass of juice, regardless if Jailey or her friends also have straws or not.
 

Dord

Dabbler
Joined
Oct 3, 2016
Messages
15
It only exists in one place. The mountpoint, within your jail's own private filesystem, is actually listing and reading data of the real dataset. Destroy the jail, and nothing happens to the real dataset.


See above.

If it helps, think of the jail's mountpoint as a "drinking straw", and think of the real dataset as a "glass of juice". If your friend, Jailey, wants access to some juice (and for whatever gross reason wants to spit into the juice), the moment you take her straw away, the glass of juice still exists. You can give her the straw once again, and she can continue to drink or spit. You can even hand out straws to other people to access the same glass of juice, but things might get messy.

No matter what, the straw is just a straw. The straw itself has no juice. There is only one glass of juice, regardless if Jailey or her friends also have straws or not.

Thank you, that makes perfect sense, love the analogy!
 
Joined
Oct 22, 2019
Messages
3,641
Just be careful that you're not saving files into the jail without using the mountpoint. Otherwise, your files will write directly inside the jail's private filesystem, yet not exist outside of the jail (since you're not using the mountpoint location.)

So for example, say you're using qBittorrent in a jail, and you have a dataset called mypool/downloads where you wish to save your downloaded files.

For the jail, you make a mountpoint that links /mnt/mypool/iocage/jails/qbittorrent/root/media/downloads to the location /mnt/mypool/downloads.

This means in the qBittorrent application, if you set the download directory to /media/downloads, then you should be good. Torrents will download into "/media/downloads", which is in fact a mountpoint to /mnt/mypool/downloads. As expected. If you ever remove the mountpoint in the jail's properties or destroy the jail, the dataset mypool/downloads (and thus /mnt/mypool/downloads) still exists, as do all your newly downloaded torrents.

However...

If in qBittorrent, you set the download directory to /var/db/downloads (or whatever), then torrents will download to /var/db/downloads, which is a directory solely inside the jail's own private filesystem! The downloaded torrents will not live outside of the jail! If you destroy the jail, bye-bye to all your downloads. They never had a chance.

qBittorrent inside the jail is not aware of your ZFS pool or datasets. It will use whatever download location you tell it to. If that location happens to be a mountpoint to a real dataset that exists outside the jail, it doesn't care. (You care, but qBittorrent or whatever app inside the jail doesn't care.)
 

ZiggyGT

Contributor
Joined
Sep 25, 2017
Messages
125
I created 3 pools on my TrueNAS system an 8x3TB and 2 4x3TB. I want to connect the content to the Plex server running in a jail on the same machine. I create a mountpoint to the first pool and everything is working great. I linked the dataset on the first pool to media mountpoint. When I add the mountpoint for the second Plex cannot see any data from the second pool. How do I setup 3 mountpoints to Plex in the Plexjail so I can see all my data? Please help out a newbie.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
How do I setup 3 mountpoints to Plex in the Plexjail so I can see all my data?
You set up each of them to appear at different locations in the plex jail, e.g., /mnt/pool1, /mnt/pool2, and /mnt/pool3.
 

ZiggyGT

Contributor
Joined
Sep 25, 2017
Messages
125
You set up each of them to appear at different locations in the plex jail, e.g., /mnt/pool1, /mnt/pool2, and /mnt/pool3.
danb35, Thanks for answering. I have only ever had one big pool before, so I set the mountpoint to "media". To try to connect to the 3 pools I went in with the shell and created 3 subdirectories for the pools. /mnt/pool2/iocage/jails/HarryP/root/media/media1, ....media\media2 and .....media\media3. That did not work. The mountpoint process does not give a way to create a new directory to attach to. Based on your feedback I created 3 directories at this level /mnt/pool2/iocage/jails/HarryP/root with the shell. That seemed to work just fine.
Why did my subdirectories fail and this worked?
 
Last edited:
Top