To attach a USB flash drive to Linux, follow these steps:
1: insert the USB flash drive into the USB interface and check whether the USB flash drive is inserted.
2: run the fdisk command to check the partition and USB device information.
[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
Device Boot Start End Blocks Id System
/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)
The above information shows that the USB device is in the FAT32 format and marked as/dev/sdb1.
[Root @ wgods ~] # Fdisk-l | grep FAT32
/Dev/sdb1*56 640 3580928 c W95 FAT32 (LBA)
3: Create a usb directory under the mnt directory
[Root @ wgods ~] # Cd/mnt/
[Root @ wgods mnt] # mkdir usb
4: mount a USB flash drive
[Root @ wgods mnt] # mount-t vfat/dev/sdb1/mnt/usb
After the mounting is successful, we can see the relevant content under/mount/usb.
5. unmount the USB flash drive.
When you run the umount command to uninstall the USB flash drive, the following error "device is busy" is reported. You can use the parameter l to solve the problem. You can also use the fuser command to solve the problem. As shown below
[Root @ wgods ~] # Umount/mnt/usb
Umount:/mnt/usb: device is busy
Umount:/mnt/usb: device is busy
[Root @ wgods ~] # Umount-f/mnt/usb
Umount2: Device or resource busy
Umount:/mnt/usb: device is busy
Umount2: Device or resource busy
Umount:/mnt/usb: device is busy
[Root @ wgods ~] # Umount-l/mnt/usb
Problem Solving
---------------------------------------------------------------------------------
[Root @ wgods usb] # umount/mnt/usb
Umount:/mnt/usb: device is busy
Umount:/mnt/usb: device is busy
[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 bogu '-'? See/usr/share/doc/procps-3.2.7/FAQ
Root 21123 0.0 0.0 3784 672 pts/2 T more 12. SQL
Root 21346 0.0 0.0 3920 696 pts/2 S + 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:
[Root @ wgods ~] # Umount/mnt/usb
6. Delete the usb directory.
[Root @ wgods ~] # Umount-l/mnt/usb
[Root @ wgods ~] # Rm-rf/mnt/usb
Note: During mounting, Chinese file names and directory names may be garbled. To avoid this problem, you can specify the character set by running the following command:
[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
Note: cp936 refers to simplified Chinese and cp950 refers to traditional Chinese.
Source: http://www.cnblogs.com/kerrycode/