一,作用

/etc/fstab是用来存放文件系统的静态信息的文件,当系统启动时,系统会自动地从这个文件读取信息,并且会自动将此文件中指定的文件系统挂在到执行的目录

二,挂载的限制

1,根目录是必须挂载的,而且一定要先于其他mount point被挂载.因为mount是所有目录的根目录,其他目录都是由根目录/ 衍生出来的
2,挂载点的指定可以任意,但必须遵守必要的系统目录架构原则
3,挂载点必须是已经存在的目录
4,所有挂载点在同一时间只能被挂载一次
5,所有分区在同一时间只能挂在一次
6,若进行卸载,必须将工作目录退出挂载点(及其子目录)之外

三,/etc/fstab文件中的参数

cat /etc/fstab 查看当前系统已经存在的挂载信息
[root@server ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Fri Mar 24 19:30:39 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=fd93d9dc-e277-4926-8a83-c731b5600f8b / ext4 defaults 1 1
UUID=c9517f8f-081d-444f-8510-92d236671b37 /boot ext4 defaults 1 2
UUID=bd841c60-daf5-4c5d-8392-95d4e8b9f4e7 /opt ext4 defaults 1 2
UUID=fe6dd69c-99f4-478d-acc7-ef7e156e5bc5 /usr/local ext4 defaults 1 2
UUID=1e71b8a2-bb4e-4e39-a894-e04fb6480e2e 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 proc defaults 0 0

第一列:Device:磁盘设备文件或者该设备的Label或者UUID

The first field, (fs_spec), describes the block special device or remote filesystem to be mounted.
1),查看分区的label和uuid
Label就是分区的标签,在最初安装系统时填写的挂载点就是标签的名字.可以通过查看一个分区的superblock中的信息找到UUID和Label Name
如:要查看/dev/sda1这个设备的uuid和label name
命令1:dumpe2fs -h /dev/sda1
[root@server ~]# dumpe2fs -h /dev/sda1
dumpe2fs 1.41.12 (17-May-2010)
Filesystem volume name: <none>
Last mounted on: /boot ---->这个就是Label name
Filesystem UUID: c9517f8f-081d-444f-8510-92d236671b37 ---->UUID
Filesystem magic number: 0xEF53

命令2:blkid
[root@server ~]# blkid
/dev/sda1: UUID="c9517f8f-081d-444f-8510-92d236671b37" TYPE="ext4"
/dev/sda2: UUID="1e71b8a2-bb4e-4e39-a894-e04fb6480e2e" TYPE="swap"
2),使用设备名和label及uuid作为标识的不同
使用设备名称(/dev/sda)来挂载分区时是被固定死的,一旦磁盘的插槽顺序发生了变化,就会出现名称不对应的问题。因为这个名称是会改变的。
不过使用label挂载就不用担心插槽顺序方面的问题。不过要随时注意label name,至于uuid,每个分区被格式化以后就会有一个UUID作为唯一的标识好。使用UUID作为唯一的标识号,使用UUID挂载的话就不用担心会发生错乱的问题

第二列: Mount point:设备的挂载点,就是要挂载到哪个目录下
The second field, (fs_file), describes the mount point for the filesystem. For swap partitions, this field should be specified as ‘none’. If the name of the mount point contains spaces these can be escaped as ‘\040’.

第三列:filesystem:磁盘文件系统的格式支持许多不同的文件系统:ext2,ext3,ext4,reiserfs,xfs,jfs,smbfs,iso9660,vfat,swap及auto,设置成auto类型,mount命令会猜测使用的文件系统类型,对CDROM和DVD等移动设备是非常有用的

