歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> Linuxfstab參數詳解

Linuxfstab參數詳解

日期:2017/3/1 13:51:09   编辑:關於Linux

[root@qs-wg-db1 /]# cat /etc/fstab

LABEL=/ / ext3 defaults 1 1

LABEL=/boot /boot ext3 defaults 1 2

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

LABEL=SWAP-sda2 swap swap defaults 0 0

/dev/sda1 /u01 ext3 defaults 0 0

[root@qs-wg-db1 /]# man fstab

FSTAB(5) Linux Programmer's Manual FSTAB(5)

NAME

fstab - static information about the filesystems

SYNOPSIS

#include <fstab.h>

DESCRIPTION

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. The order of records in fstab is important(fatab中記錄的順序很重要) because fsck(8), mount(8), and umount(8) sequentially iterate through fstab doing their thing.

The first field(第一個字段), (fs_spec), 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 (ext2 or xfs) filesystem that is to be mounted by its UUID or volume 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'. This will make the system more robust: adding or removing a SCSI disk changes the disk device name but not the filesystem volume label.

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'.

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.

The fourth field, (fs_mntops)(第四個字段), 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 options for non-nfs file systems, see mount(8). For documentation on all nfs-specific options have a look at nfs(5). Common for all types of file system are the options ''noauto'' (do not mount when "mount -a" is given, e.g., at boot time), ''user'' (allow a user to mount), ''owner'' (allow device owner to mount), ''pamconsole'' (allow a user at the console to mount), and ''comment'' (e.g., for use by fstab-maintaining programs). The ''owner'', ''pamconsole'' and ''comment'' options are Linux-specific. For more details, see mount(8).

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)

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, 該硬件在重啟時fsck將不檢查)

The proper way to read records from fstab is to use the routines getmntent(3).

FILES

/etc/fstab

SEE ALSO

getmntent(3), mount(8), swapon(8), fs(5), nfs(5)

HISTORY

The ancestor of this fstab file format appeared in 4.0BSD.

網上找到一份中文版的:

fs_spec fs_file fs_type fs_options fs_dump fs_pass 

/dev/hda1 /   ext2  defaults    1    1 

(1)fs_spec: 該字段定義希望加載的文件系統所在的設備或遠程文件系統,對於一般的本地塊設備情況來說:IDE設備一般描述為 /dev/hdaXN,X是IDE 設備通道(a, b, or c),N代表分區號;SCSI設備一描述為/dev/sdaXN。對於NFS情況,格式一般為:,例如: `knuth.aeb.nl:/'。對於procfs,使用`proc'來定義。 對文件系統的定義(fs spec),它描述了將被裝載的塊設備或遠程文件系統。對於通常的mount操作而言,這個字段應該包括一個將被裝載的塊設備的設備結點(通過mknod 命令來創建)或指向這類結點的連接(例如/dev/cdrom或/dev/sdb),對於NFS mount操作,這個字段應該包含host:dir格式的信息,例如:knuth.aeb.nl:/,對於進程文件系統procfs,使用proc。

除了顯示的使用設備名,你可以使用設備的UUID或設備的卷標簽,例如,你可以在這個字段寫成“LABAL=root”或“UUID=3e6be9de -8139-11d1-9106-a43f08d823a6”,這將使系統更具伸縮性。例如,如果你的系統添加或移除了一個SCSI硬盤,這有可以改變你的設備名,但它不會修改你的卷標簽。

(2)fs_file: 該字段描述希望的文件系統加載的目錄點,對於swap設備,該字段為none;對於加載目錄名包含空格的情況,用40來表示空格。描述文件系統的載入點,對於交換分區(swap),這個字段定義為none,如果在載入點的路徑中包含空格符,可以用“/040”來替代空格符。

(3)fs_type: 定義了該設備上的文件系統,一般常見的文件類型為ext2 (Linux設備的常用文件類型)、vfat(Windows系統的fat32格式)、NTFS、iso9600等.文件系統類型(fs vfstype),主要用來定義文件系統的類型。Linux系統支持大量的文件類型,包括sdfs,affs,autofs,jfs,minix, msdos, ncpfs, nfs, ntfs, proc, qnx4, reiserfs, romfs,,smbfs, sysv, tmpfs, udf, ufs, umsdos, vfat, xenix, xfs等等。如果想了解你的kernel目前支持哪些文件系統,可以查看/proc/filesystems的內容。如果這個字段定義為swap,這條紀錄將關聯到一個用於交換目的的文件或分區。如果這個字段定義為ignored,這行將被忽略。這對於顯示目前沒有使用的分區非常有用。

(4)fs_options: 指定加載該設備的文件系統是需要使用的特定參數選項,多個參數是由逗號分隔開來。文件系統選項(fs mntops)在裝載文件系統時使用的裝載選項。多個選項之間用逗號做分隔符,這些選項列表包括了裝載類型以及對於該文件系統合適的其它裝載選項。對於非 NFS系統可用的裝載選項可以參看mount命令的說明,對於nfs系統的選項可以查看關於nfs的文檔。對於所有文件系統都適用的選項有noauto (當使用mount –a命令時不載入),user(允許用戶進行裝載),owner(允許設備所有人裝載),_netdev(設備需要網絡),後兩個選項是linux系統所特有的。

對於大多數系統使用"defaults"就可以滿足需要。其他常見的選項包括:

選項              含義

ro    以只讀模式加載該文件系統

sync   不對該設備的寫操作進行緩沖處理,這可以防止在非正常關機時情況下破壞文件系統,但是卻降低了計算機速度

user   允許普通用戶加載該文件系統

quota   強制在該文件系統上進行磁盤定額限制

noauto  不再使用mount -a命令(例如系統啟動時)加載該文件系統

(5)fs_dump: 該選項被"dump"命令使用來檢查一個文件系統應該以多快頻率進行轉儲,若不需要轉儲就設置該字段為0.文件系統頻率(fs_freq),被dump程序使用來確定哪個文件系統需要dump,如果最後一個字段沒有設置,系統將認為其值為0,而dump程序則認為此文件系統無需dump。

(6)fs_pass:  該字段被fsck命令用來決定在啟動時需要被掃描的文件系統的順序,根文件系統"/"對應該字段的值應該為1,其他文件系統應該為2。若該文件系統無需在啟動時掃描則設置該字段為0.被fsck程序所使用來確定進行在系統重啟進行文件系統檢查時的順序,對於根系統/這個值應設為1,其它文件系統可以設為2,在同一個物理硬盤內的文件系統應該被順序檢測,而不同硬盤中的文件系統則應該同時檢測以充分利用系統的並行性。如果最後一個字段值為0或沒有設置,fsck程序裝跳過此文件系統的檢測。

在linux編程中可以用getmntent過程來訪問這個文件的內容。

Copyright © Linux教程網 All Rights Reserved