fsck 中文man页面

系统
fsck 通常用来检查并适当修复一个或多个Linux文件系统. filesys 可以是一个设备名(例如: /dev/hdc1, /dev/sdb2), 一个挂载点(例如: /, /usr, /home), 或一个ext2文件系统的磁盘标签, 也可以是UUID指定符(例如: UUID=8868abf6-88c5-4a83-98b8-bfc24057f7bd 或 LABEL=root). 通常, fsck 会试着以并行的方式同时在不同的物理磁盘上运行文件系统检查,这样可以减少对所有文件系统进行检查的时间。

NAME

fsck - 检查并修复Linux文件系统  

总览 SYNOPSIS

fsck [ -sACVRTNP ] [ -t fstype ] [filesys ... ] [--] [ fs-specific-options ]  

描述 DESCRIPTION

fsck 通常用来检查并适当修复一个或多个Linux文件系统. filesys 可以是一个设备名(例如: /dev/hdc1, /dev/sdb2), 一个挂载点(例如: /, /usr, /home), 或一个ext2文件系统的磁盘标签, 也可以是UUID指定符(例如: UUID=8868abf6-88c5-4a83-98b8-bfc24057f7bd 或 LABEL=root). 通常, fsck 会试着以并行的方式同时在不同的物理磁盘上运行文件系统检查,这样可以减少对所有文件系统进行检查的时间。

如果没有在命令行指定文件系统,并且没有指定 -A 选项, fsck 将默认顺序地检查 /etc/fstab 中登记的文件系统。这和使用 -As 选项是相同的。

fsck 退出的返回值是下列情况之和:
0 - 没有错误
1 - 文件系统有错但已修复
2 - 系统应当重启
4 - 文件系统错误没有修复
8 - 运行错误
16 - 用法或语法错误
32 - 用户撤销了fsck 操作
128 - 共享库出错
当检测多个文件系统时,退出的返回值是对每个文件系统检查的返回值按位或的结果。

实际上, fsck 只是Linux 中不同的文件系统检查器(fsck.fstype)的一个前端。首先,它在 /sbin 中搜索特定文件系统的检查器,然后在 /etc/fs/etc 中搜索,最后在 PATH 环境变量中列出的路径中搜索。请查看特定文件系统的检查器的手册页来获取细节信息。  

选项 OPTIONS

-s
顺序地进行 fsck 操作。如果你要检查多个文件系统,并且检查器运行在交互模式,这样作比较有好处。(注意: e2fsck(8) 默认是以交互方式运行的。要使 e2fsck(8) 以非交互方式运行,你必须指定 -p-a 选项,如果你想要自动纠正错误,或 -n 选项,如果不想自动纠正错误。)
-t fslist
指定要检查的文件系统的类型。当指定了 -A 标志时,只有 fslist 中列出的类型的文件系统会被检查。 fslist 参数是一个以逗号分隔的文件系统类型列表以及选项说明符。可以在这个以逗号分隔的列表的所有文件系统前面加上否定前缀 'no' 或 '!' 来使得只有没有列在 fslist 中的文件系统将被检查。如果并非 fslist 中列出的所有文件系统都加上了否定前缀,那么只有 fslist 中列出的文件系统将被检查。

选项说明符也可能包含在这个以逗号分隔的列表 fslist 中。它们的格式是 opts=fs-option 。如果出现了选项说明符,那么只有在 /etc/fstab 中它们的挂载选项字段中不包含 fs-option 的文件系统将被检查。如果选项说明符有否定前缀,那么只有在 /etc/fstab 中它们的挂载选项字段中包含 fs-option 的文件系统将被检查。

例如,如果 fslist 中出现了 opts=ro 那么只有 /etc/fstab 中,挂载选项包含 ro 的文件系统将被检查。

为了和Mandrake 发行版兼容(它的启动脚本依赖于一个未经许可而对 fsck 程序用户接口作出的改变),如果 fslist 中有一个 loop 文件系统,它被视为指定了 opts=loop 作为 -t 选项的参数。

一般地,文件系统类型是在 /etc/fstab 中通过搜索与 filesys 相应的条目得到的。如果不能这样推知类型,并且 -t 选项只有一个文件系统参数, fsck 将使用指定的文件系统类型。如果不能使用这种类型,将使用默认的文件系统类型(当前是ext2)。

-A
搜索 /etc/fstab 文件,一次检查所有在文件中有定义的文件系统。这个选项典型地用在 /etc/rc 系统初始化文件中,而不使用多条命令来分别检查各独立的分区。

