As per subject really!
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).
I've looked at upstart as a possibility but I don't see how to run a script before networking goes down, unless I edit the relevant network script (I don't want to change system scripts).
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 using Kubuntu 12.10
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
On 14 February 2013 22:56, steve-ALUG@hst.me.uk wrote:
I'm sure there's a better way than what I do, but what I do works for me. [...]
Thanks, that's all more-or-less how I had it before I switched PCs, I've now replicated your config as it was easier than digging out my old config.
I don't recall now why I messed around wth unmounting the shares on network down, but I'm almost certain it was because when I didn't (ie the config I have now) that's when it locked up on shutdown, and unmounting them fixed that, although not reliably.
But I've just shut the PC down without issues so maybe it's no longer an issue. The old PC was also on 12.10, but Ubuntu not Kubuntu so there may be a difference there. I switched to Kubuntu because despite my best efforts to get along with Unity I gave up because too many things just didn't work correctly, so maybe I'll just add this to the list!
(To be fair, Gnome would at least allow me to open a document across a Windows share and save it again without problems, with KDE it does seem that CIFS is pretty much essential to make life easy.)