Windows share with Linux (fstab)

One major hurdle I had when starting off was being able to use my NAS (Network Attached Storage) with my Linux VM’s (Virtual Machines).

Debian 11 is my flavour of choice, with cifs-utils being installed as a prerequisite.

Linux needs to mount the shares on bootup to achieve maximum uptime and autonomy. I achieved in editing the fstab file.

sudo nano /etc/fstab


This allows me to edit the Linux system’s filesystem table.
Scrolling down to the bottom, I added these lines, replacing everything in the brackets with my configuration.

//[URL]/[sharename] /media/[mountpoint] cifs vers=3.0,credentials=/home/[username]/.sharelogin,iocharset=utf8,file_mode=0777,dir_mode=0777,uid=[username],gid=[username],nofail 0 0


To not have my share login info so easily accessible, I placed them in them in a file called ‘credentials’ located in the /home/[username] directory with permissions -rw------- and it is owned by my user.

sudo nano /home/[username]/.sharelogin


The layout of this file:

username=[username]
password=[password]
domain=[domain]


I currently only use username and password for my shares so remove the domain altogether from the file.

😀