如果没有使用 -P 选项,则根文件系统将第一个被检查。之后,将按 /etc/fstab 文件中第六字段 fs_passno 指定的顺序对各文件系统进行检查。 fs_passno 值为0 的文件系统将被跳过,不会被检查。 fs_passno 值大于0 的文件系统将被按顺序检查, fs_passno 值最小的文件系统将被最先检查。 如果多个文件系统有相同的pass号,fsck将试着并行处理这些文件系统,尽管它不允许在同一个物理磁盘上同时运行多个文件系统检查程序。

因此, /etc/fstab 文件中的一个很普遍的设置是将root文件系统的 fs_passno 设为1,定义其它文件系统的 fs_passno 为2。这样就充许 fsck 程序自动以并行的方式运行文件系统检查, 如果这样有好处的话。系统管理员可能会出于某些原因而不希望并行运行多个文件系统检查--例如,如果内存不够,那么过多的换页会成为系统瓶颈。

-C
如果文件系统检查器支持的话(当前只有ext2),显示进度条。fsck 将管理各文件系统检查器,使得同一时间它们中只能有一个可以显示进度条。
-N
不执行,仅仅显示将执行的操作。
-P
当设置了 -A 标志时,将并行检查root文件系统和其他文件系统。这样是世界上最不安全的做法,因为如果root文件系统有问题, e2fsck(8) 这样的程序可执行文件将被破坏!这个选项是为不想把root 文件系统分得小而紧凑(这才是正确的做法)的系统管理员准备的。
-R
当使用 -A 标志来检查所有文件系统时,跳过root文件系统 (它可能已经被挂载为可读写)。
-T
启动时不显示标题。
-V
产生冗余输出,包含所有被执行的特定文件系统的命令。
fs-specific-options
fsck 不理解的选项被传递给特定文件系统的检查器。这些选项 决不能 有参数,因为 fsck 不能判断出哪个选项有参数,那些没有。
-- 引导的选项和参数将被当作特定文件系统的选项传给它的检查器。
注意 fsck 没有为传递任意复杂的选项给特定文件系统的检查器而专门设计。如果你要做复杂的操作,请直接执行特定文件系统的检查器。如果你传给 fsck 极其复杂的选项和参数,它没有按照你想要的那样工作, 不要把它报告为一个bug! You're almost certainly doing something that you shouldn't be doing with fsck.

当前,标准的特定文件系统的选项仍在改进之中。尽管不能保证,还是有下列这些选项可以被大部分文件系统检查器所支持。

-a
不提问,自动修复文件系统(请小心使用此选项)。注意 e2fsck(8) 支持 -a 仅仅是为了向前兼容。这个选项被映射到 e2fsck-p 选项,那比较安全一点,不像大多数文件系统检查器支持的 -a 那样。
-r
交互式地修复文件系统错误(询问确认)。注意: 如果多个 fsck 在并行执行,这不是一个好想法。还要注意 e2fsck 的默认行为;它也只为了向前兼容才保留这个选项。

作者 AUTHOR

Theodore Ts'o (tytso@mit.edu)  

文件 FILES

/etc/fstab  

环境变量 ENVIRONMENT VARIABLES

fsck 程序的行为受下列环境变量影响:

FSCK_FORCE_ALL_PARALLEL
如果设置了这个环境变量, fsck 将试着并行运行所有指定的文件系统检查,不管这些文件系统是不是在同一设备上。(这对于RAID系统或者高端存储系统比如IBM或者EMC出售的那种很有用)
FSCK_MAX_INST
这个环境变量将限制同时可以运行的文件系统检查器的最大数量。这样使得拥有大量磁盘的系统避免 fsck 一次启动过多文件系统检查器,那样有可能耗尽机器的CPU和内存资源。如果值为0,可以孵化出没有限制的数量的进程,这是当前的默认值。将来版本的 fsck 将试着根据收集操作系统的统计数据,自动判断应当启动多少文件系统检查。
PATH
PATH 环境变量用来查找文件系统检查器。一些系统目录会被最先搜索: /sbin, /sbin/fs.d, /sbin/fs, /etc/fs, 和 /etc. 然后才搜索 PATH 环境变量中设置的目录集合。
FSTAB_FILE
这个环境变量允许系统管理员指定 /etc/fstab 文件的位置。它也为 fsck 的开发者做测试之用。

参见 SEE ALSO

fstab(5), mkfs(8), fsck.minix(8), fsck.ext2(8) 或者 e2fsck(8), fsck.xiafs(8).

#p#

NAME

fsck - check and repair a Linux file system  

SYNOPSIS

fsck [ -sAVRTNP ] [ -C fd ] [ -t fstype ] [filesys ... ] [--] [ fs-specific-options ]  

