I want to make a summary of fstab, but I found that there are already many mature documents on the Internet. Therefore, this article is from the content on the Internet and is spliced by myself to make it complete.
Fstab: This file describes information about various file systems in the system. Generally, an application only reads this file and does not write the file. Maintenance is the work of the system administrator. In this file, each file system is described in one line. In each line, fields are separated by spaces or tabs. The lines starting with # in the file are comments. Sorting records in Fstab files is very important. Because programs such as fsck, mount, and umount perform their work in this order.
The configuration syntax is as follows:
Fs_spec fs_file fs_type fs_options fs_dump fs_pass
/Dev/hda1/ext2 defaults 1 1
Fs_spec: this field defines the device or remote file system where the file system to be loaded is located. For general local Block devices, the IDE device is generally described as/dev/hdXN, X is the channel (a, B, or c) of the IDE device. N represents the Partition Number. SCSI device 1 is described as/dev/sdXN. For procfs, use 'proc' for definition. The definition of a file system (fsspec) that describes the block device or remote file system to be mounted. For a general mount operation, this field should include the device node of the block device to be loaded (created using the mknod command) or the connection to such nodes (such as/dev/cdrom or/dev/sdb). For the NFSmount operation, this field should contain information in the host: dir format. For the process File System procfs, use proc. In addition to the displayed device name, you can use the UUID of the device or the volume label of the device. For example, you can write "LABAL = root" or "UUID = 3e6be9de-8139-11d1-9106-a43f08d823a6 ", this will make the system more scalable. For example, if your system adds or removes a SCSI hard disk, this may change your device name, but it will not change your volume tag.
Fs_file: this field describes the directory point to be loaded by the file system. For a swap device, this field is none. For a directory name containing spaces, 40 is used to indicate spaces. Description of the file system load point. For swap partition (swap), this field is defined as none. If the path of the load point contains a space character, you can use "\ 040" to replace the space character.
Fs_type: defines the file system on the device. The common file types are ext2 (common file types for Linux devices) and vfat (fat32 format for Windows systems), NTFS, iso9600, etc. the file system type (fsvfstype) is mainly used to define the file system type. Linux supports a large number of file types, including sdfs, affs, autofs, jfs, minix, msdos, ncpfs, nfs, ntfs, proc, qnx4, reiserfs, romfs, smbfs, sysv, tmpfs, udf, ufs, umsdos, vfat, xenix, xfs, etc. If you want to know which file systems your kernel currently supports, you can view the/proc/filesystems content. If this field is defined as swap, this record is associated with a file or partition 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.
Fs_options: specifies that the file system to which the device is loaded is a specific parameter option, multiple parameters are separated by commas. The file system option (fsmntops) used when loading the file system. Multiple options are separated by commas. The list of these options includes the loading type and other loading options suitable for the file system. For mounting options available for non-NFS systems, see the description of the mount command. For nfs system options, see the nfs documentation. Options applicable to all file systems include noauto (not loaded when the mount-a command is used), user (allowing users to load), owner (allowing all devices to load ), _ netdev (the device requires a network). The last two options are unique to the linux system.
Most systems can use "defaults" to meet their needs. Other common options include:
Option description
Ro loads the file system in read-only mode
Sync does not buffer write operations on the device, which can prevent file system damage during abnormal shutdown, but reduces the computer speed.
User allows normal users to load the File System
Quota forces disk quota limit on this file system
Noauto no longer uses the mount-a command (for example, when the system is started) to load the File System
Fs_dump: This option is used by the "dump" command to check how often a file system should be dumped. If no dump is required, set this field to 0. the file system frequency (fs_freq) is used by the dump program to determine which file system requires dump. If the last field is not set, the system considers the value 0, the dump program assumes that the file system does not require dump.
Fs_pass: this field is used by The fsck command to determine the sequence of the file system to be scanned at startup. The value of the "/" pair of the root file system should be 1, other file systems should be 2. If the file system does not need to scan at startup, set this field to 0. used by the fsck program to determine the sequence of checking the file system during system restart. The root system/value should be set to 1, and other file systems can be set to 2, file Systems on the same physical hard disk should be checked sequentially, while file systems on different hard disks should be checked at the same time to make full use of system parallelism. If the last field value is 0 or is not set, The fsck program skips the detection of this file system. In linux programming, you can use the getmntent process to access the content of this file.
--------------------------------------------------------------------------------
The fs_options parameter is worth mentioning. This parameter can be used to mount the nfs file in the target file:
HARD:
The nfs client constantly tries to connect to the SERVER (in the background, no prompt is provided, and some prompts are still provided in some versions of LINUX) until MOUNT
.
SOFT:
Will try to connect to the SERVER on the front-end, which is the default connection method. When an error message is received, the mount attempt is terminated and related information is provided.
Example: mount-F nfs-o hard 192.168.0.10:/nfs
Rsize and wsize:
File Transfer size setting: wsize. The setting of these two parameters has a great impact on the NFS execution efficiency.
Bg:
If the mount fails, the system transfers the mount operation to the background and continues to try the mount until the mount is successful. (Usually
Bg should be used when setting the/etc/fstab file to avoid the startup speed being affected due to the possible mount failure)
Fg:
In contrast to bg, It is the default parameter.
Nfsvers = n:
Sets the NFS version to be used. The default value is 2. The setting of this option depends on whether the server supports nfs ver 3.
Mountport:
Set the mount Port
Port:
Set the port based on the export output from the server. For example, if the server uses port 5555 to output NFS, the client needs to use this parameter for the same setting.
Timeo = n:
Set the time-out period. When data transmission encounters a problem, the system tries to re-transmit the data based on this parameter. The default value is 7/10 (0.7 seconds ). If the network connection is not very stable, we recommend that you increase the value and use the hard mount method. We recommend that you also add the INTR parameter so that you can terminate any pending file access.
Intr: allows an NFS call to be interrupted. It is useful when the server does not respond and must be abandoned.
Udp: Use udp as the nfs transmission protocol (NFS V2 only supports UDP)
Tcp: use tcp as the nfs transmission protocol
Namlen = n: specifies the maximum file name allowed by the remote server. The default value is 255.
Acregmin = n: sets the minimum cache time before file update. The default value is 3.
Acregmax = n: sets the maximum cache time before file update. The default value is 60.
Acdirmin = n: sets the minimum cache time before directory update. The default value is 30.
Acdirmax = n: sets the maximum cache time before directory update. The default value is 60.
Actimeo = n: Set acregmin, acregmax, acdirmin, and acdirmax to the same value, which is disabled by default.
Retry = n: set the time required for reconnecting when network transmission fails. The default value is 10000 minutes.
Noac: Disable the cache mechanism.
Use multiple parameters at the same time: mount-t nfs-o timeo = 3, udp, hard 192.168.0.30:/tmp/nfs
Note that the options of the NFS client and server are not necessarily the same, and sometimes there are conflicts. For example, if the server exports data in read-only mode, but the client mounts the data in writable mode, an error occurs when writing the data. Generally, the configuration of the server prevails when the server and client are in conflict.
Below are some samples of the fstab configuration file used by the company for production:
LABEL = // xfs defaults 1 1
LABEL = SWAP swap defaults 0 0
Tmpfs/dev/shm tmpfs defaults 0 0
Devpts/dev/pts devpts gid = 5, mode = 620 0 0
Sysfs/sys sysfs defaults 0 0
Proc/proc defaults 0 0
/Dev/lewa/data ext4 defaults 0 0
/Dev/lewa/web ext4 defaults 0 0
/Dev/lewa/Hadoop_data/hadoop_data ext4 defaults 0 0
Web-storage-1:/data/www/static/discuz/xwb/log/web/bbs/htdoc/xwb/log nfs rsize = 8192, nfsvers = 4, wsize = 8192, timeo = 14, intr, bg, retry = 100, nofail 0 0
Web-storage-1:/data/www/static/discuz/uc_server/data/web/bbs/htdoc/uc_server/data nfs rsize = 8192, nfsvers = 4, wsize = 8192, timeo = 14, intr, bg, retry = 100, nofail 0 0
Web-storage-1:/data/www/static/discuz/static/web/bbs/htdoc/static nfs rsize = 8192, nfsvers = 4, wsize = 8192, timeo = 14, intr, bg, retry = 100, nofail 0 0
Web-storage-1:/data/www/static/discuz/xwb/cache/web/bbs/htdoc/xwb/cache nfs rsize = 8192, nfsvers = 4, wsize = 8192, timeo = 14, intr, bg, retry = 100, nofail 0 0
Web-storage-1:/data/www/static/discuz/data/web/bbs/htdoc/data nfs rsize = 8192, nfsvers = 4, wsize = 8192, timeo = 14, intr, bg, retry = 100, nofail 0 0
Web-storage-1:/data/fcfiles/theme/web/theme/htdoc/theme nfs rsize = 8192, nfsvers = 4, wsize = 8192, timeo = 14, intr, bg, retry = 100, nofail 0 0
Pay more attention to the parameters. It is very useful.
Recommended reading:
Linux File System concepts and basic operations
Linux Log File System details