Unable to mount cifs share in fstab with spaces in share name

9,543

Replacing the spaces with \040 is actually the right way to do it.

The reason why it’s not working for you is probably because there are (forgotten?) quotes after /Restricted:

//servername.org.au/ABC/Company\040Services/…/Restricted"    /mnt/n-drive    cifs    id=0,credentials=/etc/samba/login.crt,iocharset=utf8,noperm        0       0

Change that to:

//servername.org.au/ABC/Company\040Services/…/Restricted    /mnt/n-drive    cifs    id=0,credentials=/etc/samba/login.crt,iocharset=utf8,noperm        0       0

(Note that I’ve shortened the path a bit for better readability.)


Background: 040 is the ASCII code for space in octal numeral system.

Share:
9,543

Related videos on Youtube

Rus Ti
Author by

Rus Ti

Updated on September 18, 2022

Comments

  • Rus Ti
    Rus Ti over 1 year

    I'm running a Debian Squeeze system and trying to mount a windows share in /etc/fstab. I've got an existing cifs mount working, but it's a simple //xx.xx.xx.xx/sharename situation. This second one isn't working however.

    The issue - the second share has white spaces in the path... multiple ones!

    The line in fstab is:

    //servername.org.au/ABC/Company Services/Department Services/Area Services/Restricted    /mnt/n-drive    cifs    id=0,credentials=/etc/samba/login.crt,iocharset=utf8,noperm        0       0
    

    So far I've tried:

    Double quotes around the path names in fstab

    //servername.org.au/ABC/"Company Services/Department Services/Area Services/Restricted"    /mnt/n-drive    cifs    id=0,credentials=/etc/samba/login.crt,iocharset=utf8,noperm        0       0
    

    Replacing the space with \040 (like in Linux)

    //servername.org.au/ABC/Company\040Services/Department\040Services/Area\040Services/Restricted     /mnt/n-drive    cifs    id=0,credentials=/etc/samba/login.crt,iocharset=utf8,noperm        0       0
    

    Escape with backslash

    //servername.org.au/ABC/Company\ Services/Department\ Services/Area\ Services/Restricted    /mnt/n-drive    cifs    id=0,credentials=/etc/samba/login.crt,iocharset=utf8,noperm        0       0
    

    None of these worked.

    I've verified the directory is valid, I've tried replacing the servername.org.au with the IP it resolves to and that didn't help either.

    The error I'm getting in kern.log is:

    kernel: [1830446.002198] CIFS VFS: cifs_mount failed w/return code = -22

    That's it - not a lot of detail to go on...

    I'm using the EXACT same syntax and credentials for both mounts. I KNOW the credentials are valid and working because I use them to connect to the same share on my Windows box. I'd change the share name, but unfortunately it's not one of MY servers and they won't do it.

    So I'm just gonna strap these two danishes to the side of my head and say:

    Help Me Obi-Stack-Exchange! You're my only hope!

    Thanks in advance!

    (Edit: removed errant quotation marks in one of the examples)

    • aaronk6
      aaronk6 over 4 years
      -22 seems to be a rather generic error code. There are answers below this post that suggest various options that you might want to try: stackoverflow.com/questions/6734400/…
  • Rus Ti
    Rus Ti over 4 years
    Sorry... the forgotten quotes after Restricted is my bad editing when posting the question. I copy-pasta'd the first example and edited to show the NEW example. Obviously I missed removing the closing quotation marks...
  • aaronk6
    aaronk6 over 4 years
    If you just mount //servername.org.au/ABC, will this work?
  • aaronk6
    aaronk6 over 4 years
    To clarify: Will it work if you mount a path on the same server that does not have spaces?
  • Rus Ti
    Rus Ti over 4 years
    Just tried that and no... same error...
  • Rus Ti
    Rus Ti over 4 years
    mount error(22): Invalid argument Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
  • Rus Ti
    Rus Ti over 4 years
    interestingly enough - I CAN manually mount it via the "mount -t cifs ...." using just the short path, which I couldn't before.... Which doesn't explain why it WON'T mount it in fstab....!!
  • Rus Ti
    Rus Ti over 4 years
    AHH... so that explains why the SHORT format worked on the manual mount and not when using fstab.... Some idiot (ie; me) had "id=" instead of "uid=" in fstab... so when I typed it out MANUALLY, I got it right.... Somewhere along the line, I obviously cut the "u" out... probably when pasting it from the OTHER fstab entry... So I SHOULD be able to do the 'short' mount and then a sym-link to the directory further in.... which would provide a nice workaround the immediate issue, but still doesn't explain why it doesn't work like it "should" (or should that be like I think it should?)
  • Rus Ti
    Rus Ti over 4 years
    And the weirdness continues... I can browse the share in windows, but can't navigate to the same directories on the Linux box. It can SEE the directory names but won't let me CD into them. 🤬
  • Rus Ti
    Rus Ti over 4 years
    Hi folks, Just to wrap this up. My IT people had no-browse permissions on the earlier part of the file structure, which whilst you CAN ignore it under Windows when mounting the share with the whole path name, linux WON'T do it. They gave me a new share path to mount to (still with a space in it!) but the \040 worked a treat and nwo I'm off and going. Thanks to all who helped me on this one.