Skip to content

Instantly share code, notes, and snippets.

@JosefJezek
Last active May 29, 2019 16:12
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JosefJezek/6390561 to your computer and use it in GitHub Desktop.
Save JosefJezek/6390561 to your computer and use it in GitHub Desktop.
Auto Mount CIFS / SMB / Samba Share on Ubuntu / Debian
#!/bin/sh
# Auto Mount CIFS / SMB / Samba Share on Ubuntu / Debian
# Author: [Josef Jezek](http://about.me/josefjezek)
# Donate: [Gittip](https://www.gittip.com/josefjezek)
# Link: [Gist](https://gist.github.com/6390561)
# Hourly cron job: 0 */1 * * * /root/auto-mount.sh > /dev/null 2>&1
MOUNT_POINT=/media/data
SHARE=//example.com/data
DOMAIN=example.com
USERNAME=administrator
PASSWORD=ubuntu
if ! mountpoint -q $MOUNT_POINT; then
echo "Mount $MOUNT_POINT"
mount.cifs $SHARE $MOUNT_POINT -o username=$USERNAME,password=$PASSWORD,domain=$DOMAIN,iocharset=utf8,file_mode=0777,dir_mode=0777
fi
@JosefJezek
Copy link
Author

You can download this using a one-liner:

wget https://gist.github.com/josefjezek/6390561/raw/auto-mount.sh && chmod +x auto-mount.sh

@jinstrong
Copy link

HI Josefjezek,
I would suggest that you include package update and manual check/install nfs-common, some times the mount.cifs is not available.

http://askubuntu.com/questions/525243/why-do-i-get-wrong-fs-type-bad-option-bad-superblock-error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment