This document describes how to mount CIFS shares permanently. The shares might be hosted on a Windows computer/server, or on a Linux/UNIX server running Samba.
We’re assuming that:
- Network connections have been configured properly.
- Share username on Windows computer is YourWinUser.
- Share password on Windows computer is YouUserPass.
- The Windows computer’s name is servername (this can be either an IP address or an assigned name).
- The name of the share is sharename.
- You want to mount the share in /media/windowsshare.
We run update and upgrade to make sure our repo is up to date
sudo apt-get update && sudo apt-get upgrade
you’ll need the cifs-utils package in order to mount SMB shares. Just type the following command at the terminal:
sudo apt-get install cifs-utils
Create a share folder in Windows system
Create in your system folder which one you want to share with Linux via CIFS
Mounting unprotected (guest) network folders
First, let’s create the mount directory. You will need a separate directory for each mount.
sudo mkdir /media/windowsshare
Then edit your /etc/fstab file (with root privileges)
sudo nano -l /etc/fstab
to add this line:
//servername/sharename /media/windowsshare cifs username=YourWinUser,password=YouUserPass,iocharset=utf8 0 0
- iocharset=utf8 allows access to file with names in non-English languages. This doesn’t work with shares of devices like the Buffalo Tera Station, or Windows machines that export their shares using ISO8895-15.
- If there is any space in the server path, you need to replace it by \040, for example //servername/My\040Documents After you add the entry to /etc/fstab type:
My working entry
//MARCIN-PC/Users/marcin/ansible /home/marcin/ansible cifs username=msusername,password=mspassword,gid=marcin,uid=1000,iocharset=utf8, 0 0
AND DO NOT FORGER TO MONT EVRY TIME YOU RESTART I THINK
sudo mount -a
This will (re)mount all entries listed in /etc/fstab.