In-depth understanding of the fstab file under Linux system——The road to dream building

fstab understanding 

The fstab file contains information about the storage devices and their file systems on your computer. It is a file that determines how a hard disk (partition) is used or integrated into the entire system. Specifically: fstab can be used to automatically mount hard disks, partitions, removable devices and remote devices in various file system formats. For Windows and Linux dual operating system users, use fstab to mount FAT format and NTFS format partitions to share resources under the Windows system in Linux.

The full path of this file is /etc/fstab. It's just a text file that you can open with your favorite editor, but you must be root to edit it. At the same time, fsck, mount, umount and other commands all use this program.

/etc/fstab is the configuration file at startup, but the actual filesystem mounting is recorded in the two files /etc/mtab and /proc/mounts. Every time we change the mount of filesystem, these two files will also be changed at the same time.

System mount restrictions

  • The root directory / must be mounted, and it must be mounted before other mount points.

  • Other mount points must be created directories and can be specified arbitrarily, but must comply with the necessary system directory structure principles.

  • All mount points can only be mounted once at the same time.

  • All partitions can only be mounted once at the same time.

  • To dismount, you must first move the working directory outside of the mount point (and its subdirectories).

# <fs>            <mountpoint>    <type>        <opts>        <dump/pass>

# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
/dev/sda10        /boot            ext4        noauto,noatime    1 2
/dev/sda6         /                ext4        noatime           0 1
/dev/sda9         none             swap        sw                0 0
/dev/cdrom        /mnt/cdrom       auto        noauto,ro         0 0

 /etc/fstab (filesystem table) is when we use the mount command to mount, we just write all the options and parameters into this file. In addition, /etc/fstab also adds support for the dump backup command! It is related to whether to perform file system check fsck and other commands at startup. 

  • <file systems> Mounted device: It is not the file system we usually understand, but refers to the device (hard disk and its partitions, DVD drive, etc.). It tells us the name of the device (partition), which is used when you mount (mount) and unmount (umount) the device on the command line.

  • <mountpoint> Mount point: tells us where the device is mounted.

  • <type> File system type: Linux supports many file systems. For a complete list of supports look at the mount man-page. Typical names include: ext2, ext3, reiserfs, xfs, jfs, iso9660, vfat, ntfs, swap and auto. 'auto' is not a file system, but allows the mount command to automatically determine the file type, especially for removable devices. This is necessary for floppy disks and DVD drives because the file types may be inconsistent each time they are mounted.

  • <opts> File system parameters: This section is the most useful setting! ! ! It can make the device you mount automatically loaded when booting, prevent Chinese display from garbled characters, and limit the read and write permissions on the mounted partition. It is related to the usage of the mount command. For a complete list, refer to the mount manpage.

  • <dump> Backup command: The dump utility is used to decide whether to back up. Dump will check the entry and use numbers to decide whether to back up the file system. Allowed numbers are 0 and 1. If it is 0, dump will ignore this file system. If it is 1, dump will make a backup. Most users have not installed dump, so for them, the <dump> entry should be written as 0.

  • <pass> Whether to use fsck to check sectors: During the startup process, the system will use fsck by default to check whether our filesystem is complete (clean). However, some file systems do not need to be checked, such as memory replacement space (swap), or special file systems such as /proc and /sys, etc. fsck will check the number under this header to determine the order in which to check the file system. The allowed numbers are 0, 1, and 2. 0 means no checking, 1 means the earliest check (generally only the root directory will be configured as 1), and 2 also needs to be checked. Inspection, but 1 will be inspected earlier! Generally speaking, the root directory is configured as 1, and other filesystems to be tested are configured as 2.

<opts>Common parameters:

  • noatime Turn off the atime feature to improve performance. This is a very old feature. Don’t worry about turning it off and it can also reduce loadcycle.

  • defaults Use default settings. Equal to rw, suid, dev, exec, auto, nouser, async. Please see the explanation below for the specific meaning.

  • Automatic and manual mounting:
    auto Automatically mount when starting or entering mount -a in the terminal
    noauto Devices (partitions) can only be mounted manually mount

  • Read and write permissions:
    ro Mount as read-only permissions
    rw Mount as read-write permissions

  • Executable:
    exec is a default setting that enables executable binaries in that partition to execute
    noexec Binary files are not allowed implement. Never use this option on your root partition! ! !

  • I/O synchronization:
    sync All I/O will be performed synchronously
    async All I/O will be performed asynchronously< /span>

  • User mounting permissions:
    user allows any user to mount the device. Implies noexec,nosuid,nodev unless overridden.
    nouser Only root users are allowed to mount. This is the default setting.

  • Temporary file execution permissions:
    suid Allow suid operations and set the sgid bit. This parameter is usually used for some special tasks, allowing ordinary users to temporarily increase their privileges when running the program.
    nosuid Disable suid operations and set the sgid bit.

 

Guess you like

Origin blog.csdn.net/qq_34777982/article/details/135021673