1FSCK(8)                      System Administration                     FSCK(8)
2
3
4

NAME

6       fsck - check and repair a Linux filesystem
7

SYNOPSIS

9       fsck [-lrsAVRTMNP] [-C [fd]] [-t fstype] [filesystem...]  [--] [fs-spe‐
10       cific-options]
11

DESCRIPTION

13       fsck is used to check and optionally repair one or more Linux  filesys‐
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 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 code returned by fsck is the sum of the following conditions:
26
27              0      No errors
28              1      Filesystem errors corrected
29              2      System should be rebooted
30              4      Filesystem errors left uncorrected
31              8      Operational error
32              16     Usage or syntax error
33              32     Checking canceled by user request
34              128    Shared-library error
35
36       The exit code returned when multiple filesystems  are  checked  is  the
37       bit-wise OR of the exit codes for each filesystem that is checked.
38
39       In  actuality,  fsck  is  simply a front-end for the various filesystem
40       checkers (fsck.fstype) available under Linux.  The  filesystem-specific
41       checker  is  searched for in /sbin first, then in /etc/fs and /etc, and
42       finally in the directories listed in  the  PATH  environment  variable.
43       Please  see  the  filesystem-specific  checker manual pages for further
44       details.
45

OPTIONS

47       -l     Lock the whole-disk  device  by  an  exclusive  flock(2).   This
48              option  can be used with one device only (this means that -A and
49              -l are mutually exclusive).  This  option  is  recommended  when
50              more  fsck(8)  instances  are  executed  in  the same time.  The
51              option is ignored when used for multiple  devices  or  for  non-
52              rotating disks.  fsck does not lock underlying devices when exe‐
53              cuted to check stacked devices (e.g. MD or DM) --  this  feature
54              is not implemented yet.
55
56       -r     Report certain statistics for each fsck when it completes. These
57              statistics include the exit status, the maximum run set size (in
58              kilobytes),  the  elapsed all-clock time and the user and system
59              CPU time used by the fsck run. For example:
60
61              /dev/sda1: status 0, rss 92828, real  4.002804,  user  2.677592,
62              sys 0.86186
63
64       -s     Serialize  fsck  operations.   This  is  a  good idea if you are
65              checking multiple filesystems and the checkers are in an  inter‐
66              active  mode.   (Note:  e2fsck(8) runs in an interactive mode by
67              default.  To make e2fsck(8) run in a non-interactive  mode,  you
68              must  either specify the -p or -a option, if you wish for errors
69              to be corrected automatically, or the -n option if you do not.)
70
71       -t fslist
72              Specifies the type(s) of filesystem to be checked.  When the  -A
73              flag  is  specified,  only  filesystems  that  match  fslist are
74              checked.  The fslist parameter  is  a  comma-separated  list  of
75              filesystems  and  options specifiers.  All of the filesystems in
76              this comma-separated list may be prefixed by a negation operator
77              'no'  or  '!',  which  requests  that only those filesystems not
78              listed in fslist will be checked.  If none of the filesystems in
79              fslist  is  prefixed  by  a  negation  operator, then only those
80              listed filesystems will be checked.
81
82              Options  specifiers  may  be  included  in  the  comma-separated
83              fslist.   They  must  have  the  format  opts=fs-option.   If an
84              options specifier is present, then only filesystems  which  con‐
85              tain  fs-option  in their mount options field of /etc/fstab will
86              be checked.  If the options specifier is prefixed by a  negation
87              operator, then only those filesystems that do not have fs-option
88              in their mount options field of /etc/fstab will be checked.
89
90              For example, if opts=ro appears in fslist, then only filesystems
91              listed in /etc/fstab with the ro option will be checked.
92
93              For compatibility with Mandrake distributions whose boot scripts
94              depend upon an unauthorized UI change to the fsck program, if  a
95              filesystem  type of loop is found in fslist, it is treated as if
96              opts=loop were specified as an argument to the -t option.
97
98              Normally, the  filesystem  type  is  deduced  by  searching  for
99              filesys  in  the  /etc/fstab  file  and  using the corresponding
100              entry.  If the type can not be deduced, and there is only a sin‐
101              gle  filesystem given as an argument to the -t option, fsck will
102              use the specified filesystem type.  If this type is  not  avail‐
103              able, then the default filesystem type (currently ext2) is used.
104
105       -A     Walk  through  the /etc/fstab file and try to check all filesys‐
106              tems in one run.  This option is typically used from the /etc/rc
107              system  initialization  file,  instead  of multiple commands for
108              checking a single filesystem.
109
110              The root filesystem will be checked first unless the  -P  option
111              is  specified  (see  below).   After  that,  filesystems will be
112              checked in the order specified  by  the  fs_passno  (the  sixth)
113              field  in  the  /etc/fstab  file.   Filesystems with a fs_passno
114              value of 0 are skipped and are not checked at all.   Filesystems
115              with  a  fs_passno value of greater than zero will be checked in
116              order, with filesystems with the lowest fs_passno  number  being
117              checked  first.  If there are multiple filesystems with the same
118              pass number, fsck  will  attempt  to  check  them  in  parallel,
119              although it will avoid running multiple filesystem checks on the
120              same physical disk.
121
122              fsck does not check stacked devices (RAIDs,  dm-crypt,  ...)  in
123              parallel    with    any    other    device.    See   below   for
124              FSCK_FORCE_ALL_PARALLEL setting.  The /sys filesystem is used to
125              detemine dependencies between devices.
126
127              Hence, a very common configuration in /etc/fstab files is to set
128              the root filesystem to have a fs_passno value of 1  and  to  set
129              all other filesystems to have a fs_passno value of 2.  This will
130              allow fsck to automatically run filesystem checkers in  parallel
131              if  it  is  advantageous  to do so.  System administrators might
132              choose not to use this configuration if they need to avoid  mul‐
133              tiple  filesystem checks running in parallel for some reason ---
134              for example, if the machine in question is short  on  memory  so
135              that excessive paging is a concern.
136
137              fsck  normally does not check whether the device actually exists
138              before calling a filesystem specific  checker.   Therefore  non-
139              existing devices may cause the system to enter filesystem repair
140              mode during boot if the filesystem specific  checker  returns  a
141              fatal  error.  The /etc/fstab mount option nofail may be used to
142              have fsck skip non-existing devices.  fsck also skips non-exist‐
143              ing devices that have the special filesystem type auto.
144
145       -C [fd]
146              Display  completion/progress  bars for those filesystem checkers
147              (currently only for ext2 and ext3)  which  support  them.   fsck
148              will  manage  the  filesystem  checkers so that only one of them
149              will display a progress bar at a time.  GUI front-ends may spec‐
150              ify  a file descriptor fd, in which case the progress bar infor‐
151              mation will be sent to that file descriptor.
152
153       -M     Do not check mounted filesystems and return an exit  code  of  0
154              for mounted filesystems.
155
156       -N     Don't execute, just show what would be done.
157
158       -P     When  the  -A flag is set, check the root filesystem in parallel
159              with the other filesystems.  This is not the safest thing in the
160              world  to  do,  since  if the root filesystem is in doubt things
161              like the e2fsck(8) executable might be corrupted!   This  option
162              is  mainly provided for those sysadmins who don't want to repar‐
163              tition the root filesystem to be small  and  compact  (which  is
164              really the right solution).
165
166       -R     When  checking  all  filesystems with the -A flag, skip the root
167              filesystem.  (This is useful in case  the  root  filesystem  has
168              already been mounted read-write.)
169
170       -T     Don't show the title on startup.
171
172       -V     Produce  verbose  output, including all filesystem-specific com‐
173              mands that are executed.
174
175       fs-specific-options
176              Options which are not understood  by  fsck  are  passed  to  the
177              filesystem-specific  checker.  These options must not take argu‐
178              ments, as there is no way for fsck to be able to properly  guess
179              which options take arguments and which don't.
180
181              Options  and  arguments  which  follow  the  --  are  treated as
182              filesystem-specific options to be passed to the  filesystem-spe‐
183              cific checker.
184
185              Please  note  that fsck is not designed to pass arbitrarily com‐
186              plicated options to  filesystem-specific  checkers.   If  you're
187              doing something complicated, please just execute the filesystem-
188              specific checker directly.  If you pass fsck some horribly  com‐
189              plicated  options  and  arguments,  and  it  doesn't do what you
190              expect, don't bother reporting it as a bug.  You're almost  cer‐
191              tainly doing something that you shouldn't be doing with fsck.
192
193       Options  to  different filesystem-specific fsck's are not standardized.
194       If in doubt, please consult the man pages  of  the  filesystem-specific
195       checker.   Although not guaranteed, the following options are supported
196       by most filesystem checkers:
197
198       -a     Automatically repair the filesystem without any  questions  (use
199              this  option with caution).  Note that e2fsck(8) supports -a for
200              backward compatibility only.  This option is mapped to  e2fsck's
201              -p  option  which is safe to use, unlike the -a option that some
202              filesystem checkers support.
203
204       -n     For some filesystem-specific checkers, the -n option will  cause
205              the fs-specific fsck to avoid attempting to repair any problems,
206              but simply report such problems to stdout.  This is however  not
207              true  for  all  filesystem-specific  checkers.   In  particular,
208              fsck.reiserfs(8) will not report any corruption  if  given  this
209              option.  fsck.minix(8) does not support the -n option at all.
210
211       -r     Interactively  repair  the  filesystem  (ask for confirmations).
212              Note: It is generally a bad idea to use this option if  multiple
213              fsck's  are  being  run  in  parallel.   Also  note that this is
214              e2fsck's default behavior; it supports this option for  backward
215              compatibility reasons only.
216
217       -y     For  some filesystem-specific checkers, the -y option will cause
218              the fs-specific fsck to  always  attempt  to  fix  any  detected
219              filesystem corruption automatically.  Sometimes an expert may be
220              able to do better driving the fsck manually.  Note that not  all
221              filesystem-specific checkers implement this option.  In particu‐
222              lar fsck.minix(8) and  fsck.cramfs(8)  do  not  support  the  -y
223              option as of this writing.
224

