Home > Operating Systems > Automount samba drives

Automount samba drives

I have a network share that gets backups sent to it automatically, so I want to have the network drive automatically mounted on bootup, so the backups will work. You’ll need to make sure you have smbfs installed and then open fstab and edit it.

sudo apt-get install smbfs
sudo gedit /etc/fstab

Add the following to the fstab

# My Network Drives
//192.168.0.11/media /media/media cifs credentials=/home/michael/.mediaserverCredentials,rw,iocharset=utf8,_netdev,uid=1000,gid=1000 0 0
  • _netdev is supposed to make it not try to mount the drive until the network is up and going.
  • credentials is where your access credentials are stored
  • cifs is the samba file system type
  • uid is the user id, exclude for root
  • guid is the group id

You will need to create your .mediaserverCredentials

sudo gedit /home/michael/.mediaserverCredentials

and add the following to it.

username=michael
password=PASSWORD

obviously you will need to put your username and password, and change the paths to something for you. You may want to use /etc/samba/ as a location to store the credentials file. You need to make sure that the file is owned by root, and only readable to root.

sudo chown root:root /home/michael/.mediaserverCredentials
sudo chmod 400 /home/michael/.mediaserverCredentials

I’ve seen it mentioned places to update the unmount order to prevent hanging during shutdown. I’m not sure if this is necessary or not.

sudo update-rc.d -f umountnfs.sh remove
sudo update-rc.d umountnfs.sh stop 15 0 6 .
Categories: Operating Systems Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.