How to mount a USB device in FAT32 format in Linux

Source: Internet
Author: User

Run CAT/proc/partitions to check the partitions in the system. After plugging in the USB flash drive, run the preceding command again to see what partitions are added. This is generally sda1.

1. Insert a USB flash drive

2. Input fdisk-L/dev/SDA to view the output result. For example, mine is like this:

[Root @ leason-laptop proc] # fdisk-L/dev/SDA

Disk/dev/SDA: 2004 MB, 2004877312 bytes

247 heads, 62 sectors/track, 255 Cylinders

Units = cylinders of 15314*512 = 7840768 bytes

Device boot start end blocks ID system

/Dev/sda1*1 256 1957856 C w95 FAT32 (LBA)

Partition 1 has different physical/logical beginnings (non-Linux ?) :

Phys = (0, 1, 1) logical = (0, 1, 3)

Partition 1 has different physical/logical endings:

Phys = (505,246, 0) logical = (255,172, 42)

Partition 1 does not end on cylinder boundary.

[Root @ leason-laptop proc] # Mount-T vfat/dev/sda1/mnt/USB/

3. After reading the output above, you will know the device where the USB flash disk is located. For example, my device is/dev/sda1, And then I mounted it, suppose I mount the USB flash drive to the/mnt/USB directory (if not, create a new one), that is

If fat16 is used, use the following command.

Mount-T msdos/dev/sda1/mnt/USB

For FAT32

Mount-T vfat/dev/sda1/mnt/USB

If the format is ext2, run the following command:

Mount-T ext2/dev/sda1/mnt/USB

4. Open/mnt/USB and you will be able to see what is in your USB flash drive!

CD/mnt/USB

Specific commands:

1. Add the FAT32 File System

Simplest usage

Mount/dev/hda6/mnt/d

/Dev/hda6 is the author's windows D disk,/mnt/D is the directory mount point. Linux recognizes the type of the file system in the/dev/hda6 partition, and then adds it. Of course, you can also specify the file system type of the partition. The command is as follows:

Mount-T vfat/dev/hda6/mnt/d

In practice, a Windows partition is directly attached, and the Chinese file name and directory name are garbled. To avoid this problem, you can specify a character set by running the following command:

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 and cp950 refers to traditional Chinese.

2. Mount the NTFS file system

In most Linux versions, you need to re-compile the Linux core to mount the NTFS partition (see other articles for the compilation method ). After the core supports NTFS, run the following command:

Mount-t ntfs/dev/hda2/mnt/C

You can also specify the character set for garbled characters in Chinese file names and directory names. However, unlike the vfat partition, the following command is practical:

Mount-t ntfs-O iocharset = cp936/dev/hda2/mnt/c-r

Mount-t ntfs-O iocharset = cp936, RW/dev/hda2/mnt/C

3. Mount the file system on the USB flash drive

More and more people are using USB flash drives. In fact, using USB flash drives in Linux is also very simple. Linux has good support for USB devices. After you insert a USB flash drive, the USB flash disk is recognized as a SCSI disk. You can use the following command to mount the file system on the USB flash disk.

Mount/dev/sda1/USB

You can specify a character set for garbled characters in Chinese file names and directory names. The command is similar to the one described in FAT32:

Mount/dev/sda1/USB-O pagecode = 936, iocharset = cp936

4. Add a Linux directory shared by Samba.

The directory shared by Samba is hard to tell which file system it was originally, but this is not important as long as it is transparent to users. When mounting, we specify the smbfs type. When mounting a samba shared partition, Chinese file names and directory names may also be garbled. You can run the following command to mount the file:

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 do not need to directly write the Password = Terry parameter. In the system field, you will need to enter the password to prevent anyone from directly viewing your password. Depending on the actual situation, the parameters following-O can be increased or decreased accordingly.

5. Add the directory shared by the window system

In the LAN, you often need to access the directories shared by other Windows systems. In Linux, after Samba is installed, you can use the commands in Samba to access the shared resources of Windows machines.

Use smbclient to list shared resources of Windows machines

Smbclient-l 192.168.100.111

Based on the Windows Shared resources listed above, you can select the Windows Shared resources to be attached to the local Linux, and then use smbmount or mount to add the resources. refer to the following commands:

Smbmount // 192.168.100.111/public/

Mount // 192.168.100.111/D/mnt/CDROM-O username = Terry (enter the password on the command line)

Mount // 192.168.100.111/D/mnt/CDROM-O username = Terry $1234 (you do not need to enter the password in the command line)

Note: In addition to the command line method described above, the best method is to use other clients, such as linneighborhood, networkneighbours, and ksmbshare. Please refer to other articles.

The above is a command line method. You must enter the command once each time you use it. If you often need to mount some file systems, what should you do if you want to automatically mount them at startup? The following two methods are described:

Method 1.

Place the mounting command in/etc/rc. d/rc. Local.

Method 2.

Modify the partition configuration file/etc/fstab and mount the file system at startup. The following is my/etc/fstab file:

Label = // ext3 defaults

1 1

None/dev/PTS devpts gid = 5, mode = 620

0 0

Label =/home ext3 defaults

1 2

None/proc defaults

0 0

None/dev/SHM tmpfs ults

0 0

/Dev/hda4 swap defaults

0 0

/Dev/CDROM/mnt/CDROM iso9660

Noauto, owner, kudzu, RO 0 0

/Dev/hda2/NTFS ults, 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

Note the last three lines:

The fourth to last line adds my C drive, NTFS format

In the last row, mount my d disk, in FAT32 format.

In the penultimate line, a directory is mounted to another Linux file server on which Samba is installed in my LAN.

All the preceding commands must be run as root.

After using the USB flash drive, remember to unmount it before pulling the USB flash drive. The operation is as follows:

# Umount-L/mnt/USB

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.