Software notes

How to automatically mount your local network drive on Ubuntu?

Identify your local network drive. For example:

  • Router address: 192.168.0.1
  • USB drive identifier: volume1
  • Samba protocol version: 1.0
  • Username: drive_user
  • Password: drive_password

Create credentials file

vim /home/<username>/.smbcredentials # replace username with your user
# .. put the following content and save the file
username=drive_user
password=drive_password

then setup permissions to file:

cd /home/<username>/.smbcredentials 
sudo chown root .smbcredentials
sudo chmod 600 .smbcredentials

Decide on mounting point

  • Example location: /mnt/Land

Setup auto mounting

sudo vim /etc/fstab

and add the following line (replace <username>) and save the file:

\\\192.168.0.1\volume1  /mnt/Land   cifs    vers=1.0,dom=microsoft,credentials=/home/<username>/.smbcredentials,iocharset=utf8,x-systemd.automount,x-systemd.requires=network-online.target,nofail   0    0

Finally restart ubuntu and verify it works correctly:

sudo reboot now

Verify logs:

grep 'Mounted' /var/log/syslog*

Logs

Nautilus

comments powered by Disqus