Score:1

How to fix my fstab file when I try and mount my server with spaces in the name

US flag

I am running ubuntu 22.04 and I have the following server to mount:

//MARS/Students/2024/LastName, FirstName

I have gotten the following error after using sudo mount -a

mount error(22): Invalid argument my /etc/fstab file line looks like:

//MARS/Students/2024/LastName, Firstname    /media/windowsshare   cifs  credentials=/path/to/creds,iocharset=utf8 0 0

I have tried multiple things like:

//MARS/Students/2024/LastName,\040FirstName
"//MARS/Students/2024/LastName, FirstName"
\"//MARS/Students/2024/LastName, FirstName\"
\"//MARS/Students/2024/LastName,\040FirstName\"
"//MARS/Students/2024/LastName,\040FirstName"

None of these work. Is there something I am missing?

Wayne Vosberg avatar
bd flag
I suspect the problem is the comma and not the space (replacing with \040 should work for that). I would try googling for how to handle the comma first.
MATOS avatar
md
is there a comma escape code?
RonJohn avatar
cn flag
@MATOS "is there a comma escape code?" 040 is *octal* for the decomal number 32, and 32 is the ordinal of ASCII space. A search for "ascii table with octal" will answer all your questions. (And tell you where %20 came from.)
FedKad avatar
cn flag
Does the samba share mounts when you try from command line?
MATOS avatar
md
well I wanna just use sudo and fstab but I tried configuring it but it didnt work
FedKad avatar
cn flag
First try to mount from command line (`sudo mount "//MARS/Students/2024/LastName, Firstname" /media/windowsshare`). And if it works, then try to edit the `fstab` file.
mook765 avatar
cn flag
Looking at `man fstab` and googling for nfs mounts leads me to suggest something like `MARS:/Students/...`.
Score:1
cn flag

Besides the space character (octal code 040), you should also escape the comma character (octal code 054) and any non-ASCII characters in the samba share:

//MARS/Students/2024/LastName\054\040FirstName    /media/windowsshare   cifs  credentials=/path/to/creds,iocharset=utf8 0 0

For a list of ASCII octal codes see https://www.asciitable.com/

You should pay special attention whether your samba share (e.g., "first name" and "last name") contains any non-ASCII letters or symbols.

MATOS avatar
md
Still calls the same error
FedKad avatar
cn flag
Check proper case also. Is it `Firstname` or `FirstName`?
MATOS avatar
md
The case ic correct in my case I checked. ```FirstName``` is just a placeholder for my name which is capitalized
Wayne Vosberg avatar
bd flag
I'm not certain you can escape the comma, and I'm not at a place I can test right now. If you *can* I suspect it would be by enclosing in single quotes: `'//MARS/Students/2024/LastName, FirstName'`
MATOS avatar
md
It raises a parse error
Score:0
bd flag

Adding as an answer just for the formatting, but you may have to do something like this as a workaround:

/etc/fstab:

//MARS/Students/2024/    /media/windowsshare   cifs  credentials=/path/to/creds,iocharset=utf8 0 0

and then

$ ln -s /media/windowsshare/'LastName, FirstName' ~user/windowsshare

relying on normal user permissions for access protections.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.