The third field, (fs_vfstype), describes the type of the filesystem. Linux supports lots of filesystem types, such as adfs,affs, autofs, coda, coherent, cramfs, devpts, efs, ext2, ext3, hfs, hpfs, iso9660, jfs, minix, msdos, ncpfs, nfs, ntfs, proc,qnx4, reiserfs, romfs, smbfs, sysv, tmpfs, udf, ufs, umsdos, vfat, xenix, xfs, and possibly others. For more details, see mount(8). For the filesystems currently supported by the running kernel, see /proc/filesystems. An entry swap denotes a file or partition to be used for swapping, cf. swapon(8). An entry ignore causes the line to be ignored. This is useful to show disk partitions which are currently unused. An entry none is useful for bind or move mounts.

第四列:parameters:文件系统的参数

 The fourth field, (fs_mntops), describes the mount options associated with the filesystem.

参数 用途说明
auto 在启动时或键入了mount -a命令时,自动挂载
noauto 只在命令下被挂载
exec 允许执行此分区的二进制文件
noexec 不允许执行此文件系统上的二进制文件
ro 以只读模式挂载文件系统
rw 以读写模式挂载文件系统
user 允许任意用户挂载此文件系统,若无显示定义,隐含启用noexec、nosuid、nodev参数
users 允许所有users组中的用户挂载此文件系统
nouser 只能被root挂载
owner 允许设备所有者挂载
sync I/0同步进行
async I/O异步进行
dev 不解析文件系统上的块特殊设备
suid 允许suid操作和设定sgid位,这一参数通常用于一些reshuffle任务,使一般用户运行程序时提升权限
nosuid 禁止suid操作和设定sgid位
noatime 不更新文件系统上的inode访问记录,可以提升性能
nodiratime 不更新文件系统上的目录的inode访问记录
relatime 实时更新inode access记录,只有在记录中的访问时间早于当前访问才会被更新(与noatime相似,但不会打断如mutt或其它程序探测文件在上次访问后是否被修改的进程)
flush - vfat的选项 频繁的刷新数据,复制对话框或进度条在全部数据都写入后才消失
defaults 使用文件系统的默认挂载参数,例如:ext4的默认参数为:rw,suid,dev,exec,auto,nouser,async

第五列:能否被dump备份命令作用:dump是一个用来作为备份的命令,通常这个参数的值为0或1

  The fifth field, (fs_freq), is used for these filesystems by the dump(8) command to determine which filesystems need to be dumped. If the fifth field is not present, a value of zero is returned and dump will assume that the filesystem does not need to be dumped.

数值 说明
0 代表不要做dump备份
1 代表要每天进行dump的操作
2 代表不定日期的进行dump操作

第六列:是否检验扇区:开机的过程中,系统默认会以fsck检验我们系统是否为完整(clean)

   The sixth field, (fs_passno), is used by the fsck(8) program to determine the order in which filesystem checks are done at reboot time. The root filesystem should be specified with a fs_passno of 1, and other filesystems should have a fs_passno of 2. Filesystems within a drive will be checked sequentially, but filesystems on different drives will be checked at the same time to utilize parallelism available in the hardware. If the sixth field is not present or zero, a value of zero is returned and fsck will assume that the filesystem does not need to be checked.

数值 说明
0 不要检验
1 最早检验(一般根目录会选择)
2 1级别检验完成之后进行检验

