掛載usb顯示亂碼

2021-06-26 18:42:56 字數 1991 閱讀 3315

移植usb驅動後,掛載u盤,結果中文顯示?,經過努力終於搞定。

參考文章:

顯示?的問題主要有兩個:

1. busybox不支援中文。

2.掛載引數用的不對。

在嵌入式linux系統中,busybox是最常見的用來構建檔案系統的。可是從busybox1.17.0以上之後,對ls命令不做修改是無法顯示中文的。就算是核心設定了支援中文的話,在shell下用ls命令也是無法顯示中文的,這是因為busybox1.17.0以後版本對中文的支援進行了限制。在製作根檔案系統時,需要對busybox中/libbb/printable_string.c 和 /libbb/unicode.c 進行修改。

在/printable_string.c找到

if(c < 

' ')  

break

;  if

(c >= 0x7f)  

break

;  s++;  

注釋掉3行和4行

if(c < 

' ')  

break

;  /*

if (c >= 0x7f)

break;

*/s++;  

找到如下**段

unsigned char

c = *d;  

if(c == 

'\0'

)  break

;  if

(c < 

' '|| c >= 0x7f)  

*d = '?'

;  d++;  

修改為unsigned char

c = *d;  

if(c == 

'\0'

)  break

;  if

(c < 

' '/*|| c >= 0x7f */

)  *d = '?'

;  d++;  

在unicode.c 找到如下**段:

*d++ = (c >= ' '

&& c < 0x7f) ? c : 

'?';  

src++;  

}  *d = '\0'

;  } else

*d = '\0'

;  } else

{  d = dst = xstrndup(src, width);  

while

(*d) {  

unsigned char

c = *d;  

if(c < 

' '/* || c >= 0x7f */

)  *d = '?'

;  

然後在編譯busybox時新增 locale support 支援

busybox settings  --->    

general configuration  --->    

[*] enable locale support (system needs locale for this to work)                   

[*] support unicode 

[*]   use libc routines for unicode (else uses internal ones)

此時編譯根檔案系統還不能顯示中文,因為沒有相關的字符集。

下面就要新增字符集

在系統檔案的 /usr/lib 目錄下 新增 gconv (字元轉換)目錄(從pc上覆制過來(/usrlib/gconv/))

這樣構建的根檔案系統就可以顯示中文了。

不過不要得意哦,還有一步要做:

就是使用掛載命令:

mount -t vfat -o iocharset=cp936 /dev/sda1 /mnt 就可以完全顯示中文了。

並且沒有fat: utf8 is not a recommended io charset for fat filesystems, filesystem will be case sensitive!

VMware掛載usb裝置

首先乙個usb裝置只能掛載在乙個系統中,要麼是主機的系統,要麼是虛擬機器的系統。預設的情況是,首先掛載主機系統中的,因此虛擬機器中是無法檢查到usb裝置的。在vmware的選單中vm removable devices 中選擇對應的usb裝置,在主機系統中解除安裝,這樣vmware的虛擬系統就可以正...

Linux 掛載usb裝置

如果系統沒有發現usb裝置,那麼就要掛載這些裝置。1.在 mnt目錄下建立乙個掛裝usb儲存器的目錄 root tgflinux root mkdir mnt usb2.然後執行裝載裝置命令,將usb裝置掛裝到 mnt usb目錄下 root tgflinux root mount t msdos ...

linux 掛載 解除安裝Usb

一 掛載usb 1.切換到root許可權 2.用fdisk l檢視u盤 一般為 dev sdb,最後的乙個裝置 3.建立u盤掛載點mkdir mnt usb 4.掛載u盤mount t vfat dev sdb1 mnt usb 但是這樣掛載會有很多問題,如亂碼,非root許可權不能用圖形介面貼上東...