/Etc/fstab is a text file in which each file system (including partitions or devices) is described in one row. In each row, separate fields with spaces or tabs.
The line starting with * is the comment information. Sorting records in fstab files is very important. Because
Programs such as fsck, mount, and umount perform the work in this order.
Example (sdb1 is the new hard disk ):
#/Etc/fstab: static file system information.
#
# <File system> <mount point> <type> <Options> <dump> <pass>
Proc/proc defaults 0 0
/Dev/sda1/ext3 errors = remount-ro 0 1
/Dev/sda6/home ext3 defaults 0 2
/Dev/sda5 none swap SW 0 0
/Dev/HDC/Media/cdrom0 UDF, iso9660 user, noauto 0 0 0
/Dev/fd0/Media/floppy0 auto RW, user, noauto 0 0
/Dev/sdb1/release El ext3 defaults 0 2
Column 1 and Column 2: devices and default mount points
The content in the first and second columns is the simplest and most direct. They are used to tell the mount command What partitions or devices I want to mount and where I want the mount point. In fstab
The mount point specified for a device is its default mount point, that is, when you do not manually specify other directories when mounting the directory, the system will mount the device to this directory. Majority
The Linux release creates a dedicated directory for the mount point, most of which are under/MNT.
Column 3: File System Type
The third column in fstab indicates the file system type of the device or partition. It supports many types of file systems. Here we will only introduce the most commonly used file systems. If you want to know your Kernel
Which file systems are currently supported? View/proc/filesystems. If this field is defined as SWAP, this record is associated with a file or minute for the purpose of exchange
. If this field is defined as ignored, this row will be ignored. This is very useful for displaying partitions that are not currently in use.
Ext2 and ext3: The ext2 File System in Linux, Which is GNU/Linux
The standard file system in the system features excellent file access performance and better advantages for small and medium files. This is mainly due to the excellent design of its cluster cache layer. As for the ext3 file system, it belongs
Is an extension of the ext2 system. The advantage of a log-type file system is that it records the write operations of the entire disk in a certain area of the disk so that it can be retained when necessary.
Trace. Because every detail is recorded in detail, when a process is interrupted, the system can review and refresh the interrupted part based on these records, the file system does not have to spend time checking other parts.
When the test is inconsistent, the reorganization speed is quite fast and almost no time is required.
Reiserfs:
Reiserfs is a very good file system. It is also one of the earliest log file systems used in Linux, and its mechanism is much more advanced than ext3, which has always been used by Xiao Lei.
The row version also uses it as the default file system. Unfortunately, the author had an accident some time ago ...... I don't know the specific situation, and I don't know whether the next generation of reiserfs4 can come out, because ext4 has
.
Swap: swap, that is, swap zone. Just think of it as virtual memory.
Vfat and
NTFS: Windows partition format. 98, me and other systems are all using vfat, that is, the most popular FAT32 format, while nt series are mostly used.
NTFS, of course, is not fixed, so the 2000 or XP system should be analyzed in detail. At the beginning, Linux had poor support for NTFs writing. Therefore, we recommend that you use most of the data.
Vfat format, but now support has been very good, even if you do not re-compile the kernel, you can also write support through the ntfs-3g (for specific methods please refer to this Article), so do not care too much about this
.
Auto: of course, this is not a file system type. Auto indicates that the file system type is automatically detected. In the above example, you will find the file system type of the soft drive and optical drive.
All of them are auto. Why? Because their file system types may change at any time, such as a soft drive or USB flash drive, today may be in vfat format, and tomorrow you will format it into NTFS, because
In this case, the most sensible way is to tell the system that I cannot determine the current type of this thing. You should check it yourself.
UDF: as a result of the increasing popularity of optical drive, in many fstab releases, the file format type of the optical drive is UDF and the UDF is universal disc.
The abbreviation of format, which is compatible with the ISO 9660 format. It adopts the standard encapsulation and Writing Technology (PW, packet
Writing) uses a CD-R/CD-RW as a hard disk, where users can modify and delete files. When the UDF format is used for burning, the recording software packs the data and temporarily stores the data in the memory.
Create a special file directory table and take over the system's access to the CD.
Iso9660: This option is also used by many optical drives. Iso9660 is an international standard used to describe the structure of computer files suitable for CD disks. Disks using this standard can be used on different operating systems, such as MAC and windows.
Column 4: Mount options
The fourth column in fstab indicates the mounting options required by the device or partition. This column is also the most complex and error-prone column in fstab. Of course, as long as you know some of the most common options
It can free you from headaches. If you want to introduce one of the available options ...... Well, I guess I will write it to tomorrow, so I am just analyzing some of the most commonly used options. if you want
Ask man for help if you know more.
Auto and noauto: This option controls whether devices are automatically mounted. Auto is the default option, so that the device will start or you use Mount
-The a command is automatically mounted according to the fstab content. If you do not want this, use the noauto option. In this case, you can only manually mount the device.
User and
Nouser: This is a very useful option. The user option allows common users to mount devices, while the nouser option only allows root users to mount devices. Nouser is the default option.
Is to make many
Linux beginners have a headache because they find that they cannot mount optical drives or Windows partitions normally. If you encounter similar problems as a common identity user or other problems
Add the user attribute to fstab.
Exec and noexec:
Exec allows you to execute executable binary programs in the corresponding partition. Similarly, noexec has the opposite effect. If you have a partition, there are some executable programs on the partition, and you don't want,
Or you can use the noexec attribute if you cannot execute them in your system. This often happens when Windows partitions are mounted. Exec is the default option, the reason is very simple, if
If noexec becomes the default option for your/root partition ......
RO: mount the file system in read-only mode.
RW: mount the system with readable and writable attributes.
Sync and
Async: How should input and output of the file system be completed. Sync means synchronization is completed. In other words, when you copy something to a device or partition, all the data is written.
The change will take effect immediately after you enter the CP command. This item should be copied to the device or partition immediately. If async is used, that is, the input and output are asynchronously completed
When you press the CP command in a device or partition, the actual write operation is executed long after you press the CP command. In other words, the operation is buffered.
Sometimes this mechanism is quite good, because sync will affect the running speed of your system, but it will also cause some problems. Think about it. When you want to copy a file to a USB flash drive, you run
CP
Command, but forget to execute the umount command (it will forcibly write the buffer content), then the file you copied is not actually on the USB flash disk. If you are using the MV command, and you will soon unmount the USB flash disk
Output ...... Congratulations, the file will disappear from this planet. Therefore, although async is the default attribute, for portable storage devices such as USB flash drives and mobile hard disks, it is better for them to use sync
.
Defaults: use default configurations for all options, including RW, SUID, Dev, exec, auto, nouser, and async.
Generally, you can use ults directly without special requirements. After reading the introduction, let's go back and look at the content of the previous example. Taking the optical drive as an example, we mainly focus on the mounting options here. We can see that the difference between the optical drive and other partition devices is Ro, because the General optical drive is read-only. Exec allows you to execute some programs directly from the optical drive.
Column 5 and column 6: dump and fsck options
The Fifth Column of fstab indicates the dump option. The dump tool determines whether the file system needs to be backed up by the number on the option location. If it is 0, dump will be ignored. In fact, most
The dump setting of the number is 0. the sixth column is The fsck option. The fsck command checks this field to determine the sequence in which the file system scans and checks. The value of the root file system/pair should be
1. Other file systems should be 2. If the file system does not need to scan during startup, set this field to 0.