1FSCK(8) MAINTENANCE COMMANDS FSCK(8)
2
3
4
6 fsck - check and repair a Linux file system
7
9 fsck [-sAVRTMNP] [-C [fd]] [-t fstype] [filesys...] [--] [fs-specific-
10 options]
11
13 fsck is used to check and optionally repair one or more Linux file sys‐
14 tems. filesys can be a device name (e.g. /dev/hdc1, /dev/sdb2), a
15 mount point (e.g. /, /usr, /home), or an ext2 label or UUID specifier
16 (e.g. UUID=8868abf6-88c5-4a83-98b8-bfc24057f7bd or LABEL=root). Nor‐
17 mally, the fsck program will try to handle filesystems on different
18 physical disk drives in parallel to reduce the total amount of time
19 needed to check all of the filesystems.
20
21 If no filesystems are specified on the command line, and the -A option
22 is not specified, fsck will default to checking filesystems in
23 /etc/fstab serially. This is equivalent to the -As options.
24
25 The exit code returned by fsck is the sum of the following conditions:
26 0 - No errors
27 1 - File system errors corrected
28 2 - System should be rebooted
29 4 - File system errors left uncorrected
30 8 - Operational error
31 16 - Usage or syntax error
32 32 - Fsck canceled by user request
33 128 - Shared library error
34 The exit code returned when multiple file systems are checked is the
35 bit-wise OR of the exit codes for each file system that is checked.
36
37 In actuality, fsck is simply a front-end for the various file system
38 checkers (fsck.fstype) available under Linux. The file system-specific
39 checker is searched for in /sbin first, then in /etc/fs and /etc, and
40 finally in the directories listed in the PATH environment variable.
41 Please see the file system-specific checker manual pages for further
42 details.
43
45 -s Serialize fsck operations. This is a good idea if you are
46 checking multiple filesystems and the checkers are in an inter‐
47 active mode. (Note: e2fsck(8) runs in an interactive mode by
48 default. To make e2fsck(8) run in a non-interactive mode, you
49 must either specify the -p or -a option, if you wish for errors
50 to be corrected automatically, or the -n option if you do not.)
51
52 -t fslist
53 Specifies the type(s) of file system to be checked. When the -A
54 flag is specified, only filesystems that match fslist are
55 checked. The fslist parameter is a comma-separated list of
56 filesystems and options specifiers. All of the filesystems in
57 this comma-separated list may be prefixed by a negation operator
58 'no' or '!', which requests that only those filesystems not
59 listed in fslist will be checked. If all of the filesystems in
60 fslist are not prefixed by a negation operator, then only those
61 filesystems listed in fslist will be checked.
62
63 Options specifiers may be included in the comma-separated
64 fslist. They must have the format opts=fs-option. If an
65 options specifier is present, then only filesystems which con‐
66 tain fs-option in their mount options field of /etc/fstab will
67 be checked. If the options specifier is prefixed by a negation
68 operator, then only those filesystems that do not have fs-option
69 in their mount options field of /etc/fstab will be checked.
70
71 For example, if opts=ro appears in fslist, then only filesystems
72 listed in /etc/fstab with the ro option will be checked.
73
74 For compatibility with Mandrake distributions whose boot scripts
75 depend upon an unauthorized UI change to the fsck program, if a
76 filesystem type of loop is found in fslist, it is treated as if
77 opts=loop were specified as an argument to the -t option.
78
79 Normally, the filesystem type is deduced by searching for
80 filesys in the /etc/fstab file and using the corresponding
81 entry. If the type can not be deduced, and there is only a sin‐
82 gle filesystem given as an argument to the -t option, fsck will
83 use the specified filesystem type. If this type is not avail‐
84 able, then the default file system type (currently ext2) is
85 used.
86
87 -A Walk through the /etc/fstab file and try to check all file sys‐
88 tems in one run. This option is typically used from the /etc/rc
89 system initialization file, instead of multiple commands for
90 checking a single file system.
91
92 The root filesystem will be checked first unless the -P option
93 is specified (see below). After that, filesystems will be
94 checked in the order specified by the fs_passno (the sixth)
95 field in the /etc/fstab file. Filesystems with a fs_passno
96 value of 0 are skipped and are not checked at all. Filesystems
97 with a fs_passno value of greater than zero will be checked in
98 order, with filesystems with the lowest fs_passno number being
99 checked first. If there are multiple filesystems with the same
100 pass number, fsck will attempt to check them in parallel,
101 although it will avoid running multiple filesystem checks on the
102 same physical disk.
103
104 fsck does not check stacked devices (RAIDs, dm-crypt, ...) in
105 parallel with any other device. See below for
106 FSCK_FORCE_ALL_PARALLEL setting. The /sys filesystem is used to
107 detemine dependencies between devices.
108
109 Hence, a very common configuration in /etc/fstab files is to set
110 the root filesystem to have a fs_passno value of 1 and to set
111 all other filesystems to have a fs_passno value of 2. This will
112 allow fsck to automatically run filesystem checkers in parallel
113 if it is advantageous to do so. System administrators might
114 choose not to use this configuration if they need to avoid mul‐
115 tiple filesystem checks running in parallel for some reason ---
116 for example, if the machine in question is short on memory so
117 that excessive paging is a concern.
118
119 fsck normally does not check whether the device actually exists
120 before calling a file system specific checker. Therefore non-
121 existing devices may cause the system to enter file system
122 repair mode during boot if the filesystem specific checker
123 returns a fatal error. The /etc/fstab mount option nofail may be
124 used to have fsck skip non-existing devices. fsck also skips
125 non-existing devices that have the special file system type auto
126
127 -C [ fd ]
128 Display completion/progress bars for those filesystem checkers
129 (currently only for ext2 and ext3) which support them. Fsck
130 will manage the filesystem checkers so that only one of them
131 will display a progress bar at a time. GUI front-ends may spec‐
132 ify a file descriptor fd, in which case the progress bar infor‐
133 mation will be sent to that file descriptor.
134
135 -M Do not check mounted filesystems and return an exit code of 0
136 for mounted filesystems.
137
138 -N Don't execute, just show what would be done.
139
140 -P When the -A flag is set, check the root filesystem in parallel
141 with the other filesystems. This is not the safest thing in the
142 world to do, since if the root filesystem is in doubt things
143 like the e2fsck(8) executable might be corrupted! This option
144 is mainly provided for those sysadmins who don't want to repar‐
145 tition the root filesystem to be small and compact (which is
146 really the right solution).
147
148 -R When checking all file systems with the -A flag, skip the root
149 file system (in case it's already mounted read-write).
150
151 -T Don't show the title on startup.
152
153 -V Produce verbose output, including all file system-specific com‐
154 mands that are executed.
155
156 fs-specific-options
157 Options which are not understood by fsck are passed to the
158 filesystem-specific checker. These arguments must not take
159 arguments, as there is no way for fsck to be able to properly
160 guess which arguments take options and which don't.
161
162 Options and arguments which follow the -- are treated as file
163 system-specific options to be passed to the file system-specific
164 checker.
165
166 Please note that fsck is not designed to pass arbitrarily com‐
167 plicated options to filesystem-specific checkers. If you're
168 doing something complicated, please just execute the filesystem-
169 specific checker directly. If you pass fsck some horribly com‐
170 plicated option and arguments, and it doesn't do what you
171 expect, don't bother reporting it as a bug. You're almost cer‐
172 tainly doing something that you shouldn't be doing with fsck.
173
174 Options to different filesystem-specific fsck's are not standardized.
175 If in doubt, please consult the man pages of the filesystem-specific
176 checker. Although not guaranteed, the following options are supported
177 by most file system checkers:
178
179 -a Automatically repair the file system without any questions (use
180 this option with caution). Note that e2fsck(8) supports -a for
181 backwards compatibility only. This option is mapped to e2fsck's
182 -p option which is safe to use, unlike the -a option that some
183 file system checkers support.
184
185 -n For some filesystem-specific checkers, the -n option will cause
186 the fs-specific fsck to avoid attempting to repair any problems,
187 but simply report such problems to stdout. This is however not
188 true for all filesystem-specific checkers. In particular,
189 fsck.reiserfs(8) will not report any corruption if given this
190 option. fsck.minix(8) does not support the -n option at all.
191
192 -r Interactively repair the filesystem (ask for confirmations).
193 Note: It is generally a bad idea to use this option if multiple
194 fsck's are being run in parallel. Also note that this is
195 e2fsck's default behavior; it supports this option for backwards
196 compatibility reasons only.
197
198 -y For some filesystem-specific checkers, the -y option will cause
199 the fs-specific fsck to always attempt to fix any detected
200 filesystem corruption automatically. Sometimes an expert may be
201 able to do better driving the fsck manually. Note that not all
202 filesystem-specific checkers implement this option. In particu‐
203 lar fsck.minix(8) and fsck.cramfs(8) does not support the -y
204 option as of this writing.
205
207 Theodore Ts'o (tytso@mit.edu)
208
210 The blkid command is part of the util-linux-ng package and is available
211 from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
212
214 /etc/fstab.
215
217 The fsck program's behavior is affected by the following environment
218 variables:
219
220 FSCK_FORCE_ALL_PARALLEL
221 If this environment variable is set, fsck will attempt to run
222 all of the specified filesystems in parallel, regardless of
223 whether the filesystems appear to be on the same device. (This
224 is useful for RAID systems or high-end storage systems such as
225 those sold by companies such as IBM or EMC.) Note that the
226 fs_passno value is still used.
227
228 FSCK_MAX_INST
229 This environment variable will limit the maximum number of file
230 system checkers that can be running at one time. This allows
231 configurations which have a large number of disks to avoid fsck
232 starting too many file system checkers at once, which might
233 overload CPU and memory resources available on the system. If
234 this value is zero, then an unlimited number of processes can be
235 spawned. This is currently the default, but future versions of
236 fsck may attempt to automatically determine how many file system
237 checks can be run based on gathering accounting data from the
238 operating system.
239
240 PATH The PATH environment variable is used to find file system check‐
241 ers. A set of system directories are searched first: /sbin,
242 /sbin/fs.d, /sbin/fs, /etc/fs, and /etc. Then the set of direc‐
243 tories found in the PATH environment are searched.
244
245 FSTAB_FILE
246 This environment variable allows the system administrator to
247 override the standard location of the /etc/fstab file. It is
248 also useful for developers who are testing fsck.
249
251 fstab(5), mkfs(8), fsck.ext2(8) or fsck.ext3(8) or e2fsck(8), cramf‐
252 sck(8), fsck.minix(8), fsck.msdos(8), fsck.jfs(8), fsck.nfs(8),
253 fsck.vfat(8), fsck.xfs(8), fsck.xiafs(8), reiserfsck(8).
254
255
256
257Linux February 2009 FSCK(8)