On 14/02/13 10:34, Mark Rogers wrote:
On my old PC I had CIFS entries in fstab and scripts in /etc/network/if-up.d and if-down.d, and whilst the mount worked well the unmount usually locked the PC on shutdown (SysRq-B was about the only thing it would respond to).
I now have a new PC so I want to set this up correctly. All I want is that when eth0 comes up, several Samba shares are mounted, and before eth0 goes down they are unmounted (forcibly if necessary). {} In case I'm overcomplicating this, all I really want is a handful of shares to be available whenever the network is, and for them not to cause me problems if I restart or shutdown networking.
I'm sure there's a better way than what I do, but what I do works for me.
Add an entry in fstab, with these sections:
//192.168.1.100/shared IP address & share name /home/steve/NetworkShare Where you want it mounted cifs share type - I find smb/smbfs doesn't work, and I have to use cifs _netdev,auto,credentials=/root/.CifsCredentials,username=steve,uid=steve,dir_mode=0700 0 0 standard when to fsck options.
The _netdev etc line needs explanation _netdev says only bring this drive up once the network is started. That said, there are errors listed in the logs saying that the drive failed to mount, but, once you're logged in, the drive is mounted. I don't think that _netdev is necessary; I think it works without. auto - standard option - I can't remember exactly what it's for credentials = path to a file that contains the user name and password for that user. File is of the format username=your_user_name password=your_password Make the file readable only to root, and probably best in the /root directory. username=your_user_name,uid=your_user_name = force the user name to be the the name of a particular user. dir_mode = force the directory mode - If I recall, this is an attempt to force files to be owned by the group owner of the directory, BICBW.
The downside of my approach is that share is forced to the username and group of one user. It won't necessarily work in a machine used regularly by multiple users.
The drive mounts automatically. There is no-need to unmount it before shutdown. You can manually unmount with sudo umount /home/steve/NetworkShare
Hope this helps. Would be interested if people have a better way of doing this!
Steve