linux中fstab文件配置简介

1、fstab文件的作用
文件/etc/fstab存放的是系统中的文件系统信息。当正确的设置了该文件,则可以通过"mount  /directory      name"命令来加载一个文件系统,每种文件系统都对应一个独立的行,每行中的字段都有空格或tab键分开。同时fsck、 mount、umount的等命令都利用该程序。

2、下面是/etc/fatab文件的一个示例行:  cat /proc/mounts
fs_spec          fs_file            fs_type fs_options fs_dump fs_pass 

/dev/sda2               /                       ext4    defaults         1 1

/dev/sda1               /boot                   ext4    defaults        1 2

/dev/sda5               /home                   ext4    defaults        1 2

/dev/sda3               swap                    swap    defaults        0 0

tmpfs                   /dev/shm                tmpfs   defaults        0 0

fs_spec - 

              This field describes the block special device or remote
              filesystem to be mounted.

              For ordinary mounts it will hold (a link to) a block special
              device node (as created by mknod(8)) for the device to be
              mounted, like `/dev/cdrom‘ or `/dev/sdb7‘.  For NFS mounts one
              will have <host>:<dir>, e.g., `knuth.aeb.nl:/‘.  For procfs,
              use `proc‘.

              Instead of giving the device explicitly, one may indicate the
              filesystem that is to be mounted by its UUID or LABEL (cf.                        
              e2label(8) or xfs_admin(8)), writing LABEL=<label> or
              UUID=<uuid>, e.g., `LABEL=Boot‘ or `UUID=3e6be9de-8139-11d1‐
              -9106-a43f08d823a6‘.

              It‘s also possible to use PARTUUID= and PARTLABEL=. These
              partitions identifiers are supported for example for GUID
              Partition Table (GPT).

              See mount(8), blkid(8) or lsblk(8) for more details about
              devices identifiers.

              Note that mount(8) uses UUIDs as strings. The string
              representation of the UUID should be based on lower case
              characters.

fs_file - 

              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‘

