In this example, a Jellyfin media server running on Docker requires an external Hetzner Storage box to be mounted.
Important considerations:
Plan:
Using the plan above will allow the server to reboot and ensure that the storage mount is available within Jellyfin.
First create a mount point for your CIFS storage share:
mkdir /root/jellyfin/media/storage
Create a systemd service file mount file for the CIFS share:
nano /etc/systemd/system/root-jellyfin-media-storage.mount
The name of the systemd mount (service) file is very important and must be the same as the mount point. For example if your mount point is /tmp/mnt then the location and file name should be:
/etc/systemd/system/tmp-mnt.mount
Now paste the following within the file:
[Unit]
Description=Used to mount Hetzner Storage block as CIFS. Used by Jellyfin for media files.
[Mount]
What=//uXXXXXX.your-storagebox.de/uXXXXXX-sub5
Where=/root/jellyfin/media/storage
Type=cifs
Options=user=XXXXXX,password=XXXXXX,uid=0,gid=0
[Install]
WantedBy=multi-user.target
With the configuration above:
Create the following file:
nano /etc/systemd/system/root-jellyfin-media-storage.automount
Like the previous step, the name of the systemd auto mount file is very important and must be the same as the mount point. For example if your mount point is /tmp/mnt then the location and file name should be:
/etc/systemd/system/tmp-mnt.automount
Paste the following within the file:
[Unit]
Description=Automount Remote Hetzner Storage as CIFS for use by Jellyfin
[Automount]
Where=/root/jellyfin/media/storage
[Install]
WantedBy=multi-user.target
With the configuration above:
Now start the newly created service:
systemctl start root-jellyfin-media-storage.mount
Now enable the newly created service to start on boot:
systemctl enable root-jellyfin-media-storage.automount
Now you should have your CIFS storage mounting as a service. The next step is to prevent Docker from starting before the CIFS share service is started.
The usual CIFS share address for Hetzner Storage Box is the following:
//<username>.your-storagebox.de/backup
Ensure you use /backup, refer to this. The above ONLY applies if you are using the main account for your Hetzner Storage Box. If you are using a sub account the following applies:
//<username>.your-storagebox.de/<username>-subx
For example if your username is u187432 and your sub account is u187432-sub9 then your CIFS share address would be:
//u187432.your-storagebox.de/u187432-sub9
To delay Docker starting until our storage service starts we need to edit the Docker systemd file:
nano /usr/lib/systemd/system/docker.service
Now we can ensure our storage mount service is listed as a Wants= service. Look for the following line:
Wants=network-online.target containerd.service
Now add the following to the line:
Wants=network-online.target containerd.service root-jellyfin-media-storage.mount
Replace the root-jellyfin-media-storage.mount with the name of your file.
This should ensure that after the server reboots Docker / Jellyfin will not be started until our storage mounts.
For more useful articles please visit our Knowledgebase home page.