linux fstab 权限,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 :

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= or

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值