Use of 'fstab'
'/Etc/fstab' is an important configuration file for the 'mount' command. You can use the 'root' identity to modify this file through 'diskdrake' (Mandrake Linux Control Center-load point) or by using the editor.
'/Etc/fstab' has several functions:
*
Determines which media is automatically mounted at startup;
*
Specifies the options and loading points for each media mount;
*
The system is used to mount several virtual file systems.
Mount media at startup
By default, all media listed in 'fstab' will be mounted at startup. If an error occurs in a media set, 'mount' displays the error message and continues the next object. Note that this is also valid for network media such as NFS or SMB sharing. If you want to cancel Automatic mounting at startup, you must provide the 'noauto' option for the corresponding entry in '/etc/fstab.
Specify mounting options and loading points
If you read the previous article, you know that the 'mount' command has two options: General options and special options for the file system.
Special options are applicable to specific file systems. If you provide special options for an entry in 'fstab' (for example, umask = 0 for Windows FAT file system ), only the media of the corresponding file system can be mounted through this entry. If you want to mount the media of another file system, either set the option or create a separate entry.
It is advantageous to specify the loading point. You can omit the file name of the device when mounting/detaching.
Mount mount_point
In '/etc/fstab', find the entry of the corresponding loading point and mount it according to the preset settings.
Virtual File System
According to the system configuration, 'fstab' contains Virtual File System entries that do not list the corresponding device files. In any case, do not move these entries!
*
'Proc' mounts the process tree to provide system information;
*
'Pts 'enables "Pseudo Terminal support" (Pseudo Terminal Support), which is compatible with Unix;
*
Enable POSIX shared memory in 'shm'. Only a small part of the program will be used without any negative impact.
* Section Index * Top
* Description of the entry in 'fstab'
Local Fixed system partition
You can see that '/etc/fstab' already contains several system partitions (such. Take this example:
/Dev/hda3/ext2 defaults 1 1
Syntax:
/Dev/hda3/ext2 defaults 1 1
Device_name mount_point file_system options 'dumpe2fs' 'fsck'
There are device names, load points (/), and file systems (ext2) of the media (partition of the hard disk ).
Defaults includes several 'mount' options: RW readable and writable, and SUID allows setting of User Identifier (set-user-identifier) exec allows running programs, automatic mounting during auto startup, nouser only has 'root' permission to detach, and async allows disk delay (caching ).
The last two options are the symbols used by the file system tools 'dumpe2fs' and 'fsck.
The 'dump' field can be set to '1' (Enabled) or '0' (disabled ). Because the program that backs up the ext2/ext3 file system uses 'dump', set the file system to '1' for the ext2/ext3 entries, and set all other entries to '0 '.
The 'fsck' field can be set to '0' (do not check the file system), '1' (check first), and '2' (check ). All non-Linux File Systems, removable and network media, and virtual file systems must be set to '0'. Because the root partition must be mounted first (then checked ), the '/' entry must be set to '1', and all other non-removable and Linux File System local media must be set to '2 '.
Removable Media
Removable data storage bodies, such as CDs, require different options (if you do not use 'supermount '):
/Dev/CDROM/mnt/CDROM auto user, noauto, exec, RO 0 0
The user allows the user to attach or detach a file. Otherwise, only 'root' has the permission. Please note that this option will disable exec. You must specify exec after the user option is available so that you can run the program in the mounted media. These are the same as the above example. Noauto indicates that the media is not mounted at startup. This option is required for some removable media. Read-Only media mounted by Ro ). 'Dump' and 'fsck' are all disabled.
Although the disc is not set to auto-mounted, the following attaching is simple due to this entry in '/etc/fstab': Put the disc and enter:
Mount/mnt/CDROM
'Mount' searches for the entry associated with this load point in '/etc/fstab' and uses the listed options. Therefore, you can save some input. In Kde, after you place the disc, you can click the disc icon with the mouse to automatically run the 'mount' command.
The mounted disc will lock the optical drive. To bring up the disc, you must first uninstall umount/mnt/CDROM.
To configure other removable media, you need to know their device file names. You can refer to devices.txt or read articles about removable storage devices.
Local Fixed non-system partition
What does Ms-Windows partition entry look like? Assume that the disk is in the second partition of the first IDE hard disk, and you want to automatically mount the disk:
/Dev/hda2/mnt/win_d vfat umask = 0, quiet 0 0
For the NTFS partition of Windows NT, replace 'vfat' with 'ntfs '. Note that in Linux, only NTFS file systems can be read, but not written.
The 'umask 'option will disable permission monitoring. Without this option, only 'root' can access the files on the device. When a file is moved to the media, an annoying error message is displayed because the permission cannot be set. You can use 'quiet 'to not display the irrelevant information.
If the file name in the Windows partition looks strange, you have to add two more options: 'iocharset' and 'codepage '. By default, 'mount' uses the 'iso8859-1' Character Set and codePage 437. After modification, character conversion can be realized. Man charsets lists available character sets and sets codePage to 850 (codePage = 850) to solve some problems.
(Note: To display Simplified Chinese, add charsets = gb2312, codePage = 936)
If a partition is mounted to an existing directory, the directory cannot be empty. However, after mounting, 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. (Do not 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.
# Mk/mnt/winc
# Mk/mnt/floppy
# Mk/mnt/CDROM
# Mount-T vfat/dev/hda1/mnt/winc
# Mount-T msdos/dev/fd0/mnt/floppy
# 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. (If the disk on the hard disk can be changed at any time, I don't think I will make such a mistake:->)
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.
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:
/Dev/hda2/ext3 defaults 1 1
/Dev/hda1/boot ext3 defaults 1 2
None/dev/PTS devpts gid = 5, mode = 620 0 0
None/proc defaults 0 0
None/dev/SHM tmpfs defaults 0 0
/Dev/hda3 swap defaults 0 0
/Dev/CDROM/mnt/CDROM iso9660 noauto, codePage = 936, iocharset = gb2312 0 0
/Dev/fd0/mnt/Floppy auto noauto, owner, kudzu 0 0
/Dev/hdb1/mnt/winc vfat defaults, codePage = 936, iocharset = cp936 0 0
/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.
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 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 set it to automatic mounting, make sure that there is a disk in your drive and drive every time you start the system .)