Detailed introduction to Linux automatic FAT partition mounting

Source: Internet
Author: User

We all use computers. Do we know how computers work? An operating system is essential to a computer. However, Linux is developing very rapidly and is catching up with Microsoft. Here we will introduce the knowledge of Linux, so that you can learn how to use Linux. Today we will talk about how to automatically mount the FAT partition when Linux is started. I hope you will remember that the FAT partition will be automatically mounted when Linux is started.

1. the mount point must be a directory.

2. A partition is mounted to an existing Directory. The directory cannot be empty, but the contents in the directory are unavailable.

This is also true for mounting file systems created by other operating systems. However, you need to understand that the formats of the file systems used by CD, floppy disk, and other operating systems are different from those used by Linux. The disk is ISO9660, the disk is fat16 or ext2, the windows NT is fat16 and NTFS, the windows 98 is fat16 and fat32, And the windows2000 and windows XP are fat16, fat32, and NTFS. Before mounting, check whether Linux supports the file system format to be mounted.

Run the mount command during mounting:

Format: mount [-parameter] [device name] [mount point]

Common parameters include:

-T <file system type> specifies the file system type of the device. Common types include:

Minix Linux's earliest File System
Ext2 common file systems in Linux
Msdos MS-DOS fat, is fat16
Fat32 commonly used in vfat windows98
Nfs Network File System
ISO CD-ROM CD standard file system
Ntfs windows NT 2000 File System
Hpfs OS/2 File System
Auto automatically detects the File System

-O <option> specifies the option when the file system is mounted. Some of them are also available in/etc/fstab. Commonly used

Codepage = XXX code page
Iocharset = XXX Character Set
Ro mounting in read-only mode
Rw mounting in read/write mode
Nouser makes the general user unable to mount
The user allows general users to mount devices.

Note that the mount command does not provide the mount point function. Therefore, make sure that the mount point already exists when you execute the mount command. Don't you understand? To put it bluntly, you must first create a directory where you want to mount the file system. So OK ?)

For example, Windows 98 is installed in the hda1 partition, and the disk and disk need to be mounted on the computer.

 
 
  1. # mk /mnt/winc   
  2. # mk /mnt/floppy   
  3. # mk /mnt/cdrom   
  4. # mount -t vfat /dev/hda1 /mnt/winc   
  5. # mount -t msdos /dev/fd0 /mnt/floppy   
  6. # mount -t iso9660 /dev/cdrom /mnt/cdrom  

Now you can access/mnt/winc and other directories to read and write these file systems.

Make sure that the last two lines of commands are correct. Make sure that the drive and the drive have disks. I don't think I will make such a mistake if I can change the disk at any time:->)

If your Windows 98 directory contains a Chinese file name, after mounting the file with the above command, a bunch of garbled characters are displayed. This requires the codepage iocharset option in the-o parameter. Codepage specifies the code page of the file system. The Chinese code in simplified Chinese is 936. iocharset specifies the character set. cp936 or gb2312 is generally used for simplified Chinese.

When the mounted file system is not supported by Linux, mount must report an error, for example, Windows ntfs file system. You can re-compile the Linux kernel to obtain support for the file system. I will not recompile the Linux kernel here.

Iv. automatic mounting

It is too cumbersome to run the mount command every time you access windows partitions at startup. Why not use the mount command to access other Linux partitions?

In fact, during each boot, Linux automatically mounts the Linux partition to be mounted. So can we set the partitions we want to mount when Linux is started, such as windows partitions, to realize automatic mounting of the file system?

This is completely possible. There is a fstab file in the/etc directory, which lists the file systems automatically mounted when Linux is started. My/etc/fstab file is as follows:

 
 
  1. /dev/hda2 / ext3 defaults 1 1   
  2. /dev/hda1 /boot ext3 defaults 1 2   
  3. none /dev/pts devpts gid=5,mode=620 0 0   
  4. none /proc proc defaults 0 0   
  5. none /dev/shm tmpfs defaults 0 0   
  6. /dev/hda3 swap swap defaults 0 0   
  7. /dev/cdrom /mnt/cdrom iso9660 noauto,codepage=936,iocharset=gb2312 0 0   
  8. /dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0   
  9. /dev/hdb1 /mnt/winc vfat defaults,codepage=936,iocharset=cp936 0 0   
  10. /dev/hda5 /mnt/wind vfat defaults,codepage=936,iocharset=cp936 0 0  

In the/etc/fstab file, the first column is the device name of the mounted file system, the second column is the mount point, and the third column is the mounted file system type, the fourth column is the mounting option, which is separated by commas. The fifth and sixth columns do not know what they mean. They also look at their fingers.

Automatically mount the FAT partition in Linux. 2)

In the last two lines, I manually added the C; D Drive in windows, and added the codepage = 936 and iocharset = cp936 parameters to support Chinese file names. The defaults parameter actually contains a set of default parameters:

Rw mounting in read/write mode
Enable User ID and group ID settings for suid
Dev can interpret characters or block devices on the file system
Exec executable binary file
Auto mount
Nouser makes the general user unable to mount
Async executes the input and output operations of the file system in non-synchronous Mode

You can see that in this list, the optical drive and the soft drive are not automatically mounted, and the parameter is set to noauto. If you want to enable automatic mounting, make sure that you have disks in your drive and drive every time you start the system .)

Create several directories under/mnt, such as d, e, f, and g. Then, use a text editor such as vi to modify the/etc/fstab file and add it to the end.

/Dev/hda5/mnt/d auto defaults 0 0

After you restart Linux, you will find that disk D has been automatically attached to/mnt/d. If you want to mount disk E, you only need to add it to the end of the/etc/fstab file.

/Dev/hda6/mnt/e auto defaults 0 0

Note: if an error occurs when using hda5, change it to hdb5 or hdc5. This is because in Linux, hard disks are represented as hd, the first hard disk is hda, the second is hdb, and so on. A hard disk can be divided into up to four primary partitions: dos primary partition, dos extended partition, Linux Root partition, and Linux swap partition. The four primary partitions are represented by numbers respectively. The first hard disk is hda1, hda2, hda3, and hda4. Extended partitions can be divided into logical partitions, with labels arranged in sequence from 5. In windows, drive C is the primary dos partition hda1), drive D is generally the first logical partition hda5 on the extended dos partition), drive E is hda6, and so on. You can mount hda5 with the mount command to see if it is successful. If it fails, change it to hdb5, hdc5, and so on. For example:

Mount-t auto/dev/hda5/mnt/d

The above content is for the IDE hard disk. If you are using a SCSI hard disk, change hda to sda, sdb, sdc, etc.

If your Linux kernel version is too old and does not support ntfs partitions, install a patch.

First, determine the version number of your Linux kernel:

Rpm-q kernel

The displayed result contains a message similar to this: kernel-2.4.20-8. This is the version number of your Linux kernel.

Then go to the http://rpm.pbone.net/find the kernel-ntfs-kernel version. i686.rpm such as the kernel-ntfs-2.4.20-8.i686.rpm ). After the download, run the following command to install

Rpm-ivh kernel-ntfs-2.4.20-20.8.i686.rpm

If no error occurs, your system supports ntfs. If an error is reported, the patch you downloaded does not match your kernel version. I hope you will learn how to automatically mount the FAT partition at startup in Linux.

  1. Easily connect to the campus network using Linux
  2. Fully Understand Linux Process Technology
  3. Introduction to the password command in Linux
  4. Learn about Linux regulatory commands
  5. How to view the ps-aux command of all processes in Linux

Related Article

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.