Mounting a Windows Share In Ubuntu on Boot
Published August 24th, 2015 at 10:42 AM. by Joe Prochazka
The following is how to mount a Windows share at boot time in Ubuntu these instructions should work on other distributions as well. However depending on the distribution you are using the packages and the way in which they need to be installed may differ. Before going on make sure you have created a Windows share and that the Windows account you will be using within the Linux operating system has the proper permissions within Windows to access it.
First you will need to install a few packages which are needed so that Ubuntu can communicate with Microsoft Windows. Specifically Samba and the CIFS utilities.
sudo apt-get install samba samba-client cifs-utils
Once you have the needed packages installed you will need to create the directory in which the mounted Windows share will be contained.
sudo mkdir /media/share
Next you will want to create a file containing your Windows credentials. This file will be named .smbcredentials and should be located within the root of your home directory. You can pass your credentials in line when you get to the part where you edit the file /etc/fstab but this is not a recommended practice. It is easier to protect the .smbcredentials file from prying eyes than /etc/fstab. Now create the file .smbcredentials...
Which should contain the following edited to contain your Windows credentials...
In order to protect your Windows credentials from those who should not have access to them you should set the permissions so only your Linux account can read them.
chmod 600 ~/.smbcredentials
Now add this line to the file /etc/fstab which when read by the operating system when it comes time to mount the file systems on the machine will mount the Windows share you wish to access. To open the file...
sudo nano /etc/fstab
Once open add the following line to /etc/fstab being sure to specify YOUR Windows server address and share, The path to the directory you created earlier where the share should be located on the Linux machine, And the path to the .smbcredentials file you created earlier as well.
//server.domain.com/share /media/share cifs credentials=/home/user/.smbcredentials,iocharset=utf8,sec=ntlm 0 0
Once you have completed the above steps go ahead and mount the devices.
sudo mount -a
You should now be able to access the folders and files contained within the Windows share by accessing the directory /media/share on your Linux machine.