天天看點

Linux系統挂載FAT32的U盤

linux挂載u盤步驟如下

1:将u盤插入usb接口,檢查是否插好

2:用fdisk指令檢查分區和usb裝置資訊

[root@wgods ~]# fdisk -l

disk /dev/sda: 1000.2 gb, 1000204886016 bytes

255 heads, 63 sectors/track, 121601 cylinders

units = cylinders of 16065 * 512 = 8225280 bytes

device boot start end blocks id system

/dev/sda1 * 1 13 104391 83 linux

/dev/sda2 14 121601 976655610 8e linux lvm

disk /dev/sdb: 4012 mb, 4012900352 bytes

223 heads, 55 sectors/track, 639 cylinders

units = cylinders of 12265 * 512 = 6279680 bytes

/dev/sdb1 * 56 640 3580928 c w95 fat32 (lba)

partition 1 has different physical/logical beginnings (non-linux?):

phys=(42, 17, 40) logical=(55, 23, 1)

partition 1 has different physical/logical endings:

phys=(487, 222, 55) logical=(639, 6, 31)

通過上面資訊我們可以看出usb裝置是fat32格式的,辨別為/dev/sdb1

[root@wgods ~]# fdisk -l | grep fat32

3:在mnt目錄下先建立一個usb的目錄

[root@wgods ~]# cd /mnt/

[root@wgods mnt]# mkdir usb

4:挂載u盤

[root@wgods mnt]# mount -t vfat /dev/sdb1 /mnt/usb

挂載成功後,我們可以在/mount/usb下看到相關的内容。

5:解除安裝u盤

執行umount指令解除安裝u盤時,報如下錯誤“device is busy”,可以用參數l解決問題。當然你也可以用fuser指令解決問題。如下所示

[root@wgods ~]# umount /mnt/usb

umount: /mnt/usb: device is busy

[root@wgods ~]# umount -f /mnt/usb

umount2: device or resource busy

[root@wgods ~]# umount -l /mnt/usb

問題解決

---------------------------------------------------------------------------------

[root@wgods usb]# umount /mnt/usb

[root@wgods usb]# fuser -m /mnt/usb

/mnt/usb: 21123c 21158c 21180c 21182c 21223c

[root@wgods usb]# ps -auxw | grep 21123

warning: bad syntax, perhaps a bogus '-'? see /usr/share/doc/procps-3.2.7/faq

root 21123 0.0 0.0 3784 672 pts/2 t 15:10 0:00 more 12.sql

root 21346 0.0 0.0 3920 696 pts/2 s+ 15:52 0:00 grep 21123

[root@wgods usb]# fuser -kvm /mnt/usb

user pid access command

/mnt/usb: root 21123 f.c.. more

root 21158 ..c.. man

root 21180 ..c.. sh

root 21182 ..c.. less

root 21223 ..c.. bash

[etl@wgods ~]$ umount /mnt/usb

umount: /mnt/usb is not in the fstab (and you are not root)

[etl@wgods ~]$ su - root

password:

6: 删除usb目錄

[root@wgods ~]# rm -rf /mnt/usb

注意:有時候挂載時,中文的檔案名和目錄名會出現亂碼,為了避免這種情況可以指定字元集,指令如下

[root@wgods ~]# mount -t vfat -o iocharset=utf8,codepage=uft8 /dev/sdb1 /mnt/usb

[root@wgods ~]# mount -t vfat -o iocharset=cp936,codepage=936 /dev/sdb1 /mnt/usb

注意:cp936是指簡體中文,cp950是指繁體中文。

上一篇: CCNA
下一篇: CCNA

繼續閱讀