linux中fstab文件介绍

发布时间:2020-11-01编辑:脚本学堂
本文介绍下,linux中的fstab文件,此文件包含了系统中的存储设备及文件系统的信息。有需要的朋友参考下。

linux系统中的fstab文件,包含了电脑上的存储设备及其文件系统的信息。
它是决定一个硬盘(分区)被怎样使用或者说整合到整个系统中的唯一文件。

文件路径:/etc/fstab

fstab文件示例
 

# <file system>        <dir>         <type>    <options>             <dump> <pass>
none                   /dev/pts      devpts    defaults                0      0
none                   /dev/shm      tmpfs     defaults                0      0
/dev/dvd               /media/dvd    udf       ro,user,noauto,unhide   0      0
/dev/hda1              swap          swap      defaults                0      0
/dev/hda4              /             ext3      defaults                0      1
/dev/hda3              /home         xfs       rw,suid,exec,auto,nouser,async 0      2
UUID=03ec5dd3-45c0-4f95-a363-61ff321a09ff /www ext4 defaults,noatime  0      2

fstab文件详解
<file system> <dir> <type> <options> <dump> <pass>
<file systems>选项
指设备(硬盘及其分区,DVD光驱等)

<dir>选项
设备挂载目录。

<type>选项
指挂载设备或分区为何种文件系统类型(例如:ext2, ext3, reiserfs, xfs, jfs, smbfs, iso9660, vfat, ntfs, swap等)。
<options>选项
这部分是最有用的设置,它能使所挂载的设备在开机时自动加载、使中文显示不出现乱码、限制对挂载分区读写权限等。

选项说明:
 

auto - File system will mount automatically at boot, or when the command 'mount -a' is issued.
noauto - The filesystem is mounted only when you tell it to.
exec - Allow the execution binaries that are on that partition (default).
noexec - Do not allow binaries to be executed on the filesystem.
ro - Mount the filesystem read only
rw - Mount the filesystem read-write
sync - I/O should be done synchronously
async - I/O should be done asynchronously
flush - specific option for FAT to flush data more often, thus making copy dialogs or progress bars to stays up until things are on the disk
user - Permit any user to mount the filesystem (implies noexec,nosuid,nodev unless overridden.)
nouser - Only allow root to mount the filesystem. (default)
defaults - Default mount settings (equivalent to rw,suid,dev,exec,auto,nouser,async).
suid - Allow the operation of suid, and sgid bits. They are mostly used to allow users on a computer system to execute binary executables with temporarily elevated privileges in order to perform a specific task.
nosuid - Block the operation of suid, and sgid bits.
noatime - Do not update inode access times on the filesystem. Can help perf