Setting up a Samba client on Ubuntu 12.04
Based on MountWindowsSharesPermanently, for Ubuntu after 12.04:
-
Create a share on your Windows machine (the remote share)
-
Install
cifs-utils
sudo apt-get install cifs-utils
- Update the unmount order to prevent CIFS from hanging during shutdown.
sudo update-rc.d -f umountnfs.sh remove
sudo update-rc.d umountnfs.sh stop 15 0 6 .
- Switch to the user that will have permissions over the local share; find out the UID of the user (
$USER
)
grep $USER /etc/passwd | cut -d: -f3
- Create a Samba credentials file,
/home/$USER/.smbcredentials
, and make it only user-readable (chmod og-rw ~/.smbcredentials
)
username=MyUsername
password=MyPassword
# OR:
# username=MyUsername@MyDomain
# password=MyPassword
# OR: (for cifs on Windows Serve 2003)
# username=MyDomain/MyUsername
# password=MyPassword
- Create a new empty directory by the Linux user which will hold the client folder:
mkdir ~/mount
- Very carefully edit
/etc/fstab
, making sure that it is on one line:
//$SERVER_NAME/$SERVER_PATH /home/$USER/mount cifs iocharset=utf8,credentials=/path/to/.smbcredentials,uid=1000 0 0
e.g.
//10.0.2.2/newsroom /home/jevon/newsroom cifs iocharset=utf8,credentials=/home/jevon/.smbcredentials,uid=1000 0 0
- Restart mount and hopefully everything will work!
sudo mount -a
ls -la /home/$USER/mount