1FSCK(8) System Administration FSCK(8)
2
3
4
6 fsck - check and repair a Linux filesystem
7
9 fsck [-lsAVRTMNP] [-r [fd]] [-C [fd]] [-t fstype] [filesystem...] [--]
10 [fs-specific-options]
11
13 fsck is used to check and optionally repair one or more Linux
14 filesystems. filesystem can be a device name (e.g., /dev/hdc1,
15 /dev/sdb2), a mount point (e.g., /, /usr, /home), or a filesystem label
16 or UUID specifier (e.g., UUID=8868abf6-88c5-4a83-98b8-bfc24057f7bd or
17 LABEL=root). Normally, the fsck program will try to handle filesystems
18 on different physical disk drives in parallel to reduce the total
19 amount of time needed to check all of them.
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 status returned by fsck is the sum of the following
26 conditions:
27
28 0
29 No errors
30
31 1
32 Filesystem errors corrected
33
34 2
35 System should be rebooted
36
37 4
38 Filesystem errors left uncorrected
39
40 8
41 Operational error
42
43 16
44 Usage or syntax error
45
46 32
47 Checking canceled by user request
48
49 128
50 Shared-library error
51
52 The exit status returned when multiple filesystems are checked is the
53 bit-wise OR of the exit statuses for each filesystem that is checked.
54
55 In actuality, fsck is simply a front-end for the various filesystem
56 checkers (fsck.fstype) available under Linux. The filesystem-specific
57 checker is searched for in the PATH environment variable. If the PATH
58 is undefined then fallback to /sbin.
59
60 Please see the filesystem-specific checker manual pages for further
61 details.
62
64 -l
65 Create an exclusive flock(2) lock file (/run/fsck/<diskname>.lock)
66 for whole-disk device. This option can be used with one device only
67 (this means that -A and -l are mutually exclusive). This option is
68 recommended when more fsck instances are executed in the same time.
69 The option is ignored when used for multiple devices or for
70 non-rotating disks. fsck does not lock underlying devices when
71 executed to check stacked devices (e.g. MD or DM) - this feature is
72 not implemented yet.
73
74 -r [fd]
75 Report certain statistics for each fsck when it completes. These
76 statistics include the exit status, the maximum run set size (in
77 kilobytes), the elapsed all-clock time and the user and system CPU
78 time used by the fsck run. For example:
79
80 /dev/sda1: status 0, rss 92828, real 4.002804, user 2.677592, sys
81 0.86186
82
83 GUI front-ends may specify a file descriptor fd, in which case the
84 progress bar information will be sent to that file descriptor in a
85 machine parsable format. For example:
86
87 /dev/sda1 0 92828 4.002804 2.677592 0.86186
88
89 -s
90 Serialize fsck operations. This is a good idea if you are checking
91 multiple filesystems and the checkers are in an interactive mode.
92 (Note: e2fsck(8) runs in an interactive mode by default. To make
93 e2fsck(8) run in a non-interactive mode, you must either specify
94 the -p or -a option, if you wish for errors to be corrected
95 automatically, or the -n option if you do not.)
96
97 -t fslist
98 Specifies the type(s) of filesystem to be checked. When the -A flag
99 is specified, only filesystems that match fslist are checked. The
100 fslist parameter is a comma-separated list of filesystems and
101 options specifiers. All of the filesystems in this comma-separated
102 list may be prefixed by a negation operator 'no' or '!', which
103 requests that only those filesystems not listed in fslist will be
104 checked. If none of the filesystems in fslist is prefixed by a
105 negation operator, then only those listed filesystems will be
106 checked.
107
108 Options specifiers may be included in the comma-separated fslist.
109 They must have the format opts=fs-option. If an options specifier
110 is present, then only filesystems which contain fs-option in their
111 mount options field of /etc/fstab will be checked. If the options
112 specifier is prefixed by a negation operator, then only those
113 filesystems that do not have fs-option in their mount options field
114 of /etc/fstab will be checked.
115
116 For example, if opts=ro appears in fslist, then only filesystems
117 listed in /etc/fstab with the ro option will be checked.
118
119 For compatibility with Mandrake distributions whose boot scripts
120 depend upon an unauthorized UI change to the fsck program, if a
121 filesystem type of loop is found in fslist, it is treated as if
122 opts=loop were specified as an argument to the -t option.
123
124 Normally, the filesystem type is deduced by searching for filesys
125 in the /etc/fstab file and using the corresponding entry. If the
126 type cannot be deduced, and there is only a single filesystem given
127 as an argument to the -t option, fsck will use the specified
128 filesystem type. If this type is not available, then the default
129 filesystem type (currently ext2) is used.
130
131 -A
132 Walk through the /etc/fstab file and try to check all filesystems
133 in one run. This option is typically used from the /etc/rc system
134 initialization file, instead of multiple commands for checking a
135 single filesystem.
136
137 The root filesystem will be checked first unless the -P option is
138 specified (see below). After that, filesystems will be checked in
139 the order specified by the fs_passno (the sixth) field in the
140 /etc/fstab file. Filesystems with a fs_passno value of 0 are
141 skipped and are not checked at all. Filesystems with a fs_passno
142 value of greater than zero will be checked in order, with
143 filesystems with the lowest fs_passno number being checked first.
144 If there are multiple filesystems with the same pass number, fsck
145 will attempt to check them in parallel, although it will avoid
146 running multiple filesystem checks on the same physical disk.
147
148 fsck does not check stacked devices (RAIDs, dm-crypt, ...) in
149 parallel with any other device. See below for
150 FSCK_FORCE_ALL_PARALLEL setting. The /sys filesystem is used to
151 determine dependencies between devices.
152
153 Hence, a very common configuration in /etc/fstab files is to set
154 the root filesystem to have a fs_passno value of 1 and to set all
155 other filesystems to have a fs_passno value of 2. This will allow
156 fsck to automatically run filesystem checkers in parallel if it is
157 advantageous to do so. System administrators might choose not to
158 use this configuration if they need to avoid multiple filesystem
159 checks running in parallel for some reason - for example, if the
160 machine in question is short on memory so that excessive paging is
161 a concern.
162
163 fsck normally does not check whether the device actually exists
164 before calling a filesystem specific checker. Therefore
165 non-existing devices may cause the system to enter filesystem
166 repair mode during boot if the filesystem specific checker returns
167 a fatal error. The /etc/fstab mount option nofail may be used to
168 have fsck skip non-existing devices. fsck also skips non-existing
169 devices that have the special filesystem type auto.
170
171 -C [fd]
172 Display completion/progress bars for those filesystem checkers
173 (currently only for ext[234]) which support them. fsck will manage
174 the filesystem checkers so that only one of them will display a
175 progress bar at a time. GUI front-ends may specify a file
176 descriptor fd, in which case the progress bar information will be
177 sent to that file descriptor.
178
179 -M
180 Do not check mounted filesystems and return an exit status of 0 for
181 mounted filesystems.
182
183 -N
184 Don’t execute, just show what would be done.
185
186 -P
187 When the -A flag is set, check the root filesystem in parallel with
188 the other filesystems. This is not the safest thing in the world to
189 do, since if the root filesystem is in doubt things like the
190 e2fsck(8) executable might be corrupted! This option is mainly
191 provided for those sysadmins who don’t want to repartition the root
192 filesystem to be small and compact (which is really the right
193 solution).
194
195 -R
196 When checking all filesystems with the -A flag, skip the root
197 filesystem. (This is useful in case the root filesystem has already
198 been mounted read-write.)
199
200 -T
201 Don’t show the title on startup.
202
203 -V
204 Produce verbose output, including all filesystem-specific commands
205 that are executed.
206
207 -?, --help
208 Display help text and exit.
209
210 --version
211 Display version information and exit.
212
214 Options which are not understood by fsck are passed to the
215 filesystem-specific checker!
216
217 These options must not take arguments, as there is no way for fsck to
218 be able to properly guess which options take arguments and which don’t.
219
220 Options and arguments which follow the -- are treated as
221 filesystem-specific options to be passed to the filesystem-specific
222 checker.
223
224 Please note that fsck is not designed to pass arbitrarily complicated
225 options to filesystem-specific checkers. If you’re doing something
226 complicated, please just execute the filesystem-specific checker
227 directly. If you pass fsck some horribly complicated options and
228 arguments, and it doesn’t do what you expect, don’t bother reporting it
229 as a bug. You’re almost certainly doing something that you shouldn’t be
230 doing with fsck. Options to different filesystem-specific fsck’s are
231 not standardized.
232
234 The fsck program’s behavior is affected by the following environment
235 variables:
236
237 FSCK_FORCE_ALL_PARALLEL
238 If this environment variable is set, fsck will attempt to check all
239 of the specified filesystems in parallel, regardless of whether the
240 filesystems appear to be on the same device. (This is useful for
241 RAID systems or high-end storage systems such as those sold by
242 companies such as IBM or EMC.) Note that the fs_passno value is
243 still used.
244
245 FSCK_MAX_INST
246 This environment variable will limit the maximum number of
247 filesystem checkers that can be running at one time. This allows
248 configurations which have a large number of disks to avoid fsck
249 starting too many filesystem checkers at once, which might overload
250 CPU and memory resources available on the system. If this value is
251 zero, then an unlimited number of processes can be spawned. This is
252 currently the default, but future versions of fsck may attempt to
253 automatically determine how many filesystem checks can be run based
254 on gathering accounting data from the operating system.
255
256 PATH
257 The PATH environment variable is used to find filesystem checkers.
258
259 FSTAB_FILE
260 This environment variable allows the system administrator to
261 override the standard location of the /etc/fstab file. It is also
262 useful for developers who are testing fsck.
263
264 LIBBLKID_DEBUG=all
265 enables libblkid debug output.
266
267 LIBMOUNT_DEBUG=all
268 enables libmount debug output.
269
271 /etc/fstab
272
274 Theodore Ts’o <tytso@mit.edu>>, Karel Zak <kzak@redhat.com>
275
277 fstab(5), mkfs(8), fsck.ext2(8) or fsck.ext3(8) or e2fsck(8),
278 fsck.cramfs(8), fsck.jfs(8), fsck.nfs(8), fsck.minix(8), fsck.msdos(8),
279 fsck.vfat(8), fsck.xfs(8), reiserfsck(8)
280
282 For bug reports, use the issue tracker at
283 https://github.com/util-linux/util-linux/issues.
284
286 The fsck command is part of the util-linux package which can be
287 downloaded from Linux Kernel Archive
288 <https://www.kernel.org/pub/linux/utils/util-linux/>.
289
290
291
292util-linux 2.39.2 2023-06-14 FSCK(8)