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.
Check out my previous blog post here.
Enter your email address to subscribe to this blog and receive notifications of new posts!
If you enjoy this blog check out my affiliate links here to support this site: https://powersjo.com/powersjo-affiliate-links/
God bless you!