DESCRIPTION

fsck is used to check and optionally repair one or more Linux file systems. filesys can be a device name (e.g. /dev/hdc1, /dev/sdb2), a mount point (e.g. /, /usr, /home), or an ext2 label or UUID specifier (e.g. UUID=8868abf6-88c5-4a83-98b8-bfc24057f7bd or LABEL=root). Normally, the fsck program will try to run filesystems on different physical disk drives in parallel to reduce total amount time to check all of the filesystems.

If no filesystems are specified on the command line, and the -A option is not specified, fsck will default to checking filesystems in /etc/fstab serial. This is equivalent to the -As options.

The exit code returned by fsck is the sum of the following conditions:
0 - No errors
1 - File system errors corrected
2 - System should be rebooted
4 - File system errors left uncorrected
8 - Operational error
16 - Usage or syntax error
32 - Fsck canceled by user request
128 - Shared library error
The exit code returned when multiple file systems are checked is the bit-wise OR of the exit codes for each file system that is checked.

In actuality, fsck is simply a front-end for the various file system checkers (fsck.fstype) available under Linux. The file system-specific checker is searched for in /sbin first, then in /etc/fs and /etc, and finally in the directories listed in the PATH environment variable. Please see the file system-specific checker manual pages for further details.  

OPTIONS

-s
Serialize fsck operations. This is a good idea if you are checking multiple filesystems and the checkers are in an interactive mode. (Note: e2fsck(8) runs in an interactive mode by default. To make e2fsck(8) run in a non-interactive mode, you must either specify the -p or -a option, if you wish for errors to be corrected automatically, or the -n option if you do not.)
-t fslist
Specifies the type(s) of file system to be checked. When the -A flag is specified, only filesystems that match fslist are checked. The fslist parameter is a comma-separated list of filesystems and options specifiers. All of the filesystems in this comma-separated list may be prefixed by a negation operator 'no' or '!', which requests that only those filesystems not listed in fslist will be checked. If all of the filesystems in fslist are not prefixed by a negation operator, then only those filesystems listed in fslist will be checked.

Options specifiers may be included in the comma separated fslist. They must have the format opts=fs-option. If an options specifier is present, then only filesystems which contain fs-option in their mount options field of /etc/fstab will be checked. If the options specifier is prefixed by a negation operator, then only those filesystems that do not have fs-option in their mount options field of /etc/fstab will be checked.

For example, if opts=ro appears in fslist, then only filesystems listed in /etc/fstab with the ro option will be checked.

For compatibility with Mandrake distributions whose boot scripts depend upon an unauthorized UI change to the fsck program, if a filesystem type of loop is found in fslist, it is treated as if opts=loop were specified as an argument to the -t option.

Normally, the filesystem type is deduced by searching for filesys in the /etc/fstab file and using the corresponding entry. If the type can not be deduced, and there is only a single filesystem given as an argument to the -t option, fsck will use the specified filesystem type. If this type is not available, then the default file system type (currently ext2) is used.

-A
Walk through the /etc/fstab file and try to check all file systems in one run. This option is typically used from the /etc/rc system initalization file, instead of multiple commands for checking a single file system.

The root filesystem will be checked first unless the -P option is specified (see below). After that, filesystems will be checked in the order specified by the fs_passno (the sixth) field in the /etc/fstab file. Filesystems with a fs_passno value of 0 are skipped and are not checked at all. Filesystems with a fs_passno value of greater than zero will be checked in order, with filesystems with the lowest fs_passno number being checked first. If there are multiple filesystems with the same pass number, fsck will attempt to check them in parallel, although it will avoid running multiple filesystem checks on the same physical disk.

Hence, a very common configuration in /etc/fstab files is to set the root filesystem to have a fs_passno value of 1 and to set all filesystems to have a fs_passno value of 2. This will allow fsck to automatically run filesystem checkers in parallel if it is advantageous to do so. System administrators might choose not to use this configuration if they need to avoid multiple filesystem checks running in parallel for some reason --- for example, if the machine in question is short on memory so that excessive paging is a concern.

