Skip to content

Instantly share code, notes, and snippets.

@JosefJezek JosefJezek/auto-mount.sh
Last active May 29, 2019

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

commented Aug 30, 2013

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

This comment has been minimized.

Copy link

commented Sep 17, 2015

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
You can’t perform that action at this time.