# mount ntfs volume, chinese filenames

## wildleaf

如何mount 可以显示中文文件名？

----------

## Hauser

Try this in your fstab:

```
/dev/hda5        /win       ntfs         users,iocharset=cp936,noauto      0 0

```

or cp950 if you use zh_TW.Big5 locale.

----------

## akar

這樣也可以， 如果你的 GNU/Linux環境是 UTF-8的編碼。

```
/dev/hda5        /mnt/win       ntfs         users,iocharset=utf8,noauto      0 0 
```

----------

## wildleaf

如何知道我用的是不是utf8?

另外不管我用iocharset=cp936 还是utf8, mount 出错

```

mount: wrong fs type, bad option, bad superblock on /dev/hda6,

       or too many mounted file systems

```

如果去掉iocharset=...这个option就没有问题

 *akar wrote:*   

> 這樣也可以， 如果你的 GNU/Linux環境是 UTF-8的編碼。
> 
> ```
> /dev/hda5        /mnt/win       ntfs         users,iocharset=utf8,noauto      0 0 
> ```
> ...

 

----------

## ts

 *wildleaf wrote:*   

> 如何知道我用的是不是utf8?
> 
> 另外不管我用iocharset=cp936 还是utf8, mount 出错
> 
> 

 

show your locale first

iocharset=gb2312

iocharset will depend on your locale

----------

## wildleaf

which should i change to zh_CN? I still want to use english majorly but need to read chinese filenames. 

I changed LANG=zh_CN.UTF-8, but mount still gave me the exact same error. Why?

```

LANG=en_US.UTF-8

LC_CTYPE=zh_CN.UTF-8

LC_NUMERIC="en_US.UTF-8"

LC_TIME="en_US.UTF-8"

LC_COLLATE="en_US.UTF-8"

LC_MONETARY="en_US.UTF-8"

LC_MESSAGES="en_US.UTF-8"

LC_PAPER="en_US.UTF-8"

LC_NAME="en_US.UTF-8"

LC_ADDRESS="en_US.UTF-8"

LC_TELEPHONE="en_US.UTF-8"

LC_MEASUREMENT="en_US.UTF-8"

LC_IDENTIFICATION="en_US.UTF-8"

LC_ALL=

```

 *ts wrote:*   

>  *wildleaf wrote:*   如何知道我用的是不是utf8?
> 
> 另外不管我用iocharset=cp936 还是utf8, mount 出错
> 
>  
> ...

 

----------

## ts

 *wildleaf wrote:*   

> which should i change to zh_CN? I still want to use english majorly but need to read chinese filenames. 
> 
> I changed LANG=zh_CN.UTF-8, but mount still gave me the exact same error. Why?
> 
> 

 

I need more information, please run

```

cat /etc/locales.build

```

In addition, I'm wondering what codepage (437 or 936) you select for your vfat system when you genkernel --menuconfig all.

----------

## wildleaf

 *ts wrote:*   

>  *wildleaf wrote:*   which should i change to zh_CN? I still want to use english majorly but need to read chinese filenames. 
> 
> I changed LANG=zh_CN.UTF-8, but mount still gave me the exact same error. Why?
> 
>  
> ...

 

Here is the output of cat /etc/locales.build:

```

wildleaf portage # cat /etc/locales.build

# This file names the list of locales to be built when glibc is installed.

# The format is <locale>/<charmap>, where <locale> is a locale from the

# /usr/share/i18n/locales directory, and <charmap> is name of one of the files

# in /usr/share/i18n/charmaps/. All blank lines and lines starting with # are

# ignored. Here is an example:

# en_US/ISO-8859-1

en_US/ISO-8859-1

en_US.UTF-8/UTF-8

ja_JP.EUC-JP/EUC-JP

ja_JP.UTF-8/UTF-8

ja_JP/EUC-JP

en_HK/ISO-8859-1

en_PH/ISO-8859-1

de_DE/ISO-8859-1

de_DE@euro/ISO-8859-15

es_MX/ISO-8859-1

fa_IR/UTF-8

fr_FR/ISO-8859-1

fr_FR@euro/ISO-8859-15

it_IT/ISO-8859-1

```