-C fd
Display completion/progress bars to the specified file descriptor for those filesystems checkers (currently only for ext2 and ext3) which support them. Fsck will manage the filesystem checkers so that only one of them will display a progress bar at a time.
-N
Don't execute, just show what would be done.
-P
When the -A flag is set, check the root filesystem in parallel with the other filesystems. This is not the safest thing in the world to do, since if the root filesystem is in doubt things like the e2fsck(8) executable might be corrupted! This option is mainly provided for those sysadmins who don't want to repartition the root filesystem to be small and compact (which is really the right solution).
-R
When checking all file systems with the -A flag, skip the root file system (in case it's already mounted read-write).
-T
Don't show the title on startup.
-V
Produce verbose output, including all file system-specific commands that are executed.
fs-specific-options
Options which are not understood by fsck are passed to the filesystem-specific checker. These arguments must not take arguments, as there is no way for fsck to be able to properly guess which arguments take options and which don't.
Options and arguments which follow the -- are treated as file system-specific options to be passed to the file system-specific checker.
Please note that fsck is not designed to pass arbitrarily complicated options to filesystem-specific checkers. If you're doing something complicated, please just execute the filesystem-specific checker directly. If you pass fsck some horribly complicated option and arguments, and it doesn't do what you expect, don't bother reporting it as a bug. You're almost certainly doing something that you shouldn't be doing with fsck.

Options to different filesystem-specific fsck's are not standardized. If in doubt, please consult the man pages of the filesystem-specific checker. Although not guaranteed, the following options are supported by most file system checkers:

-a
Automatically repair the file system without any questions (use this option with caution). Note that e2fsck(8) supports -a for backwards compatibility only. This option is mapped to e2fsck's -p option which is safe to use, unlike the -a option that some file system checkers support.
-n
For some filesystem-specific checkers, the -n option will cause the fs-specific fsck to avoid attempting to repair any problems, but simply report such problems to stdout. This is however not true for all filesystem-specific checkers. In particular, fsck.reiserfs(8) will not report any corruption if given this option. fsck.minix(8) does not support the -n option at all.
-r
Interactively repair the filesystem (ask for confirmations). Note: It is generally a bad idea to use this option if multiple fsck's are being run in parallel. Also note that this is e2fsck's default behavior; it supports this option for backwards compatibility reasons only.
-y
For some filesystem-specific checkers, the -y option will cause the fs-specific fsck to always attempt to fix any detected filesystem corruption automatically. Sometimes an expert may be able to do better driving the fsck manually. Note that not all filesystem-specific checkers implement this option. In particular fsck.minix(8) and fsck.cramfs(8) does not support the -y option as of this writing.

AUTHOR

Theodore Ts'o (tytso@mit.edu)  

FILES

/etc/fstab.  

ENVIRONMENT VARIABLES

The fsck program's behavior is affected by the following environment variables:

FSCK_FORCE_ALL_PARALLEL
If this environment variable is set, fsck will attempt to run all of the specified filesystems in parallel, regardless of whether the filesystems appear to be on the same device. (This is useful for RAID systems or high-end storage systems such as those sold by companies such as IBM or EMC.)
FSCK_MAX_INST
This environment variable will limit the maximum number of file system checkers that can be running at one time. This allows configurations which have a large number of disks to avoid fsck starting too many file system checkers at once, which might overload CPU and memory resources available on the system. If this value is zero, then an unlimited number of processes can be spawned. This is currently the default, but future versions of fsck may attempt to automatically determine how many file system checks can be run based on gathering accounting data from the operating system.
PATH
The PATH environment variable is used to find file system checkers. A set of system directories are searched first: /sbin, /sbin/fs.d, /sbin/fs, /etc/fs, and /etc. Then the set of directories found in the PATH environment are searched.
FSTAB_FILE
This environment variable allows the system administrator to override the standard location of the /etc/fstab file. It is also use for developers who are testing fsck.

SEE ALSO

fstab(5), mkfs(8), fsck.ext2(8) or e2fsck(8), cramfsck(8) fsck.minix(8), fsck.jfs(8) fsck.xfs(8), fsck.xiafs(8) reiserfsck(8).

责任编辑:韩亚珊 来源: CMPP.net
相关推荐

2011-08-24 16:48:36

man中文man

2011-08-15 10:21:09

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-08-25 15:39:42

fcloseall中文man

2011-08-25 15:00:15

cfgetispeed中文man

2011-08-19 18:35:50

issue中文man

2011-08-25 17:03:51

pclose中文man

2011-08-25 17:40:25

setvbuf中文man

2011-08-23 14:21:16

poweroff中文man

2011-08-24 15:52:59

intro中文man

2011-08-23 13:40:31

2011-08-25 15:54:08

ferror中文man

2011-08-25 17:24:54

puts中文man

2011-08-25 18:34:55

ungetc中文man

2011-08-23 10:03:40

useradd中文man

2011-08-23 10:29:02

chpasswd中文man

2011-08-23 10:34:22

convertquot中文man

2011-08-23 15:39:34

rpmbuild中文man

2011-08-24 15:48:38

INSERT中文man
点赞
收藏

51CTO技术栈公众号