Linux /etc/fstab文件的更多相关文章

  1. linux之fstab文件详解

    /etc/fstab是用来存放文件系统的静态信息的文件.位于/etc/目录下,可以用命令less /etc/fstab 来查看,如果要修改的话,则用命令 vi /etc/fstab 来修改. 当系统启 ...

  2. linux /etc/fstab 文件详细说明(整理版)

    转至:https://blog.csdn.net/xiaolongwang2010/article/details/8657332?utm_medium=distribute.pc_relevant. ...

  3. linux中/etc/fstab文件删除或修改了,导致系统无法启动

    在linux中,/etc/fstab文件是磁盘挂载的问题,若该文件不小心给修改了,或者被删除了,那么就会导致系统无法重启.因为/etc/fstab文件是记录磁盘挂载的信息,若该文件出现了问题,那么对应 ...

  4. /etc/fstab文件出错,无法进入Linux系统

    问题描述 今天复习Linux文件系统管理,在Linux系统上挂载了一块新硬盘之后,然后分区,格式化,一步步走下来,为了能够使该硬盘在系统启动时自动挂载,于是将之写入了/etc/fstab文件,然而在r ...

  5. Linux学习之分区自动挂载与fstab文件修复(九)

    linux分区自动挂载与fstab文件修复 在前面我们实现新添加硬盘,进行分区与格式化,然后手动挂载,这样做,在重启后,需要重新挂载才能使用. https://www.cnblogs.com/-wen ...

  6. Linux系统下的 /etc/fstab 文件解读

    1 [root@localhost ~]# cat /etc/fstab 2 3 # 4 # /etc/fstab 5 # Created by anaconda on Sat Nov 3 12:03 ...

  7. Linux操作系统启动故障排错之"/etc/fstab"文件被删除恢复案例

    Linux操作系统启动故障排错之"/etc/fstab"文件被删除恢复案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.模拟故障 [root@yinzhe ...

  8. linux系统开机自动挂载光驱 和 fstab文件详解

    Linux 通过 UUID 在 fstab 中自动挂载分区 summerm6关注 2019.10.17 16:29:00字数 1,542阅读 607 https://xiexianbin.cn/lin ...

  9. Linux之/etc/fstab文件讲解

    /etc/fstab是用来存放文件系统的静态信息的文件.位于/etc/目录下,可以用命令less /etc/fstab 来查看,如果要修改的话,则用命令 vi /etc/fstab 来修改.当系统启动 ...

随机推荐

  1. postgresql客户端连接错误的解决方法【转】

    今天在重新设置postgresql服务器以后却发现启动不了服务器.错误如下:psql: could not connect to server: No such file or directory   ...

  2. spring boot快速入门 7: 使用aop处理请求

    样例:登陆拦截(aop简单样例) 第一步:在pom 文件中加入aop依赖 <!-- spring aop --> <dependency> <groupId>org ...

  3. centos安装图形操作界面

    yum groupinstall "GNOME Desktop" "Graphical Administration Tools"

  4. css3记事

    1.文字超出省略 text-overflow: ellipsis white-space: nowrap; overflow: hidden; text-overflow: ellipsis; *父元 ...

  5. Linux C笔记

    <Linux C编程一站式学习>笔记 gcc编译 直接编译 gcc main.c a.out 指定可执行文件名 gcc main.c -o main main 提示所有的警告信息 gcc ...

  6. sizeof数组名和字符指针是有区别的

    sizeof数组名和字符指针是有区别的. #include <stdio.h> #include <stdlib.h> void change(char url[]); int ...

  7. 【WAN】PPPOE宽带上网功能详解

    1.mac地址克隆 某些地方的运营商会把宽带账号和用户电脑的mac地址绑定起来,运营商的账号只能让当前的电脑去上网,限制路由器上网,这时候路由器可以复制用户电脑的mac伪装成这台电脑去上网,实现路由器 ...

  8. python爬虫实战(九)--------拉勾网全站职位(CrawlSpider)

    相关代码已经修改调试成功----2017-4-24 详情代码请移步我的github:https://github.com/pujinxiao/Lagou_spider 一.说明 1.目标网址:拉勾网 ...

  9. asp.netCore连接多个数据库

    1.首先要有对应的context实体类, 多个实体类的构造函数的参数都应该是集合 public class firstContext : DbContext { //多个数据库应该使用这个构造函数,参 ...

  10. mysql分表,批量生成数据

    一.mysql的分表策略 根据经验,Mysql表数据一般达到百万级别,查询效率会很低,容易造成表锁,甚至堆积很多连接,直接挂掉: 1,水平分割: 水平(横向)拆分:将同一个表的数据进行分块保存到不同的 ...