[/code]

----------

## ts

 *wildleaf wrote:*   

> 
> 
> Here is the output of cat /etc/locales.build:
> 
> ```
> ...

 

我想你应该把中文加入你的 locales.build，法语和日语等其它语言没有必要，你可以把文件改成如下这样：

```

# This file names the list of locales to be built when glibc is installed.

# The format is <locale>/<charmap>, where <locale> is a locale from the

# /usr/share/i18n/locales directory, and <charmap> is name of one of the files

# in /usr/share/i18n/charmaps/. All blank lines and lines starting with # are

# ignored. Here is an example:

# en_US/ISO-8859-1

en_US/ISO-8859-1

en_US.UTF-8/UTF-8

zh_CN.UTF-8/UTF-8

zh_CN/gb2312

```

完了之后，试一下 mount 你的分区;不行，再试一下

```
export LC_ALL="zh_CN.UTF-8/UTF-8"
```

再试一下用 iocharset=UTF8 来 mount 你的分区；如果还不行（这也是最可能发生的情况），你需要重新重新编译你的 kde，我就不知道你是否有时间和精力呢。

Good luck, 兄弟。

----------

## ts

补充一下，

当你：

```
genkernel --menuconfig all 
```

DOS/VFAT 的编码选项时绝对不能选 cp936 或 gb2312，只能是默认值。要不任何 iocharset 选项都不会 work，我想这是核心的一个 bug。

----------

## wildleaf

NO, I didn't select that. BTW, i want to mount a ntfs volume, not VFAT.

 *ts wrote:*   

> 补充一下，
> 
> 当你：
> 
> ```
> ...

 

----------

## Hauser

 *ts wrote:*   

> 我想你应该把中文加入你的 locales.build，法语和日语等其它语言没有必要，你可以把文件改成如下这样：
> 
> ```
> 
> # This file names the list of locales to be built when glibc is installed.
> ...

 

如果之前設了locales.build而又沒有中文的locale，現在光是加進去是不行的，你得重編glibc才行。

另外編譯kernel的時候要把Native Language Support裡中文及UTF-8的選項編進去。

----------

## ts

 *Hauser wrote:*   

> 
> 
> 如果之前設了locales.build而又沒有中文的locale，現在光是加進去是不行的，你得重編glibc才行。
> 
> 另外編譯kernel的時候要把Native Language Support裡中文及UTF-8的選項編進去。

 

Good points, you are right.   :Very Happy: 

----------

## wildleaf

Does it mean I have to recompile the entire system?  :Sad: 

 *Hauser wrote:*   

> 
> 
> 如果之前設了locales.build而又沒有中文的locale，現在光是加進去是不行的，你得重編glibc才行。
> 
> 另外編譯kernel的時候要把Native Language Support裡中文及UTF-8的選項編進去。

 

----------

## Hauser

There's no need to do that.  Just recompile glibc, and if necessary, the kernel. :Smile: 

----------

## wildleaf

Thanks guys! I found I by mistake set CP936 and CP950 and UTF8 as Module in the Native Language Support and forgot to load them. After I insmod, now i can mount it using iocharset=cp926 or utf8 option. But the chinese file name does not show up correctly. What is the problem now?

Is this because I have to recompile glibc? And how can I recompile it? emerge glibc?

Also, is it better to compile language support into kernel instead of modules?

Sorry still one more, How do I know my system is now using UTF8 or not , since the language option was not loaded ever.

----------

## ts

 *wildleaf wrote:*   

> But the chinese file name does not show up correctly. What is the problem now?
> 
> Is this because I have to recompile glibc? And how can I recompile it? emerge glibc?

 

这样就好

```
emerge glibc
```

 *Quote:*   

> Also, is it better to compile language support into kernel instead of modules?
> 
> Sorry still one more, How do I know my system is now using UTF8 or not , since the language option was not loaded ever.

 

刚才我又重新编译核心试了一下，只要你 make.conf 文件 USE 设了 nls，默认就是 utf8，编译时各语言包作为模块就行。

但是，我试了一下不同的 iocharset，只有 gb2312 才行，好像如果 cp936(gb2312) 和 UTF8 同时选择的话，gb2312 优先。

good luck.

----------

## wildleaf

I had no luck to make this work:(

I use this to mount

```

