0

I'm using ubuntu 18.04 and I need to check some logs from windows shares. I mount these shares with this command:

sudo mount -v -t cifs -o username=me,password=pass //network-adr/logs ~/mylocaldir/log

It works fine, except if local network disconnects. And I need to occasionally disconnect my local network. If I do it and don't unmount the directory first, my gnome shell hangs and I need to ctrl + alt + f3 to reboot the system (or battle the mount, or restart gnome shell).

I tried using options like vers=3.0 and hard, but they didn't solved the issue. Is there a way I can mount these shares without risking crashing my gnome if the network dies?

0

What you are describing is a use case for a systemd automount.

You accomplish that by adding an entry into /etc/fstab that in your case would look something like this:

//network-adr/logs /home/bruno/mylocaldir/log cifs username=me,password=pass,noauto,x-systemd.automount,x-systemd.idle-timeout=10 0 0

Then make systemd happy by running:

sudo systemctl daemon-reload
sudo systemctl restart remote-fs.target

noauto = prevents the share from mounting at boot.

x-systemd.automount = will mount the share when the mount point is accessed - on demand

x-systemd.idle-timeout = sets the time in seconds when the system will automatically unmount the share when it detects no activity.

It is all fairly seamless to the user. Click on the mount point and it mounts without user intervention. If it's not used in 10 seconds ( or 20, 30, ..etc.. ) it will unmount without user intervention.

Anything will trigger the automount: You accessing the mount point in your file manager, some script you may create that accesses the mount point or subfolder of that mount point, etc..

  • Tried this solution, it auto mounts and works fine, but when I disconnect from ethernet the gnome crashes. – Bruno Lamps Feb 13 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.