Ubunutu 18.04 - How to automount a CIFS?

  • Hi all,


    I have got my OMV up and running and have the SMB/CIFS turned on.
    From Ubuntu files / nautilus I can see the shares and double click to enter the share, enter my credentials and I'm in.


    I want to use Duplicati on my Ubuntu box to send backups each day to the OMV discs so I need the shares to auto mount on login / boot up.
    I have to say I'm totally lost. Is there a newby friendly way to help set this up?
    I keep seeing things like:


    Code
    sudo mount -t cifs //192.168.20.20/srv/dev-disk-by-label-SmallStorage/NUC-Backups /media/OMVSmall -o username=user1




    and I get errors like:


    Code
    mount error(2): No such file or directory
    Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)


    I really am stumped and hope someone can help out. I can guarantee my password is correct for user1.


    Anything I can research I'd be grateful for the info. Thank you

  • An update to this, I seem to be getting somewhere. I've changed it to:


    Code
    sudo mount -t cifs //openmediavault.local/nuc-backups /media/OMVSmall -o username=user1

    ... and am now getting this error:


    Code
    mount error(16): Device or resource busyRefer to the mount.cifs(8) manual page (e.g. man mount.cifs)

    That has to be an improvement I'm guessing but I have no idea how to deal with a busy device :) Does anyone have a suggestion? Thanks a tonne..

  • Why don't you just add it to fstab? It will be mounted on startup. All you need is to make sure you have cifs-tools installed by running:


    Code
    sudo apt install cifs-tools

    Create you a credential file inside of root's home /root/.smbcredentials and put your credentials (this will ensure the share gets mounted no matter what user is on the computer):


    Code
    username=user1
    password=yourpassword
    domain=WORKGROUP (or whatever domain/workgroup you are using)

    Then give the proper permissions to the file like so:

    Code
    sudo chmod 600 /root/.smbcredentials


    Then add a line to /etc/fstab like so:

    Code
    //openmediavault.local/nuc-backups /media/OMVSmall cifs credentials=/root/.smbcredentials,uid=user1,noperm,rw 0 0

    You can then either mount the share by issuing sudo mount -a or by rebooting. I would recommend, though, mounting it under /mnt instead of /media because Ubuntu uses that directory for automatic media mounting and might cause you some issues.

    Einmal editiert, zuletzt von bkraul () aus folgendem Grund: Missing information.

  • This is an excellent reply. I've gone through those steps and I THINK it's working. I particularly like the credentials file being kept separately. Very nice.
    I'll give it a thorough run down and report back. Just wanted to say thanks. This should be pinned or something for beginners.

  • I have an update here. I have it setup as above, and have been away a month or so. On my return I noted my OMV share wasn't auto mounting.
    When I run sudo mount -a I get the following error: mount.cifs: bad UNC (openmediavault.local/NUC-backups)


    I have setup as so:


    fstab has: openmediavault.local/NUC-backups /media/NUCBackups cifs credentials=/root/.smbcredentials,uid=rob,noperm,rw 0 0



    /root/.smbcredentials is:

    Code
    username=rob
    password=yourpassword
    domain=WORKGROUP

    chmod is done, I just can't figure it out. I'm a little lost perhaps in understanding what openmediavault.local/NUC-backups is pointing to and how Ubuntu is meant to interpret that (I'm pretty new at all of this).


    Any advice would be really appreciated. Thank you

    • Offizieller Beitrag

    It probably can't resolve the openmediavault.local dns name. If you can't fix your dns resolving, you can substitute the OMV IP address in fstab.

    omv 7.0-32 sandworm | 64 bit | 6.5 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.9 | compose 7.0.9 | cputemp 7.0 | mergerfs 7.0.3


    omv-extras.org plugins source code and issue tracker - github


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • Thanks for your help with this.


    I updated the fstab to the following: 192.168.20.22/NUC-backups /media/NUCBackups cifs credentials=/root/.smbcredentials,uid=rob,noperm,rw 0 0 but still get mount.cifs: bad UNC (192.168.20.22/NUC-backups) as the error. If I enter 192.168.20.22 into my web browser it takes me to the OMV admin panel so that's the correct address.


    What else might it be do you think?


    UPDATE: Here is the share setup in OMV:

  • TADA!!!!!!! That worked.


    Thank you so much. It makes so much sense, if I was trying for //openmediavault.xxx earlier I should also have used the // when changing to IP address.


    Thanks again, much appreciated.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!