Linux
01.系统维护
CPU
内存
drop_cache为什么有些不释放
swap交换分区
磁盘
lvm磁盘扩容
文件夹加密ecryptfs-utils
linux挂载ISCSI磁盘
创建lvm
fstab挂载文件系统
systemd.mount
存储故障
曲线为目录配置限额
lvm缩容
进程
如何找到某一个正在运行的进程?
CRIU进程快照
网络
TCP连接的10种状态
Ubuntu禁用ipv6
close_wait数量过多阻塞网络连接
IP地址与二进制转换
支持ACME的DNS服务器PowerDNS
系统
CentOS版本及对应默认内核版本
修改shell语言
系统启动流程
cgroup
CentOS7升级内核并开启BBR
配置内核参数优化linux
更新grub2默认启动的内核
CentOS-SCLo源
修改键盘映射
Debian12升级时内核编译错误
timesync(ntp)
内核
drop_caches
软件
更新openssl
GUI
Gnome Workspace Names
02.系统安全
Auditd审计服务配置
ssh登陆免公钥验证
恶意脚本处置
2023挖矿脚本m0nad
为ssh服务添加多因子认证
03.基本概念
Out Of Memory
70.QEMU
磁盘格式转换
80.LFS
90.常用脚本
使用except修改操作系统密码
init.d脚本模板
shell脚本判断参数数量
安装oh-my-zsh
systemd脚本模板
端口测试
适用于truenas的ipv6阿里云ddns脚本
更新nginx白名单
将文件改名为md5值
djvu转换为pdf并ocr
99.常用命令
man page中命令后的数字释义
tcpdump
nslookup
nc
rsync
awk
sed
echo
rm
tar
chage
auditctl
ausearch
ab
openssl
parted
find
date
firewall-cmd
sort
vmstat
nice-调整进程的优先级
top
taskset-进程绑定CPU核心
iptables
iostat
sysctl
tr
rpmbuild
转载nginx.spec含说明
安装使用rpmbuild
unpacked files found
grep
vimtutor
tlinux - tos
snmpwalk
chattr
本文档使用 MrDoc 发布
-
+
首页
fstab挂载文件系统
# fstab文件挂载文件系统 ## 说明 > The file fstab contains descriptive information about the various file systems. fstab is only read by programs, and not written; it is the duty of the system administrator to properly create and maintain this file. Each filesystem is described on a separate line; fields on each line are separated by tabs or spaces. Lines starting with '#' are comments, blank lines are ignored. The order of records in fstab is important because fsck(8), mount(8), and umount(8) sequentially iterate through fstab doing their thing. fstab文件中包含了不通文件系统的描述信息,fstab只会被程序读取,且不会被修改;创建与维护fstab文件是系统管理员的职责。 每一个文件系统都通过不同的行被描述;每一行的不同字段都通过缩进符号或空格来分割。以“#”开头的行为注释行,空行会被忽略。 fstab文件中的顺序非常重要,因为fsck,mount和umount都会按顺序迭代fstab中的记录执行。 ## 示例 - 系统信息 ``` root@pi:~# blkid /dev/sda1 /dev/sda1: LABEL_FATBOOT="boot" LABEL="boot" UUID="54E3-79CE" TYPE="vfat" PARTUUID="46662cd6-01" ``` - 通过PARTUUID挂载块设备 ``` PARTUUID=46662cd6-01 /boot vfat defaults 0 2 ``` - 通过UUID挂载块设备 ``` UUID=54E3-79CE /boot vfat defaults 0 2 ``` - 通过LABEL挂载块设备 ``` LABEL=boot /boot vfat defaults 0 2 ``` - 挂载网络文件系统(nfs) - 必须在第四列加入`_netdev`选项,否则可能会挂载失败 - 添加`nofail`避免挂在失败后无法启动系统,有些必须要挂载成功才能启动业务的应用不建议添加,应该先处理挂载问题。 ``` 192.168.1.1:/nfs /opt/nfs nfs default,_netdev,noatime,nofail 0 0 ``` - 挂载windows共享cifs - 与nfs类似,在第四列加入`_netdev,nofail`选项 ``` //192.168.124.201/video /mnt/videos/ cifs user=username,pass=password,dom=Workgroup,ver=1.0,uid=0,gid=0,_netdev,nofail ``` - 也可以将用户名密码保存到一个root用户只读的文件,然后: ``` # cat /path/to/file user=username pass=password dom=Workgroup # cat /etc/fstab //192.168.124.201/video /mnt/videos/ cifs credentials=/path/to/file,uid=0,gid=0,_netdev ``` - 通过UUID挂载iscsi存储 - 与nfs类似,获取iscsi存储UUID后,再第四列加入`_netdev`选项 ``` UUID="57e98c4a-2c8d-49e9-ba33-c609791137c1" /data xfs defaults,_netdev,noatime,nodiratime 0 0 ``` - 直接挂载光盘设备 ``` /dev/sr0 /mnt/cdrom iso9660 ro,auto,nofail 0 0 ``` - 仅在访问/opt/mypic时挂载改文件系统,超过60s不访问则卸载文件系统 ``` /dev/sda3 /opt/mypic xfs noauto,x-systemd.automount,x-systemd.idle-timeout=60s 0 0 ``` ## 列定义 ### 第一列 > This field describes the block special device or remote filesystem to be mounted. 第一列描述了将要被挂载的块设备或远程文件系统 ### 第二列 > This field 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'. 这一列描述文件系统的挂载点信息,swap交换分区填写`none`。如果挂载点中包含空格,可以用`\040`来代替空格 ### 第三列 > This field describes the type of the filesystem. 这一列描述文件系统的类型,Linux支持多种文件系统类型如: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等等。 更多信息可以查看管理员命令mount(8)。 查看当前支持的文件系统类型可以通过`cat /proc/filesystems`来查询 ### 第四列 > This field describes the mount options associated with the filesystem. 第四列描述了挂载文件系统时的相关选项,如: - defaults:默认选项,包含了rw, suid, dev, exec, auto, nouser, 和 async. - rw:以读写方式挂载文件系统 - suid:允许操作、设定suid和sgid特殊权限位 - dev:允许文件系统使用的解释字符或块设备 - exec:允许可执行权限x生效 - auto:使用"mount -a"时自动挂载 - nouser:不允许用户挂载 - async:以异步方式执行所有文件系统的I/O操作 - `noauto`:当使用了"mount -a"时不自动挂载(如:在启动过程中不自动挂载)。可以配合`x-systemd.automount`使用,将挂载点配置为被访问时才挂载,否则不挂载,以降低系统启动时间 - user:允许非root用户挂载,隐含启用 noexec, nosuid, nodev 参数 - owner:允许设备的归属用户挂载 - comment或x-<name>:被fstab维护程序所使用 - nofail:如果这个设备不存在的话,不要报错。 - nodirtime:在文件夹被访问后,不修改文件夹的inode的数据,提升系统性能 - ro:以只读方式挂载 - **noatime:在文件被访问后,不修改文件的inode数据,提升系统性能,隐含"nodirtime"** - **_netdev:挂载设备来源于网络,用来防止网络没启动就开始挂载文件系统导致的启动失败。** - **x-mount.mkdir[=<mode>]:当挂载点不存在时,创建挂载点,且支持递归创建多级目录,默认权限(mode)为0755,仅对root用户生效。** - **x-systemd.idle-timeout:挂载点空闲一段时间后卸载,如:`x-systemd.idle-timeout=60s`、`x-systemd.idle-timeout="5min 30s"`** - **x-systemd.automount:systemd时代的挂载单元,centos7后引入;部分文件系统的挂载工作移交给了systemd.mount** - 如tmp的挂载 ```shell systemctl cat tmp.mount # /usr/lib/systemd/system/tmp.mount # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. [Unit] Description=Temporary Directory Documentation=man:hier(7) Documentation=http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems ConditionPathIsSymbolicLink=!/tmp DefaultDependencies=no Conflicts=umount.target Before=local-fs.target umount.target [Mount] What=tmpfs Where=/tmp Type=tmpfs Options=mode=1777,strictatime # Make 'systemctl enable tmp.mount' work: [Install] WantedBy=local-fs.target ``` [关于systemd.mount看这里。](https://wiki.ihoiwan.com:3003/project-2/doc-233/ "关于systemd.mount看这里。") ### 第五列 > This field 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值,也就是不备份,备份级别从0到9 ### 第六列 > This field is used by the fsck(8) program to determine the order in which filesystem checks are done at reboot time. 用来描述在重启后是否需要对该行的文件系统使用fsck进行检查工作,建议将根分区配置为1,其它分区配置为2,如果不配置或配置为0则认为不需要检查文件系统。
zhangky
2022年12月12日 15:10
分享文档
收藏文档
上一篇
下一篇
微信扫一扫
复制链接
手机扫一扫进行分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码