Results 1 to 8 of 8

Thread: Auto Mount NAS with fstab Not Working

  1. #1
    Join Date
    Nov 2019
    Beans
    6

    Auto Mount NAS with fstab Not Working

    So i am new to linux and Ubuntu came over from MacOS. I have a NAS that I need to auto mount at reboot since my media server uses it for media. i have setup cifs and edited the fstab file with the following but it will not auto mount. But when i run
    Code:
    sudo mount -a
    it will mount fine.

    Code:
    //xxx.xxx.xxx.xxx/public /media/NAS cifs vers=2.0,uid=1000,gid=1000,username=username,password=password,_netdev,file_mode=0777,dir_mode=0777 0 0
    I am running Ubuntu 19.10

    Any thoughts?

    Sean
    Last edited by seandavidson; November 12th, 2019 at 02:10 AM.

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

    Re: Auto Mount NAS with fstab Not Working

    I don't have 19.10. We are LTS-only here. Mounting at boot and automounting are different things, but that isn't important.

    I don't see anything clearly wrong with the fstab line. I use autofs so storage doesn't get mounted until requested using the automount daemon. The options I use are:

    Code:
    rw,iocharset=utf8,vers=2.1,uid=tf,gid=tf,file_mode=0664,dir_mode=0775,credentials=/root/win7lap-D.credentials
    Again, I think your options should be fine, though I'd have to check the vers=2.0 to see what that means.
    Code:
               ·   2.0 - The SMBv2.002 protocol. This was initially introduced in
                   Windows Vista Service Pack 1, and Windows Server 2008. Note
                   that the initial release version of Windows Vista spoke a
                   slightly different dialect (2.000) that is not supported.
    That's from the mount.cifs manpage. BTW, I should probably add _netdev to my options, but because autofs is used, nothing gets mounted until requested.

    Did the log files show anything on the NAS? Should be in /var/log/samba/ ... somewhere.

    If the NAS supports NFS, I'd use that for a number of reasons rather than CIFS.
    Last edited by TheFu; November 12th, 2019 at 03:14 AM.

  3. #3
    Join Date
    Nov 2019
    Beans
    6

    Re: Auto Mount NAS with fstab Not Working

    @ThFu Thanks for the info. I will take a look at the NAS logs and NFS.

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

    Re: Auto Mount NAS with fstab Not Working

    //xxx.xxx.xxx.xxx/public /media/NAS cifs vers=2.0,uid=1000,gid=1000,username=username,passw ord=password,_netdev,file_mode=0777,dir_mode=0777 0 0
    Probably the easiest route is to invoke autofs by adding two more options to your list:
    //xxx.xxx.xxx.xxx/public /media/NAS cifs vers=2.0,uid=1000,gid=1000,username=username,passw ord=password,file_mode=0777,dir_mode=0777,noauto,x-systemd.automount 0 0
    After editing fstab unmount the share: sudo umount /media/NAS

    Then do the systemd 3-step:
    Code:
    sudo systemctl daemon-reload
    sudo systemctl restart remote-fs.target
    sudo systemctl restart /media/NAS
    To test things run mount | grep NAS

    You should get something that starts with something that tells you the autofs process is running:
    systemd-1 on /media/NAS type autofs
    Followed by the actual mount parameters:
    /xxx.xxx.xxx.xxx/public on /media/NAS type cifs (rw,relatime .....
    Note: autofs works by mounting on demand when accessed and just about anything can trigger it.

    Note2: You can also go all the way with a systemd-autofs by having it automatically unmount when it's not required but you will have to change your mount point for that. Autofs and udisks2 don't play well together and udisks2 will make it so anything mounted under /media or your home directory will never unmount because autofs will think it's never idle. .... Come to think of it you should probably change your mount point anyway to say ... /mnt/NAS ... but that's up to you.
    Last edited by Morbius1; November 12th, 2019 at 02:09 PM.

  5. #5
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Auto Mount NAS with fstab Not Working

    If you have things working, ignore what I've written below. It is just some things I've learned from senior Unix admins over the decades.

    The autofs process has config files in /etc/ usually tied to auto.master and auto.nfs/auto.cifs which have a specific, sometimes odd, format. No need to touch the fstab - I'd not heard of autofs using the fstab before today. The autofs manpage:
    Code:
    OPERATION
           autofs   will   consult  a  configuration  file  /etc/auto.master  (see
           auto.master(5)) by default to find mount points on the system. For each
           of  those mount points automount(8) will mount and start a thread, with
           the appropriate parameters, to manage the mount point.
    Perhaps systemd changed something, again?! There is no mention of automout in the fstab manpage.

    The main reason I prefer using autofs is that unused network storage mounts aren't mounted. This is very handy with the remote storage may not be powered on or for a laptop that might not be on the home network. It is also helpful with USB storage devices that might not be connected all the time.
    <rant>
    I'm a little old-school, so new x-...... additions to mount options in the fstab file seem like too many cooks in the kitchen. Whenever that happens, the chances of problems increases. resolvconf is an example where things were working great, but "someone" decided to make it more flexible and DNS has never worked right since then. The last few releases, the systemd team has been trying to "fix" the issue ---- only to make it worse. IMHO.

    Searching the manpages, systemd.automount does say something about using the fstab.
    Code:
    FSTAB
           Automount units may either be configured via unit files, or via
           /etc/fstab (see fstab(5) for details).
    
           For details how systemd parses /etc/fstab see systemd.mount(5).
    
           If an automount point is configured in both /etc/fstab and a unit file,
           the configuration in the latter takes precedence.
    Once again, too many cooks, IMHO.
    </rant>

    For network mounts, I like to keep the mount point on the source system the same as the mount point on each client to prevent confusion.
    /D on the NFS host is /D on each client. 1-for-1 mapping, but I'm a little slow sometimes. For example:
    Code:
    $ df .
    Filesystem      Size  Used Avail Use% Mounted on
    istar:/D        3.5T  3.5T   42G  99% /D
    istar is the hostname of the NFS server where /D is a 4TB partition.
    On the current machine, I made an empty directory, /D, which serves as the mount point for the NFS storage.

    If you are doing media streaming from the NAS and see any stuttering over CIFS, Kodi MP recommends switching to NFS which seems to help assuming the NAS is 100Mbps wired ethernet or faster.

  6. #6
    Join Date
    Dec 2009
    Beans
    6,774

    Re: Auto Mount NAS with fstab Not Working

    @seandavidson

    There needs to be some clarification here or else you will end up with a mess. There are 2 autofs processes available to you.

    ** There's the original one where you have to install something and set up configurations in a couple of files. It works. I've used it myself in the past.

    ** Then there is the new way made possible by systemd that offers a number of options which is invoked in fstab itself. It's been available for years now so new is in the eye of the beholder. There is nothing else to install and no files to configure. Only add systemd options to fstab.

    If you are still using cifs I would suggest the systemd method first since it's easy enough to set up and if it doesn't do what is advertised move on the the old way - but only after removing your fstab entry.

    If you have moved to using NFS I can't comment either way. I haven't used NFS in 20 years.
    Last edited by Morbius1; November 12th, 2019 at 08:51 PM. Reason: Corrected spelling.

  7. #7
    Join Date
    Nov 2019
    Beans
    6

    Re: Auto Mount NAS with fstab Not Working

    I wanted to come back and state I got it working. I had to add the noperm to the fstab

    //xxx.xxx.xxx.xxx/public /media/NAS cifs uid=1000,gid=1000,username=username,password=passw ord,noperm,_netdev,file_mode=0777,dir_mode=0777 0 0

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

    Re: Auto Mount NAS with fstab Not Working

    You did more than add noperm you removed vers=2.0.


    That allowed cifs to mount at SMB3 ( vers=3.0 ) if it wanted to. The Linux kernel dictates which version of smb to use and does so by negotiating with the server to find the optimal value between vers=2.1 and vers=3.0 automatically. Maybe your server ( NAS ) didn't like or was more up-to-date than vers=2.0.

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
  •