fs_type - 

              This field describes the type of the filesystem.  Linux
              supports lots of filesystem types, the most common are ext2,
              ext3, ext4, xfs, btrfs, vfat, sysfs, proc, nfs and cifs. For
              more details, see mount(8).

              An entry swap denotes a file or partition to be used for
              swapping, cf. swapon(8).  An entry none is useful for bind or
              move mounts.

              More than one type may be specified in a comma-separated list.                                      mount(8) and umount(8) support filesystem subtypes.  The
              subtype is defined by ‘.subtype‘ suffix.  For example
              ‘fuse.sshfs‘. It‘s recommended to use subtype notation rather
              than add any prefix to the first fstab field (for example
              ‘sshfs#example.com‘ is deprecated).

查看系统支持的文件系统命令:ls   /lib/modules/`uname -r`/kernel/fs/  
fs_options - 

              This field describes the mount options associated with the
              filesystem.

              It is formatted as a comma separated list of options.  It
              contains at least the type of mount plus any additional
              options appropriate to the filesystem type. For documentation
              on the available mount options, see mount(8).  For
              documentation on the available swap options, see swapon(8).
    • 推荐参数
   noatime   关闭atime特性,提高性能,这是一个很老的特性,放心关闭,还能减少loadcycle
    • 默认设置
   defaults  使用默认设置。等于rw,suid,dev,exec,auto,nouser,async,具体含义看下面的解释。
    • 自动与手动挂载
   auto  在启动或在终端中输入mount -a时自动挂载
   noauto  设备(分区)只能手动挂载 The file system can be mounted only explicitly.
    • IO编码设置
   iocharset=   在=号后面加入你的本地编码,似乎在这个设备(分区)中做文件IO的时候就会自动做编
   码的格式转换。
   例如:你的某个分区是编码是utf8,而设备中文件的编码是gb2312,当是复制你设备中的文件到你的这
   个分区时,它将自动做编码转换。  
   
   (不知道我的理解对不对,但是好像用下面的nls就可以实现转换。)
    • 中文乱码的解决
   nls=     在=号后面加入你的本地编码,你的中文就不会出现乱码。
    • 读写权限
   umask=   这是关于读写权限的,好像比下面的ro,rw选项更管用!!!
   例如:umask=000或0222,使得挂载时option中有default,普通用户仍然能读写挂载设备中的东西。
               
   请大家补充!!!

   ro  挂载为只读权限
   rw   挂载为读写权限
    • 可执行
   exec     是一个默认设置项,它使在那个分区中的可执行的二进制文件能够执行。
   noexec  二进制文件不允许执行。千万不要在你的root分区中用这个选项!!!
    • I/O同步
   sync	  所有的I/O将以同步方式进行
   async  所有的I/O将以非同步方式进行
    • 用户挂载权限
   user  允许任何用户挂载设备。 Implies noexec,nosuid,nodev unless overridden.
   nouser  只允许root用户挂载。这是默认设置。
       suid     Permit 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   Blocks the operation of suid, and sgid bits.

    fs_dump - 

                  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

    fs_pass - 

                  This field 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
    时间: 2024-08-11 00:30:36

    linux中fstab文件配置简介的相关文章

    Linux中fstab文件的配置和理解

    下面是我机子上的fstab文件: LABEL=/                 /                       ext3    defaults        1 1 LABEL=/boot1            /boot                   ext3    defaults        1 2 tmpfs                   /dev/shm                tmpfs   defaults        0 0 devpt

    Linux中fstab文件的理解

    fstab(/etc/fstab)是Linux下比较重要的配置文件,它包含了系统在启动时挂载文件系统和存储设备的详细信息. # # /etc/fstab # Created by anaconda on Sat Nov 22 02:14:55 2014 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) an

    linux中的strings命令简介

    摘自:http://blog.csdn.net/stpeace/article/details/46641069 linux中的strings命令简介 在linux下搞软件开发的朋友, 几乎没有不知道strings命令的.我们先用man strings来看看: strings - print the strings of printable characters in files. 意思是, 打印文件中可打印的字符.  我来补充一下吧, 这个文件可以是文本文件(test.c), 可执行文件(te

    linux中的strings命令简介2

    摘自:http://blog.csdn.net/stpeace/article/details/46641069 linux中的strings命令简介 之前我们聊过linux strings的用法和用途, 但据我了解, 还有部分朋友并不常用strings, 这是个不好的习惯. 所以, 本文继续啰嗦一下strings命令. 在软件开发中, 我们经常需要修改代码, 并生成静态库.动态库或者可执行文件, 有时候, 工程太大, 那怎样确定自己改动的代码正确编译到库中去了呢? 用strings命令吧!  

    【转】linux中inittab文件详解

    原文网址:http://www.2cto.com/os/201108/98426.html linux中inittab文件详解 init的进程号是1(ps -aux | less),从这一点就能看出,init进程是系统所有进程的起点,Linux在完成核内引导以后,就开始运行init程序. init程序需要读取配置文件/etc/inittab.inittab是一个不可执行的文本文件,它有若干行指令所组成. 理解Runlevel: runlevel用来表示在init进程结束之后的系统状态,在系统的硬

    linux中对文件的权限设置以及作用

    一.通过权限的设置达到目录共享 在linux中通过对文件的权限设置可以充分对文件的 owner进行内容保护,也可以把内容分享给想要分享的用户.下面举例说明:1.首先在root权限下创建一个组,三个用户,将三个用户全部添加到同一组里groupadd gongxiang(创建一个组为gongxiang的组)useradd -G gongxiang zhangsan(创建一个用户zhangsan加入附属组gongxiang)useradd -G gongxiang zhangsi(创建一个用户zhan

    Linux中删除文件,磁盘空间未释放问题追踪

    在客户使用我们产品后,发现一个问题:在删除了文件后,磁盘空间却没有释放.是有进程在打开这个文件,还是其他情况?我们一起来看看一下两个场景 一. 场景一:进程打开此文件 当一个文件正在被一个进程使用时,用户删除此文件,文件只会从目录结构中删除,但并没有从磁盘删除.当使用这个文件的进程结束后,文件才会真正的从磁盘删除,释放占有的空间. 我们发现剩余磁盘空间比较少时,回去删除一些大的临时文件或者log文件,如果删除之后会发现磁盘空间并未减少,那么可以通过"lsof"命令去查看正在使用该文件的

    5 个在 Linux 中管理文件类型和系统时间的有用命令

    对于想学习 Linux 的初学者来说要适应使用命令行或者终端可能非常困难.由于终端比图形用户界面程序更能帮助用户控制 Linux 系统,我们必须习惯在终端中运行命令.因此为了有效记忆 Linux 不同的命令,你应该每天使用终端并明白怎样将命令和不同选项以及参数一同使用. 在 Linux 中管理文件类型和设置时间 请先查看我们 Linux 小技巧系列之前的文章: 5 个有趣的 Linux 命令行技巧 给新手的 10 个有用 Linux 命令行技巧 在这篇文章中,我们打算看看终端中 5 个和文件以及

    linux中Makefile文件相关内容

    第一章.概述什么是makefile?或许很多Winodws的程序员都不知道这个东西,因为那些Windows的IDE都为你做了这个工作,但我觉得要作一个好的和professional(专业)的程序员,makefile还是要懂.这就好像现在有这么多的HTML的编辑器,但如果你想成为一个专业人士,你还是要了解HTML的标识的含义.特别在Unix下的软件编译,你就不能不自己写makefile了,会不会写makefile,从一个侧面说明了一个人是否具备完成大型工程的能力.因为,makefile关系到了整个