How Linux mounts a USB flash drive

Source: Internet
Author: User

Before you hang the U-disk, run the command cat/proc/partitions to see what partitions are present in the system. After inserting the U-disk, run the above command again to see what partition (usually sda1,ps because I am installed under the virtual machine, so it is SDB1).
1. Insert USB stick
2, input fdisk-l/DEV/SDA View the output results, such as mine is this:
# fdisk-l/DEV/SDA
disk/dev/sda:131 MB, 131104768 bytes
3 heads, Sectors/track, 2667 cylinders
Units = Cylinders of * 49152 bytes
Device Boot Start End Blocks Id System
/DEV/SDB1 * 1 2668 128016 6 FAT16
3, look at the above output know the device of the U disk, for example, my is/DEV/SDB1, then is mounted, assuming I will mount the USB stick to the/mnt/usb directory (no, new), is
Mount-t Msdos/dev/sdb1/mnt/usb
If it's FAT16, use the following command.
Mount-t Msdos/dev/sdb1/mnt/usb
If it's FAT32,
Mount-t Vfat/dev/sdb1/mnt/usb
In the case of the ext2 format, use the command:
Mount-t Ext2/dev/sda1/mnt/usb
4, open/mnt/usb can see your u disk in the thing!
Cd/mnt/usb
Specific commands:
1. Add-on FAT32 file system
The simplest usage
mount/dev/hda6/mnt/d
/dev/hda6 is the author of Windows D disk,/mnt/d is the directory plus hang point. Linux recognizes what the file system type of the/DEV/HDA6 partition is and then hangs it. Of course, you can also specify the file system type of the partition, with the following command:
Mount-t vfat/dev/hda6/mnt/d
In the actual operation, directly with a Windows partition, the Chinese file name and directory name will be garbled, in order to avoid this situation can specify the character set, the command is as follows:
MOUNT/DEV/HDA6/MNT/D-O codepage=936,iocharset=cp936
Mount-t vfat/dev/hda6/mnt/d-O codepage=936,iocharset=cp936
Note: cp936 refers to Simplified Chinese, cp950 refers to traditional Chinese.
2. Attach the NTFS file system
On most Linux versions today, you will need to recompile your Linux kernel to mount NTFS partitions (see other articles for compiling methods). After the core supports NTFS, you can mount it with the following command:
Mount-t ntfs/dev/hda2/mnt/c
Also for the Chinese file name and directory name will be garbled problem can specify a character set, but unlike the VFAT partition, the actual use of the command is feasible:
Mount-t Ntfs-o iocharset=cp936/dev/hda2/mnt/c-R
Mount-t Ntfs-o iocharset=cp936,rw/dev/hda2/mnt/c
3. Attach the file system on the USB drive
Now there are more and more people using USB flash drive, in fact, the use of the USB flash drive is very simple, Linux USB device has a good support, after you insert a USB stick, the U disk is recognized as a SCSI disk, usually you can use the following command to attach the file system on the USB flash drive
Mount/dev/sda1/usb
Also for Chinese filenames and directory names will be garbled problem can specify a character set, the command is similar to FAT32 described above:
Mount/dev/sda1/usb-o pagecode=936,iocharset=cp936
4. Add a directory to the Linux system shared by Samba
It's hard to say what kind of file system it is, but it doesn't matter if it's transparent to the user. When hanging, we specify the type of SMBFS, when the partition of the Samba shared, also appear in Chinese file name and directory name garbled situation, can be hung with the following command:
Mount-t Smbfs-o
username=terry,password=terry,codepage=936,iocharset=cp936
terry-linux/terry/mp3/
Mount-t Smbfs-o
username=terry,password=terry,codepage=936,iocharset=cp936
192.168.100.228/terry/mp3/
Note: You can not directly write Password=terry This parameter, the system interface will ask you to enter the password, so that you can prevent someone directly see your password. Depending on the situation, the parameters after-O can be increased or decreased.
5. Add-on Window System shared directory
In a local area network, it is often necessary to access directories shared by other Windows systems, and under Linux, after installing Samba, you can use the commands in Samba to access shared resources for Windows machines.
Use Smbclient to list shared resources for Windows machines
Smbclient-l 192.168.100.111
Depending on the shared resources of Windows listed above, you can select a shared resource that needs to be attached to Windows on your local Linux, and then use Smbmount or mount to mount it, please refer to the following several commands:
Smbmount//192.168.100.111/public/public/
Mount//192.168.100.111/d/mnt/cdrom-o Username=terry (to enter the password at the command line)
Mount//192.168.100.111/d/mnt/cdrom-o username=terry$1234 (so you don't have to enter a password at the command line)
Note: In addition to the command line method described above, the best way is to use other clients, such as Linneighborhood, networkneighbours, ksmbshare, etc., please refer to other articles.
All of the above is the command line, each use to enter once, if you often want to hang some file system, you want to automatically when the startup should be how to do? Two methods are described below:
Method 1.
Put the attached command in the/etc/rc.d/rc.local.
Method 2.
Modify the partition profile/etc/fstab, attach the file system at startup, and the following is my/etc/fstab file:
label=//ext3 Defaults
1 1
None/dev/pts devpts gid=5,mode=620
0 0
Label=/home/home ext3 Defaults
1 2
NONE/PROC proc Defaults
0 0
NONE/DEV/SHM TMPFS Defaults
0 0
/DEV/HDA4 Swap swap Defaults
0 0
/dev/cdrom/mnt/cdrom iso9660
Noauto,owner,kudzu,ro 0 0
/dev/hda2/ntfs NTFS defaults,iocharset=cp936 0 0
/dev/hda6/win vfat defaults,codepage=936,iocharset= cp936 0 0
192.168.100.228/terry/mp3 Smbfs username=terry,password=terry,codepage=cp936,iocharset=cp936 0 0
Please note the last three lines:
Bottom line Fourth, add my C drive, NTFS format
The penultimate line, plus my D-disk, FAT32 format
The second-to-last line is a directory on another Linux file server on my LAN that installs samba.
All of the above commands must be root to execute
Linux under the installation of USB drive driver
First, enter the CD/MNT directory
Fdisk-l See if a USB drive is found
Display: Extra sda1 This move is a USB drive
Two, in the MNT directory built file usb
mnt]# mkdir USB
Three, hook up
Mount/dev/sda1/mnt/usb
Four, enter the new USB
Cd/mnt/usb
ll find zone Move file
Five, enter the catalogue
CD/Driver-mounted folder
Cd/src
Make clean Empty the original file
Make install Installation

Re-up

How Linux mounts a USB flash drive

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.