xxxxxxxxxx
# THIS IS HOW TO MOUNT A DIRECTORY IN UBUNTU ON STARTUP
# First, let’s create the mount directory. You will need a separate directory for each mount:
mkdir /mnt/windowsshare
# Then edit your /etc/fstab file
sudo nano /etc/fstab
# to add this line:
//servername/sharename /mnt/windowsshare cifs defaults,uid=1000,gid=1000,file_mode=0775,dir_mode=0775,nofail 0 0
# OR to mount password-protected network folders
//servername/sharename /mnt/windowsshare cifs username=microsoft_username,password=microsoft_password,uid=1000,gid=1000,file_mode=0775,dir_mode=0775,nofail 0 0
# SETTINGS EXPLANATION
# - servername is the server hostname or IP address
# - cifs is the windows filesystem
# - defaults indicates you don’t need a password to access the share,
# - uid=1000 makes the Linux user (specified by the ID) the owner of the mounted share, allowing them to rename files
# - to see the uid and gid of a user, type in the commandline:
# - id <user_name>
# - nofail makes Ubuntu still boot when the mount fails
# - If there is any space in the server path, you need to replace it by \040, for example:
# -//servername/My\040Documents
# - The 0775 gives read and write priveliges
# For example:
# //10.0.0.1/data_dir /mnt/windowsshare cifs defaults,uid=1000,gid=1000,file_mode=0775,dir_mode=0775 0 0
# After you add the entry to /etc/fstab, type this command to mount the drive:
sudo mount /mnt/windowsshare
sudo nano /etc/fstab
append below line with replacing your values
xxxxxxxxxx
//<shared_path> < local_directory_from_root> cifs credentials=<credentials_file_path>,gid<user_group_id>,uid=<user_id> 0 0
*create credential file including
xxxxxxxxxx
username=<username>
password=<password>