wildleaf mnt #  mount -t ntfs -o iocharset=cp936 /dev/hda6 d

```

then I got 

```

wildleaf Chinese # dir

\301\367\320\320\270\350\307\372

wildleaf Chinese # ll

ls: ���и���: No such file or directory

total 0

wildleaf Chinese #

```

----------

## akar

I think it is the locale problem of the user root

How about,

```

#  mount -t ntfs -o iocharset=cp936 /dev/hda6 d 

# export LC_ALL=zh_CN.GB2312

#ls 

```

it is only locale problem for the root user for your case.

explaination

.config of kernel 2.6.9

```

glc linux # grep -i nls .config |grep -v ^#

CONFIG_UDF_NLS=y

CONFIG_NLS=y

CONFIG_NLS_DEFAULT="iso8859-1"

CONFIG_NLS_CODEPAGE_936=m

CONFIG_NLS_CODEPAGE_950=m

CONFIG_NLS_ISO8859_1=m

CONFIG_NLS_UTF8=m

```

For my kernel 2.6.9, the nls modules are black magicly loaded when need

Mount without any parameter, module nls_iso8859_1(nls default in kernel config) is loaded

```

glc root # mount /dev/hda6 /mnt/C

glc root # lsmod

Module                  Size  Used by

nls_iso8859_1           4096  1

nvidia               4814004  12

eepro100               25868  0

```

Mount with parameter "iocharset=utf8", we can see:

1. the module "nls_iso8859_1" is still there but Used=0 after umount the previous mount!!

2. the module "nls_utf8" is now loaded

```

glc root # umount /mnt/C

glc root # mount -o iocharset=utf8 /dev/hda6 /mnt/C

glc root # lsmod

Module                  Size  Used by

nls_utf8                1920  1

nls_iso8859_1           4096  0

```

 :Idea:  I have not read the kernel manual, but i think the Used=N of  every kernel module is to support the experiment "unload module" feature of kernel. N<>0, is a module that should not be unloaded.

edit.20041221: better BBcode formating

----------

## wildleaf

Thanks! But It is not working:(

Here is what i got:

```

wildleaf Chinese # grep -i nls /usr/src/linux/.config |grep -v ^#

CONFIG_UDF_NLS=y

CONFIG_NLS=y

CONFIG_NLS_DEFAULT="iso8859-1"

CONFIG_NLS_CODEPAGE_437=y

CONFIG_NLS_CODEPAGE_936=m

CONFIG_NLS_CODEPAGE_950=m

CONFIG_NLS_ISO8859_1=y

CONFIG_NLS_UTF8=m

```

and when I mount it using cp936

```

Module                  Size  Used by

nls_utf8                2688  0

nls_cp950             104832  0

nls_cp936             127232  1

ntfs                  143632  1

e100                   31360  0

```

Any other ideas?

----------

## akar

 *wildleaf wrote:*   

> I had no luck to make this work:(
> 
> I use this to mount
> 
> ```
> ...

 

I have overlook, your preferred codepage is zh_CN.UTF-8, so

```

wildleaf mnt #  mount -t ntfs -o iocharset=utf8 /dev/hda6 d

wildleaf mnt # ls d

```

to see if it works.

---If the above still not work !! ---

 :Idea:  Hmmm,,,,, i should invite you to create a file with Chinese name to test if your system is Chinese ready.  :Smile: 

at least set LC_CTYPE to processing chinese characters.

```

$ export LC_CTYPE="zh_CN.UTF-8"

```

TestCase: if the file with chinese name created under Linux native file sytem is handled correctly.

```

$ touch /tmp/中文文件名.txt

$ ls /tmp/

```

----------

## wildleaf

 *akar wrote:*   

