Mount Windows Shares During Linux Startup

Submitted by matthiaslink on Sat, 2016-04-23 - 18:25

Make sure that you installed cifs-utils package before starting.

Editing /etc/fstab

The fstab file lists all partitions, shares, logical volumes that should be mounted during boot time or at a later stage (in case "noauto" parameter is given).

  1. Edit the fstab file (with e.g. sudo nano /etc/fstab)
  2. Don't delete or change existing lines but add at the end
    //<server-ip>/<path>    /mnt/<server>/<path>        cifs    uid=matthias,credentials=/home/matthias/.smbcredentials
  3. Save file and exit editor

Make sure that the path that you want to use to mount your share in is existing (use mkdir). Use full home path. ~ might not work properly.

Putting login credentials to a more secure place

  1. Go to home directory with cd ~ and edit .smbcredentials (nano .smbcredentials)
  2. Put following into the file
    username=<your share-user>
    password=<your share-pwd>
  3. Save file and exit editor
  4. sudo chmod 600 .smbcredentials for security reasons because you only want to see what is written in that file ;)

"Integration Test"

  1. Test your configuration by sudo mount -a (this command mounts all filesystems mentioned in fstab)
  2. After reboot you hopefully have all shares mounted.

Anyway there might be different situations where this easy solution don't work. In that case there are plenty of good sites on the web.


Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.