FILES

226       /etc/fstab.
227

ENVIRONMENT VARIABLES

229       The  fsck  program's  behavior is affected by the following environment
230       variables:
231
232       FSCK_FORCE_ALL_PARALLEL
233              If this environment variable is set, fsck will attempt to  check
234              all  of  the  specified  filesystems  in parallel, regardless of
235              whether the filesystems appear to be on the same device.   (This
236              is  useful  for RAID systems or high-end storage systems such as
237              those sold by companies such as IBM  or  EMC.)   Note  that  the
238              fs_passno value is still used.
239
240       FSCK_MAX_INST
241              This  environment  variable  will  limit  the  maximum number of
242              filesystem checkers that can  be  running  at  one  time.   This
243              allows  configurations  which  have  a  large number of disks to
244              avoid fsck starting too many filesystem checkers at once,  which
245              might overload CPU and memory resources available on the system.
246              If this value is zero, then an unlimited number of processes can
247              be  spawned.  This is currently the default, but future versions
248              of fsck may attempt to automatically determine how many filesys‐
249              tem  checks  can  be run based on gathering accounting data from
250              the operating system.
251
252       PATH   The PATH environment variable is used to find filesystem  check‐
253              ers.   A  set  of  system directories are searched first: /sbin,
254              /sbin/fs.d, /sbin/fs, /etc/fs, and /etc.  Then the set of direc‐
255              tories found in the PATH environment are searched.
256
257       FSTAB_FILE
258              This  environment  variable  allows  the system administrator to
259              override the standard location of the /etc/fstab  file.   It  is
260              also useful for developers who are testing fsck.
261
262       LIBBLKID_DEBUG=0xffff
263              enables debug output.
264
265       LIBMOUNT_DEBUG=0xffff
266              enables debug output.
267

SEE ALSO

269       fstab(5),  mkfs(8),  fsck.ext2(8)  or fsck.ext3(8) or e2fsck(8), cramf‐
270       sck(8),   fsck.minix(8),   fsck.msdos(8),   fsck.jfs(8),   fsck.nfs(8),
271       fsck.vfat(8), fsck.xfs(8), fsck.xiafs(8), reiserfsck(8).
272

AUTHOR

274       Theodore Ts'o ⟨tytso@mit.edu⟩
275

AVAILABILITY

277       The  fsck  command  is  part of the util-linux package and is available
278       from Linux Kernel  Archive  ⟨ftp://ftp.kernel.org/pub/linux/utils/util-
279       linux/⟩.
280
281
282
283util-linux                       February 2009                         FSCK(8)
Impressum