Tue 24 Nov 2009
Edit: The following is correct, but this article is better. Also, I was seeing the CIFS shutdown error discussed in [1]-[4]. There is a sophisticated workaround given by [3], but the quick fix in [2,4] seems to work just as well. However, as discussed in [1], both fixes might lead to data corruption problems. (I don’t know). So, I went with my own simple fix, which was simply to unmount the cifs share at shutdown. To do so, download the following script to /etc/init.d/, and symlink to it in /etc/rc0.d and /etc/rc6.d, giving it the prefix K00. The script just does a
#! /bin/sh
### BEGIN INIT INFO
# Provides: unmount_kristen
# Required-Start:
# Required-Stop:
# Should-Stop:
# Default-Start:
# Default-Stop: 0 6
# Short-Description: Just unmounts a samba/cfis share as a bug work around.
# Description: Just unmounts a samba/cfis share as a bug work around.
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
MOUNTPOINT=/path/to/share/mountpoint #e.g., /mnt/myshare
echo "["`date`"] ("`users` ") $1" >> /var/log/unmount_cifs.log
case "$1" in
start)
# No-op
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop|"")
umount $MOUNTPOINT
;;
*)
echo "Usage: umountnfs.sh [start|stop]" >&2
exit 3
;;
esac
:
Also, I do not automatically mount the CIFS share vi
#!/usr/bin/env xdg-open [Desktop Entry] Encoding=UTF-8 Version=1.0 Type=Application Icon[en_US]=gnome-panel-launcher Terminal=false Name[en_US]=Mount CIFS Share Exec=mountshow.sh Name=Mount CIFS Share Icon=/usr/share/pixmaps/gnome-computer.png
The applet file (above) calls a script I wrote called
#!/bin/bash
share=//share_host/share
mountpoint=/path/to/mount/point
options='credentials=/etc/samba/user_name,gid=sambashare,file_mode=0775,dir_mode=0775,users'
# try to mount if not already mounted
if !(mount|grep -q "on ${mountpoint} type"); then
gksudo "mount -t cifs -o $options $share $mountpoint" --description="mount"
fi
# error if it didn't mount
if !(mount|grep -q "on ${mountpoint} type"); then
echo Unable to mount $share at $mountpoint using $options. >&2
exit 1
fi
# open browser if mounted
nautilus --browser $mountpoint 2>/dev/null
[1] bugs.launchpad.net
[2] Ubuntu Forums
[3] Sander Marechal
[4] My Thoughts
[5] Tech Republic
It is easy to edit /etc/fstab so that Samba shares are automatically mounted at startup. However, remember that you need smbfs and smbclient installed. (smbfs is not installed by default under Ubuntu 9.10). Also, you can escape spaces in /etc/fstab using \040 (e.g., My\040Documents). Finally, the mount will be read-only by non-root users unless you specify otherwise. To do so, create a new group (e.g., sambashare) and use the dir_mode option. The /etc/fstab file line will look something like:
//servername/sharename /mountdirectory smbfs username=mywindowsusername,password=mywindowspassword,gid=sambagroup,dir_mode=0775
You can then doing a sudo mount -a to test.
Of course, there are more secure ways, etc. See this article, this article, or just google it.


