Jellyfin Forum
Bind mounts on Ubuntu & Docker? - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Support (https://forum.jellyfin.org/f-support)
+--- Forum: General Questions (https://forum.jellyfin.org/f-general-questions)
+--- Thread: Bind mounts on Ubuntu & Docker? (/t-bind-mounts-on-ubuntu-docker)

Pages: 1 2 3 4


Bind mounts on Ubuntu & Docker? - 4r5hw45twh - 2025-01-19

So, I am following the guide here. I am on latest Ubuntu LTS version. Not really familiar with Linux a whole lot. I don't understand how to do the actual bind mounts part.
Where it says, "mkdir /path/to/config" and "mkdir /path/to/cache", I just manually created 2 folders on the Desktop called "conf" and "cache". Do I still use the mkdir commands there if I manually did it? Did I name them correctly, or does it matter?
My goal is to plug in my external hard drive and always have my JF server recognize & mount that drive and allow JF, which is in Docker, to access it at all times.

[Image: GwfrdvJ.png]

Or, let's say I do the persistent mount (which for some reason isn't listed first on the guide page) to make config & cache volumes in Docker.If I have multiple folders for the content on my hard drive (anime, tv shows, movies, etc.) do I then do a bind mount for each of those folders? I see the below code...

Code:
--mount type=bind,source=/path/to/media1,target=/media1
--mount type=bind,source=/path/to/media2,target=/media2,readonly
...etc

but what am I looking at here? I guess in my example, the code for the source part would be "/media/username/drivename/Jellyfin/Anime" (at least when I open my external drive and go to that directory and then open a terminal, that's the path)? But now what about the target? What am I linking to there?


RE: Bind mounts on Ubuntu & Docker? - theguymadmax - 2025-01-19

The first thing you should do is mount your external hard drive using fstab: https://forum.jellyfin.org/t-mounting-local-storage-in-linux-linux-permissions-primer

For Docker I have my folders setup like this:
/home/max/Dockers/Jellyfin/Config
/home/max/Dockers/Jellyfin/Cache

I have my exteranl drive mounted here
/media/Media1
/media/Media2

Here is my docker compose
Code:
services:
  jellyfin:
    image: jellyfin/jellyfin:latest
    container_name: jellyfin
    user: 1000:1000
    group_add:
      - "992" #render
    network_mode: 'host'
    volumes:
      - /home/max/Dockers/Jellyfin/Config:/config
      - /home/max/Dockers/Jellyfin/Cache:/cache
      - /media/Media1:/Movies
      - /media/Media2:/Shows
    restart: 'unless-stopped'
    devices:
      - /dev/dri/renderD128:/dev/dri/renderD128



RE: Bind mounts on Ubuntu & Docker? - 4r5hw45twh - 2025-01-19

(2025-01-19, 01:00 AM)theguymadmax Wrote: The first thing you should do is mount your external hard drive using fstab: https://forum.jellyfin.org/t-mounting-local-storage-in-linux-linux-permissions-primer

For Docker I have my folders setup like this:
/home/max/Dockers/Jellyfin/Config
/home/max/Dockers/Jellyfin/Cache

I have my exteranl drive mounted here
/media/Media1
/media/Media2

Couldn't I just uncheck "User session defaults" here and just check the "Mount at system startup" box?

Ok, so if I follow your folder structure with my personal media folders, how do I link mine to JF in Docker? A couple of my folders are:
Anime, TV Shows, Movies - but they're on one drive.

Oh, and ok, so if I have my Config/Cache folder structure like that, how is it linked to Docker? The compose file?

And in my "/media" location, I only see a folder that has my username on it and when I double-click that, it brings up my external hard drive's name.


RE: Bind mounts on Ubuntu & Docker? - theguymadmax - 2025-01-19

Quote:Couldn't I just uncheck "User session defaults" here and just check the "Mount at system startup" box?

Ok, so if I follow your folder structure with my personal media folders, how do I link mine to JF in Docker? A couple of my folders are:
Anime, TV Shows, Movies

Oh, and ok, so if I have my Config/Cache folder structure like that, how is it linked to Docker?

Fstab is the way to go.  

Quote:Ok, so if I follow your folder structure with my personal media folders, how do I link mine to JF in Docker? A couple of my folders are:
Anime, TV Shows, Movies
So in my example, that's 2 external drives and it's mounted in docker here:

Code:
      - /media/Media1:/Movies (Drive 1) dedicated to movies

      - /media/Media2:/Shows  (Drive 2) dedicated to shoes


For your setup - something like this.
Code:
 - /media/Media:Media
   * You'll have access to all folders in here, you don't need to designate in the content type in the docker file.
   * From Jellyfin you'll be able to browse the external drive and choose what folder to mount to each library.

Quote:Oh, and ok, so if I have my Config/Cache folder structure like that, how is it linked to Docker?

It's in the docker compose example. 
Code:
    volumes:

      - /home/max/Dockers/Jellyfin/Config:/config

      - /home/max/Dockers/Jellyfin/Cache:/cache



RE: Bind mounts on Ubuntu & Docker? - 4r5hw45twh - 2025-01-19

(2025-01-19, 01:35 AM)theguymadmax Wrote: Fstab is the way to go.

I made some edits in my above post. Not sure if you saw them before your reply was posted. Ok, so how does this look for my own compose file? From what you just said, I wouldn't need to mount each folder on the drive like I do in my below compose file?

Code:
services:
  jellyfin:
    image: jellyfin/jellyfin
    container_name: jellyfin
    user: 1000:1000
    network_mode: 'host'
    volumes:
      - /home/username/Dockers/Jellyfin/Config:/config
      - /home/username/Dockers/Jellyfin/Cache:/cache
      - type: bind
        source: /media/username/Media/Jellyfin/Anime
        target: /Anime
      - type: bind
        source: /media/username/Media/Jellyfin/TV Shows
        target: /TVShows
      - type: bind
        source: /media/username/Media/Jellyfin/Movies
        target: /Movies
        read_only: true
    restart: 'unless-stopped'

So, if that's the case, I guess my final compose file would be:

Code:
services:
  jellyfin:
    image: jellyfin/jellyfin
    container_name: jellyfin
    user: 1000:1000
    network_mode: 'host'
    volumes:
      - /home/username/Dockers/Jellyfin/Config:/config
      - /home/username/Dockers/Jellyfin/Cache:/cache
      - type: bind
        source: /media/username/Media/Jellyfin
        target: /Media
        read_only: true
    restart: 'unless-stopped'
?

I didn't see the "device" portion on the guide link that you have in your compose file. Do I need that?
Also in the guide, I see, "To run the container in background add -d to the above command." Once I finally get a proper compose file, should I be adding the "-d" part or no?


RE: Bind mounts on Ubuntu & Docker? - theguymadmax - 2025-01-19

Looks fine so far. But yeah you don't need to split out your hard drive, just point to a root folder in it.  The device and render are for GPU support example here: https://jellyfin.org/docs/general/administration/hardware-acceleration/intel#configure-with-linux-virtualization

When you're ready, cd to the directory containing your Docker Compose file and run the following command:
Code:
docker-compose up -d



RE: Bind mounts on Ubuntu & Docker? - 4r5hw45twh - 2025-01-19

(2025-01-19, 01:52 AM)theguymadmax Wrote: Looks fine so far. But yeah you don't need to split out your hard drive, just point to a root folder in it.  The device and render are for GPU support example here: https://jellyfin.org/docs/general/administration/hardware-acceleration/intel#configure-with-linux-virtualization

When you're ready, cd to the directory containing your Docker Compose file and run the following command:
Code:
docker-compose up -d

Ok, and is the "read_only" part at the bottom fine/needed? Noticed it in the guide but not on yours.
So, in regards to this fstab thing...I got my UUID and see it's a NTFS filesystem and I'm at the part where we are making the fstab command. So far, I have:

Code:
UUID=8854yy54ce-6ce9-446-befa-bb6f67e8fe44 /media/username/Media ntfs defaults 0 0

Could I make that a shorter path like yours is? Example: Your mounts seem to be on the root of /media while my path is /media/username/Media and then I see my folders in my hard drive. If possible, it would be nice to have it like yours, where it just shows at /media, but the guide says to make sure the path I choose isn't at Home directory and to make sure the folder already exists and is empty....but my /media root technically isn't empty since it then has "/username/Media" before it shows my folders.

So, basically, it'd be:
Code:
UUID=8854yy54ce-6ce9-446-befa-bb6f67e8fe44 /media ntfs defaults 0 0



RE: Bind mounts on Ubuntu & Docker? - theguymadmax - 2025-01-19

(2025-01-19, 02:05 AM)4r5hw45twh Wrote:
(2025-01-19, 01:52 AM)theguymadmax Wrote: Looks fine so far. But yeah you don't need to split out your hard drive, just point to a root folder in it.  The device and render are for GPU support example here: https://jellyfin.org/docs/general/administration/hardware-acceleration/intel#configure-with-linux-virtualization

When you're ready, cd to the directory containing your Docker Compose file and run the following command:
Code:
docker-compose up -d

Ok, and is the "read_only" part at the bottom fine/needed? Noticed it in the guide but not on yours.
So, in regards to this fstab thing...I got my UUID and see it's a NTFS filesystem and I'm at the part where we are making the fstab command. So far, I have:

Code:
UUID=8854yy54ce-6ce9-446-befa-bb6f67e8fe44 /media/username/Media ntfs defaults 0 0

Could I make that a shorter path like yours is? Example: Your mounts seem to be on the root of /media while my path is /media/username/Media and then I see my folders in my hard drive. If possible, it would be nice to have it like yours, where it just shows at /media, but the guide says to make sure the path I choose isn't at Home directory and to make sure the folder already exists and is empty....but my /media root technically isn't empty since it then has "/username/Media" before it shows my folders.

So, basically, it'd be:
Code:
UUID=8854yy54ce-6ce9-446-befa-bb6f67e8fe44 /media ntfs defaults 0 0

The read only is personal preference. Some people don't want Jellyfin to write files to their media folders. I like to have all my metadata stored with the media folders, like pictures and the NFO files.

You need to make one more level and you need to make the folder before you mount your drive. so cd into /media the sudo mkdir Media so your fstab would look like this
Code:
UUID=8854yy54ce-6ce9-446-befa-bb6f67e8fe44 /media/Media ntfs defaults 0 0

This is my fstab entry:
Code:
UUID=92583D42423D3EEM  /media/Media1  ntfs  defaults,uid=1000,gid=1000  0  0



RE: Bind mounts on Ubuntu & Docker? - 4r5hw45twh - 2025-01-19

(2025-01-19, 02:26 AM)theguymadmax Wrote: You need to make one more level and you need to make the folder before you mount your folders.

Ok, thought so. And possibly my last question before I save this fstab command....

So, in Terminal, I navigated to /etc/fstab with sudo & nano. Do I literally just copy and paste my UUID line on the next empty line, save, then exit?

My current fstab file looks like:
Code:
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>  <type>  <options>      <dump>  <pass>
# / was on /dev/sda2 during curtin installation
/dev/disk/by-uuid/754t335-6f1a-454t-a6d9-eb4343y564aee / ext4 defaults 0 1
# /boot/efi was on /dev/sda1 during curtin installation
/dev/disk/by-uuid/EB0B-03D2 /boot/efi vfat defaults 0 1
/swap.img none swap sw 0 0

Do I simply add:
Code:
UUID=8854yy54ce-6ce9-446-befa-bb6f67e8fe44 /media/FolderName ntfs defaults 0 0
to the very bottom and save?


RE: Bind mounts on Ubuntu & Docker? - theguymadmax - 2025-01-19

Quote:to the very bottom and save?
Yes