Encoding issue between NFSv3 and NFSv4
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!
Solution 1:
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.