Saturday, March 5, 2011

BSD|解决ntfs-3g挂载的分区无法显示中文文件的办法

安装了openSUSE10.3后,发现原来保存在NTFS分区上的一些文件不见了,还以为升级的过程中丢失了呢。因为是在10.2版本上根据官方网站进行的ntfs-3g安装,可以读写NTFS分区,当时感觉很好用,没想到升级后对中文支持出现了问题。并且在NTFS分区上新建文件或者文件夹都报错误: “一般错误”,开始没有理解什么是一般错误,后来考虑了一下觉得应该是中文字符的问题,因为在10.3版本上新建的文件夹或文件都是用的中文名字(如果安装选择的中文的话),导致创建不了,然后搜索了一下中文文件无法显示的问题,有很多资料。

This means that your operating system (OS) doesn't have the correct language specific settings (locale, LANG variable, LC_ALL, etc) thus some filenames can't be converted to your language and won't be visible. The reason can be:
The locale setting wasn't configured during installation.
Not the correct locale was configured.
The configured value doesn't exist on the system.
The OS configures the setting in a too late stage during the boot process, only after the NTFS volume was already mounted.
The most common explanation is the latter one. This is why unmounting then mounting such volumes after boot often makes all filenames visible.

其实主要是最后一个原因:ntfs模块加载的时候系统区域配置还没有起作用,导致无法辨别中文字符。解决办法也提供了,其实就是在fstab文件中mount的时候添加“locale=zh_CN.UTF-8”就可以了。

修改后,重启,所有的文件都出现了,并且可以正常创建文件和文件夹。