Page 1 of 3 123 LastLast
Results 1 to 10 of 27

Thread: Mount Samba shares automatically after establishing Wifi

  1. #1
    Join Date
    Feb 2010
    Location
    Europe
    Beans
    16
    Distro
    Ubuntu 18.04 Bionic Beaver

    Mount Samba shares automatically after establishing Wifi

    Hi

    I use Ubuntu 18.04 on a Notebook and have some Samba shares in my home network. These Samba shares are not always available (only when at home), but if available they should be mounted automatically system-wide after establishing a Wifi connection.

    What's the easiest way to do this?

    Regards,
    Atalanttore
    Last edited by Atalanttore; October 3rd, 2018 at 05:52 PM. Reason: Mark thread as SOLVED

  2. #2
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: Mount Samba shares automatically after establishing Wifi

    Well, for sometimes connected storage, I'd recommend using autofs. When the storage is requested, then it is mounted. Be certain to use "soft" mounts, so the machine doesn't lock up looking for amount that doesn't exist when you are away.

    Of course, I've got to suggest using NFS for Unix-to-Unix storage. It provides native access, native permissions, and is a little faster. autofs works well with NFS too.

    Or you could write a script that checks what network you are on and mounts the storage. Drop this into your login autorun setup.

    I don't think Samba does mounts for all users without a user mapping solution between Windows and Unix systems. I haven't done that in a few decades now. We had thousands of users and doing it with all the added/removed users was a pain for someone, not me. Samba mount permissions are determined at mount time, so if you have multiple users who need access, more thought will be needed.

  3. #3
    Join Date
    Feb 2010
    Location
    Europe
    Beans
    16
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: Mount Samba shares automatically after establishing Wifi

    Samba resp. SMB is mainly used because of the Windows computers in my home network.

    Would you recommend to use NFS in addition to Samba for network shares?

  4. #4
    Join Date
    Dec 2009
    Beans
    6,257

    Re: Mount Samba shares automatically after establishing Wifi

    For the samba part you might consider Gigolo.

    ** Install it:
    Code:
    sudo apt install gigolo
    ** Run it

    ** Go to Edit > Preferences > Interface > select "Start minimized in the Notification Area" and Disable "Show auto-connect error messages"

    ** Then go to Edit Bookmarks > Add > Fill in the blanks - Don't forget to check "Auto-Connect":
    GigoloBookmark.png



    ** The only missing step which gigolo will not do for you is to make sure the applications itself runs at login. So go to Startup Applications > Add > And for the Command enter gigolo

    The next time you log into your machine your share will be mounted. If you are not in that network where the server exists or if WiFi is not up at that moment gigolo will wait until both exist and then mount it.

  5. #5
    Join Date
    Feb 2010
    Location
    Europe
    Beans
    16
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: Mount Samba shares automatically after establishing Wifi

    Gigolo looks nice and is already installed on my Ubuntu Notebook.

    Does it offer a way to mount a network share in a specific mount directory (e.g. /mnt/<share>) on my Notebook?

  6. #6
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    14,437
    Distro
    Kubuntu Development Release

    Re: Mount Samba shares automatically after establishing Wifi

    Quote Originally Posted by Atalanttore View Post
    Would you recommend to use NFS in addition to Samba for network shares?
    I run both Samba and NFS on my file server. I only occasionally have need for CIFS, but I do run Win7 in a VirtualBox from time to time and connect to Samba from there. I export the home directory on that server both ways. I have a couple of other NFS-only shares that are exported only to Linux clients.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  7. #7
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: Mount Samba shares automatically after establishing Wifi

    The main downside for GUI tools is they usually use the very slow gvfs mount method, based on FUSE. Very slow is giving too much credit, IMHO. People have reported 50% slower file transfers, but I don't know the truth. But it is easier and has a GUI.

    If you want performance from networked storage, use config files (nfs or CIFS/samba) and a "real mount". But it is your system, the choice is yours. "Real mounts" show up in a list when you type "mount."
    Last edited by TheFu; September 7th, 2018 at 05:48 PM.

  8. #8
    Join Date
    Dec 2009
    Beans
    6,257

    Re: Mount Samba shares automatically after establishing Wifi

    Does it offer a way to mount a network share in a specific mount directory (e.g. /mnt/<share>) on my Notebook?
    Nope. The closest you can get would be a link to the parent folder: /run/user/$UID/gvfs

  9. #9
    Join Date
    Feb 2010
    Location
    Europe
    Beans
    16
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: Mount Samba shares automatically after establishing Wifi

    Quote Originally Posted by TheFu View Post
    The main downside for GUI tools is they usually use the very slow gvfs mount method, based on FUSE. Very slow is giving too much credit, IMHO. People have reported 50% slower file transfers, but I don't know the truth. But it is easier and has a GUI.

    If you want performance from networked storage, use config files (nfs or CIFS/samba) and a "real mount". But it is your system, the choice is yours. "Real mounts" show up in a list when you type "mount."
    I do prefer a working network share with 50% slower file transfers rather than a non-working network share with no file transfers.


    Quote Originally Posted by Morbius1 View Post
    Nope. The closest you can get would be a link to the parent folder: /run/user/$UID/gvfs
    Thank you for that hint.

  10. #10
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: Mount Samba shares automatically after establishing Wifi

    And if you use autofs, then you don't have the performance drop and the shares would be mounted on-demand, as requested. You seemed interested in other solutions, so I stopped making suggestions.

    autofs acts as a smart mounter based on configuration files. I do have a few CIFS mounts on 1 machine.
    Code:
    win7ult  -fstype=cifs,rw,iocharset=utf8,file_mode=0660,dir_mode=0770,credentials=/root/data/win7.credentials  ://172.22.22.8/Data
    That's the main /etc/auto.Data file on my client Linux system. No spaces in any of the options, all on a single line. /etc/auto.master on the same machine has to point to auto.Data.

    The mount looks like this:
    Code:
    /Data/win7ult$ df -h .
    Filesystem          Size  Used Avail Use% Mounted on
    //172.22.22.8/Data  101G   23G   79G  22% /Data/win7ult
    You can force a username and groupname for the mount, if needed. The mount options are part of the mount.cifs and get passed through directly. It won't be slow like FUSE and there isn't any GUI to configure it.

    I also use autofs to mount USB storage devices, since they are sometimes available and sometimes not available.

Page 1 of 3 123 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •