This snippet will show you how to add a Windows share to Ubuntu on boot.
- Windows 10
- Ubuntu 18.10
Share a folder in Windows 10 (we assume the IP address of this machine is
192.168.20.11and the hidden share is named
Install the CIFS utilities in Ubuntu:
sudo apt install cifs-utils
Add a samba credentials file under your home directory named
.smbcredentialsand assign the proper permissions:
vim ~/.smbcredentials chmod 0640 ~/.smbcredentials
The content of the file should be in the format:
username=<username [can be in the format [email protected]]> password=<password> domain=<domain [optional]>
Note: The credentials are those of a user with share access set up in Windows.
Note 2: If you are mounting the share "system wide" you could add the
.smbcredentialsfile to the
/root/folder and assign the proper permissions as suggested here.
Create a folder where the share will be mounted (in this case:
/media/mySharedFolder) and assign it to your user.
sudo mkdir /media/mySharedFolder sudo chown $USER: /media/mySharedFolder
/etc/fstabfile and add the mount point as follows:
# <file system> <mount point> <type> <options> <dump> <pass> //192.168.20.11/MyShare$ /media/mySharedFolder cifs credentials=/home/<user>/.smbcredentials,uid=<user>,gid=<group>,iocharset=utf8 0 0
Note: If you don't want to use a credentials file (not recommended) instead of writing
credentials=<path>you can write
Try to mount all defined entries:
sudo mount -a
If everything went right, you will have your mounted share in