> 
> 
> I have overlook, your preferred codepage is zh_CN.UTF-8, so
> 
> ```
> ...

 

I tried this utf8 before, didn't work either.

 *Quote:*   

> 
> 
> ---If the above still not work !! ---
> 
>  Hmmm,,,,, i should invite you to create a file with Chinese name to test if your system is Chinese ready. 
> ...

 

I've no problem to create and see chinese name while i'm in gnome, but i cant see chinese names without it. Also, the mount is still not working. 

If I give you a test account, could u log on and see what 's wrong?

wildleaf.3322.org

user: testuser

pass: wildleaf

Thanks!

----------

## akar

 :Cool:   : btw, i have changed the passwd of the account "testuser". 

i found you have recompiled the kernel! now the nls modules are compiled into kernel.   :Exclamation:  Make sure you are using the correct kernel to boot up your Gentoo, (and of coz the new compiled version has properly installed). otherwise mounting with option of "iocharset=utf8" will prompt you an error.

During my login session, i found your have mounted two ntfs, but WITHOUT the iocharset=utf8 option. was it having problem when mounting with such option?

```

$ mount

/dev/hda6 on /mnt/d type ntfs (rw,noexec,nosuid,nodev,umask=0022)

/dev/hda7 on /mnt/e type ntfs (rw,noexec,nosuid,nodev,umask=0022) 
```

mine is something like:

```

/dev/hda6 on /mnt/D type vfat (rw,noexec,nosuid,nodev,umask=022,iocharset=utf8,iocharset=utf8)

```

----------

## wildleaf

Thanks a lot! It works now! But I didn't figure out why it works  :Confused: 

Here is what I did today:

1. I do recompiled kernel with language support (utf8, cp936, cp950) built in

2. recompiled glibc with updated locales.build

3. unmerge linux-headers, merge linux26-headers

4. recompiled glibc

5. merge kde

Then I suspect it is only because I built the language support into kernel instead of modules. This is weird.

But anyway, thanks guys, everything is working now, kde works much better than gnome, i like it.

 *akar wrote:*   

>   : btw, i have changed the passwd of the account "testuser". 
> 
> i found you have recompiled the kernel! now the nls modules are compiled into kernel.   Make sure you are using the correct kernel to boot up your Gentoo, (and of coz the new compiled version has properly installed). otherwise mounting with option of "iocharset=utf8" will prompt you an error.
> 
> During my login session, i found your have mounted two ntfs, but WITHOUT the iocharset=utf8 option. was it having problem when mounting with such option?
> ...

   :Confused:   :Confused: Last edited by wildleaf on Wed Dec 22, 2004 3:32 am; edited 1 time in total

----------

## wildleaf

OK a last question.    :Shocked: 

akar I cant be happier if  you can help me fix this

Now I can read the chinese file names of the mounted volumes correctly only in kde/gnome.  The chinese characters are screwed in text mode, say, when i'm not running X. How can I get this fixed?

----------

## shyokou

I think everyone wants to mount ntfs/vfat with NLS should consider these thing first -

1) ntfs/vfat modules supported by kernel (as those in CONFIG_*_FS);

2) NLS modules supported by kernel (as those in CONFIG_NLS_*), at least iso8859-1 and cp437 for ASCII, also utf8 for all other languages in one;

But it is totally another thing to read the NLS correctly, since it depends upon both your libc and ui compabilities -

1) locale settings supported by glibc (en_US.UTF-8 is the ultimate solution for any language, if you know that you should forget any other settings);

2) fonts supported by other packages (freettf etc might be enough, but there is few fonts claim utf8; it is better to choose a bigger one, like gb18030 for any zh_CN);

3) console and gui with proper locale/fonts settings (it depends upon your application, but the theory is the same);

Here is the minimal for a universal box -

1) has ASCII support (cp437 and iso8859-1);

2) has UTF-8 support (not only kernel/glibc, but also fonts/ui);

Please note the encoding spaces that "(simplifed chinese only) HZ == GB2312 < GBK == CP937 < GB18030 < UTF-8 (all languages in one) ...

Nothing is too difficult if you know how to deal with it  :Smile: 

----------

## akar

install zhcon!  :Smile: 

 *Quote:*   

> 
> 
> *  app-i18n/zhcon
> 
>       Latest version available: 0.2.3
> ...

 

[img:c0a65fadaf]http://zhcon.sourceforge.net/images/scr_bbs.gif[/img:c0a65fadaf]

http://zhcon.sourceforge.net/

to shyokou: informative! thank you.

----------

