We have some issues regarding NFS share regarding filenames encoding.

We were previously mounting as NFSv3 and started to use NFSv4 and some files previously created, with special characters (typically French accented characters) are now incompatible and cannot be listed correctly.

The NFS server is configured to allow clients to mount with either v3 or v4.

Moreoever, we did a simple test to understand what is happening:

  • mount the share on (for example): /mnt/nfs3 with the type nfs (-t nfs)
  • mount the same folder on: /mnt/nfs4 with the type nfs4 (-t nfs4)
  • create a file with accented characters in the filename in the nfsv4 folder: touch /mnt/nfs4/testééè
  • list the newly created file on the same folder: ls /mnt/nfs4

And the result is : testééè

So as you can see, listing the file with accents in the same folder it was created shows differences. Why is that ?

  • Is there any compatibility mode on the NFS server ?
  • Is mounting the same folder with different NFS types on the same machine an issue ?
  • Has it anything to do with machine locale and the LC_* env variables ?

Thank you for your help!

  • Is this the same share on the same storage server? – Michael Hampton Jan 31 '19 at 13:22
  • 1
    NFSv4 requires that file names are UTF-8 encoded – kofemann Feb 1 '19 at 9:03
  • @MichaelHampton yes, same share, same storage server (netapp), just two different mount points with two different nfs versions – Lebowski Feb 1 '19 at 18:59

The reason this has happened is that NFSv4 requires filenames to be in UTF-8 encoding, but your filenames were written by old clients using NFSv3 and some Latin encoding, probably ISO-8859-1 if you're in Europe.

The files will all need to be renamed.

You can use the utility convmv to rename the file from one character encoding to another. But since your storage is on a Netapp, you'll almost certainly have to do this from a client that has the filesystem mounted via NFSv3. An example:

convmv -f latin1 -t utf-8 -r /nfsv3-mountpoint

After that you should be able to see the filenames correctly on NFSv4, and all the missing files should reappear too.

After this point you need to find any clients still using NFSv3 and get them fixed. NFSv3 is almost 25 years old. Nothing should be using it anymore.

For more information see this thread from Hacker News.

  • Thank you for your advice ! I saw the exact same thread on Hacker News. But one thing we could not explain is, why when we create the new file directly in the NFSv4 mountpoint, its filename is already corrupted when we ls it just after creating it, in the same NFSv4 folder? but when we do the ls from the NFSv3 mountpoint, the name is correct. It's like the system does not care where we create the file from. (I don't know if I'm clear with my terms, sorry for this) – Lebowski Feb 3 '19 at 16:03
  • Hm, now that's interesting. Are your clients actually using a UTF-8 character set? If you run locale on a LInux client you should see something like fr_FR.UTF-8. if UTF-8 is missing then you need to fix the locale. – Michael Hampton Feb 3 '19 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.