1FSCK(8)                      MAINTENANCE COMMANDS                      FSCK(8)
2
3
4

NAME

6       fsck - check and repair a Linux file system
7

SYNOPSIS

9       fsck [-sAVRTMNP] [-C [fd]] [-t fstype] [filesys...]  [--] [fs-specific-
10       options]
11

DESCRIPTION

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

OPTIONS

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              Hence, a very common configuration in /etc/fstab files is to set
105              the  root  filesystem  to have a fs_passno value of 1 and to set
106              all other filesystems to have a fs_passno value of 2.  This will
107              allow  fsck to automatically run filesystem checkers in parallel
108              if it is advantageous to do  so.   System  administrators  might
109              choose  not to use this configuration if they need to avoid mul‐
110              tiple filesystem checks running in parallel for some reason  ---
111              for  example,  if  the machine in question is short on memory so
112              that excessive paging is a concern.
113
114              fsck normally does not check whether the device actually  exists
115              before  calling  a  file system specific checker. Therefore non-
116              existing devices may cause  the  system  to  enter  file  system
117              repair  mode  during  boot  if  the  filesystem specific checker
118              returns a fatal error. The /etc/fstab mount option nofail may be
119              used  to  have  fsck skip non-existing devices.  fsck also skips
120              non-existing devices that have the special file system type auto
121
122       -C [  fd  ]
123              Display completion/progress bars for those  filesystem  checkers
124              (currently  only  for  ext2 and ext3) which support them.   Fsck
125              will manage the filesystem checkers so that  only  one  of  them
126              will display a progress bar at a time.  GUI front-ends may spec‐
127              ify a file descriptor fd, in which case the progress bar  infor‐
128              mation will be sent to that file descriptor.
129
130       -M     Do  not  check  mounted filesystems and return an exit code of 0
131              for mounted filesystems.
132
133       -N     Don't execute, just show what would be done.
134
135       -P     When the -A flag is set, check the root filesystem  in  parallel
136              with the other filesystems.  This is not the safest thing in the
137              world to do, since if the root filesystem  is  in  doubt  things
138              like  the  e2fsck(8) executable might be corrupted!  This option
139              is mainly provided for those sysadmins who don't want to  repar‐
140              tition  the  root  filesystem  to be small and compact (which is
141              really the right solution).
142
143       -R     When checking all file systems with the -A flag, skip  the  root
144              file system (in case it's already mounted read-write).
145
146       -T     Don't show the title on startup.
147
148       -V     Produce  verbose output, including all file system-specific com‐
149              mands that are executed.
150
151       fs-specific-options
152              Options which are not understood  by  fsck  are  passed  to  the
153              filesystem-specific  checker.   These  arguments  must  not take
154              arguments, as there is no way for fsck to be  able  to  properly
155              guess which arguments take options and which don't.
156
157              Options  and  arguments  which follow the -- are treated as file
158              system-specific options to be passed to the file system-specific
159              checker.
160
161              Please  note  that fsck is not designed to pass arbitrarily com‐
162              plicated options to  filesystem-specific  checkers.   If  you're
163              doing something complicated, please just execute the filesystem-
164              specific checker directly.  If you pass fsck some horribly  com‐
165              plicated  option  and  arguments,  and  it  doesn't  do what you
166              expect, don't bother reporting it as a bug.  You're almost  cer‐
167              tainly doing something that you shouldn't be doing with fsck.
168
169       Options  to  different filesystem-specific fsck's are not standardized.
170       If in doubt, please consult the man pages  of  the  filesystem-specific
171       checker.   Although not guaranteed, the following options are supported
172       by most file system checkers:
173
174       -a     Automatically repair the file system without any questions  (use
175              this  option with caution).  Note that e2fsck(8) supports -a for
176              backwards compatibility only.  This option is mapped to e2fsck's
177              -p  option  which is safe to use, unlike the -a option that some
178              file system checkers support.
179
180       -n     For some filesystem-specific checkers, the -n option will  cause
181              the fs-specific fsck to avoid attempting to repair any problems,
182              but simply report such problems to stdout.  This is however  not
183              true  for  all  filesystem-specific  checkers.   In  particular,
184              fsck.reiserfs(8) will not report any corruption  if  given  this
185              option.  fsck.minix(8) does not support the -n option at all.
186
187       -r     Interactively  repair  the  filesystem  (ask for confirmations).
188              Note: It is generally a bad idea to use this option if  multiple
189              fsck's  are  being  run  in  parallel.   Also  note that this is
190              e2fsck's default behavior; it supports this option for backwards
191              compatibility reasons only.
192
193       -y     For  some filesystem-specific checkers, the -y option will cause
194              the fs-specific fsck to  always  attempt  to  fix  any  detected
195              filesystem corruption automatically.  Sometimes an expert may be
196              able to do better driving the fsck manually.  Note that not  all
197              filesystem-specific checkers implement this option.  In particu‐
198              lar fsck.minix(8) and fsck.cramfs(8) does  not  support  the  -y
199              option as of this writing.
200

AUTHOR

202       Theodore Ts'o (tytso@mit.edu)
203

AVAILABILITY

205       The  fsck command is part of the util-linux-ng package and is available
206       from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
207

FILES

209       /etc/fstab.
210

ENVIRONMENT VARIABLES

212       The fsck program's behavior is affected by  the  following  environment
213       variables:
214
215       FSCK_FORCE_ALL_PARALLEL
216              If  this  environment  variable is set, fsck will attempt to run
217              all of the specified  filesystems  in  parallel,  regardless  of
218              whether  the filesystems appear to be on the same device.  (This
219              is useful for RAID systems or high-end storage systems  such  as
220              those sold by companies such as IBM or EMC.)
221
222       FSCK_MAX_INST
223              This  environment variable will limit the maximum number of file
224              system checkers that can be running at one  time.   This  allows
225              configurations  which have a large number of disks to avoid fsck
226              starting too many file system  checkers  at  once,  which  might
227              overload  CPU  and memory resources available on the system.  If
228              this value is zero, then an unlimited number of processes can be
229              spawned.   This is currently the default, but future versions of
230              fsck may attempt to automatically determine how many file system
231              checks  can  be  run based on gathering accounting data from the
232              operating system.
233
234       PATH   The PATH environment variable is used to find file system check‐
235              ers.   A  set  of  system directories are searched first: /sbin,
236              /sbin/fs.d, /sbin/fs, /etc/fs, and /etc.  Then the set of direc‐
237              tories found in the PATH environment are searched.
238
239       FSTAB_FILE
240              This  environment  variable  allows  the system administrator to
241              override the standard location of the /etc/fstab  file.   It  is
242              also useful for developers who are testing fsck.
243

SEE ALSO

245       fstab(5),  mkfs(8),  fsck.ext2(8)  or fsck.ext3(8) or e2fsck(8), cramf‐
246       sck(8),   fsck.minix(8),   fsck.msdos(8),   fsck.jfs(8),   fsck.nfs(8),
247       fsck.vfat(8), fsck.xfs(8), fsck.xiafs(8), reiserfsck(8).
248
249
250
251Linux                            February 2009                         FSCK(8)
Impressum