linuxmountfstab

How do I specify a label/path with special characters as 'ñ' in /etc/fstab?


I know that if a path has spaces one can encode it with \040:

Example for path:

"//server/folder with spaces"

fstab entry:

//server/folder\040with\040spaces /mnt/share/folder_local cifs nofail,credentials=/root/.credfile 0 0

But how to fill fstab if you have a path with non-English chars as 'ñ'?

Path example:

"//server/folderWith-ñ-char"

I've tried:

fstab entry:

//server/folderWith-\F1-char /mnt/share/folder_local cifs nofail,credentials=/root/.credfile 0 0

based on: https://www.degraeve.com/reference/urlencoding.php

but I get the error:

 mount -a
mount error(2): No such file or directory

Solution

  • Just type //server/folderWith-ñ-char, ñ is not anyhow special.

    In case of problems, you can use mnt_mangle from linux-util. Compile this short program:

    $ printf "%s\n" '#include "libmount/libmount.h"' 'int main(int argc, char *argv[]) { puts(mnt_mangle(argv[1])); }' | gcc -xc - -lmount -o mnt_mangle
    

    Then you can use:

    $ ./mnt_mangle '//server/folderWith-ñ-char'
    //server/folderWith-ñ-char