0

I want to mount a LAN Network Drive that I can access from Files/Nautilus as soon as I login to my Ubuntu desktop.

I can do this manually with the following command:

sudo mount -t cifs -o user=user,password=***,vers=1.0  //192.168.XX.XX/sda1 /media/sda1/

If I reboot the system, I loose the file location of my drive and find myself running the command again. Another manual method that works is by :

Cntrl+L and then typing smb://192.168.XX.XX/sda1/

Can you recommend me a tutorial that will allow me to accomplish my goal or let me know the steps to mount this Network drive that is attache to my router BTW.

1 Answers1

0

Custom script option with crontab

  1. Create .sh script
  2. Add your line without sudo:
 #!/bin/bash
 mount -t cifs -o user=user,password=***,vers=1.0  //192.168.XX.XX/sda1 /media/sda1/
  1. Add privileges
sudo chmod 700 ./your_script.sh
  1. Add owenrship to the root user
sudo chwon root:root ./your_script.sh
  1. Modify your contab as sudo user by adding following line
sudo corntab -e
@reboot sleep 30 && /bin/sh /full_path_to_file/your_script.sh

Description

Crontab will lunch your script 30 seconds after reboot (to avoid situation when some services are waking up when you lunch the script)

Ad. 3 and Ad. 4 - Will protect you script, that only users with sudo privileges can read/write/execute.

Ad. 5 - Use sudo crontab to lunch jobs as root user.


Fstab option:

  1. Create file with credentials:
sudo nano /etc/cred_1
username=myUser
password=my$Password!
  1. Privileges for read/write
sudo chmod 600 /etc/cred_1
  1. Open fstab and add line with cifs mount
sudo nano /etc/fstab
//192.168.100.100/folder /home/mnt cifs credentials=/etc/cred_1,users,uid=114,gid=1002,file_mode=0770,dir_mode=0770 0 0
  • uid,gid is an user/group id: id username.
  • file_mode and dir_mode was used because cifs doesn't support umask argument.
Falcon
  • 101
  • 1