How make a persistent CIFS mount in Linux. While setting up a home media server (Jellyfin), I found the need to mount a CIFS (Common Internet File System) share in Linux. The flavor of Linux I’m using is Ubuntu (20.04.5 LTS). The video and pictures are stored on a QNAP server sharing out the media.
Connect to the share
First make a folder where the link will live.
Following that command, here is the easy command to mount a CIFS share in Linux. Be sure to change the paths to the paths in your system.
sudo mount -v -t cifs //10.1.0.22/Movies /mnt/movies/
After entering your credentials to the share, now you can reach the share in Linux. However, after you reboot the mount will be gone. You will have to run the command again. Or, you can add this entry to a file that will mount shares on startup.
This file is /etc/fstab
Save your credentials
Second, in order to get the fstab file to work, you need to store your credentials to the CIFS share. To do this: create a file, save your creds in it, set the owner and change the access level on the file. For example:
sudo nano /etc/win-credentials sudo chown powersjo: /etc/win-credentials sudo chmod 600 /etc/win-credentials
Additionally, here is an example of a password file:
Save the share
Thirdly, now edit the file. For example:
sudo nano /etc/fstab
After that, you can mount the shares in this file by running this command. (This is only to mount the shares right now. If you reboot, you do not need to run this command).
sudo mount -a
Finally, after a reboot, your shares should still be reachable.
This post was originally from my blog, referenced below.
I found these blogs to be helpful when solving this problem here and here. You can find Jellyfin here.
Check out my previous post here.
You can get a 25 PRE token bonus if you use my referral code here. This is to support a decentralized web search engine with presearch.org.
You can earn crypto at Odysee.com, an alternative to YouTube. Use my affiliate link here to watch and earn.
God bless you!