- This line was added.
- This line was removed.
- Formatting was changed.
In this guide you'll learn how to mount a CIFS/SMB share on Ubuntu. Make sure you have your FTP SMB server and credentials ready.
I wrote this guide when creating a shared folder for the GamePanel server so that it can place backups of the game servers on there.I advise you run the following as the root user. Especially step 4!
1. Installing package
sudo apt install cifs-utils
2. Create a folder
This is the folder where you will mount the share to.
sudo mkdir /mnt/backups
3. Add entry to fstab
Open your fstab file
(/etc/fstab). And add something like this to the bottom of the file.
//SERVER_IP_ADDRESS/SHARE_NAME /mnt/backups cifs username=msusername,password=mspassword,iocharset=utf8 0 0
You will note that you have enter the password and username here. This is not advisable since the
fstab file is readable by all users. Will fix this in the next step.
4. Not having our password in the
RUN THIS AS ROOT! Make this file in the home folder of root (by default
/root). Why? Because only root can access this folder or privileged users. This makes sure that other people cannot access the credentials file.
So create and open the file
/root/.smbcredentials using vim or nano. (Eg
sudo vi /root/.smbcredentials)
Save and close and then set the permissions that only root can read it.
sudo chmod 600 /root/.smbcredentials
You can verify it by writing:
sudo ls -al /root/.smbcredentials
If everything is correct you should see this:
Now open up your fstab again and replace the username and password with
Your file should look like this:
//SERVER_IP_ADDRESS/SHARE_NAME /mnt/backups cifs credentials=/root/.smbcredentials,iocharset=utf8 0 0
5. Actually mounting
If you reboot the folder will be mounted automatically. Of course we can manually mount it by entering the command
sudo mount -a