xref: /netbsd-src/sbin/fsck_ffs/fsck_ffs.8 (revision 87ba0e2a319653af510fae24a6d2975d3589735b)
1*87ba0e2aSchs.\"	$NetBSD: fsck_ffs.8,v 1.52 2022/11/17 06:40:38 chs Exp $
20114e805Scgd.\"
3ccfa3742Smycroft.\" Copyright (c) 1980, 1989, 1991, 1993
4ccfa3742Smycroft.\"	The Regents of the University of California.  All rights reserved.
561f28255Scgd.\"
661f28255Scgd.\" Redistribution and use in source and binary forms, with or without
761f28255Scgd.\" modification, are permitted provided that the following conditions
861f28255Scgd.\" are met:
961f28255Scgd.\" 1. Redistributions of source code must retain the above copyright
1061f28255Scgd.\"    notice, this list of conditions and the following disclaimer.
1161f28255Scgd.\" 2. Redistributions in binary form must reproduce the above copyright
1261f28255Scgd.\"    notice, this list of conditions and the following disclaimer in the
1361f28255Scgd.\"    documentation and/or other materials provided with the distribution.
14bf07c871Sagc.\" 3. Neither the name of the University nor the names of its contributors
1561f28255Scgd.\"    may be used to endorse or promote products derived from this software
1661f28255Scgd.\"    without specific prior written permission.
1761f28255Scgd.\"
1861f28255Scgd.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1961f28255Scgd.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2061f28255Scgd.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2161f28255Scgd.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2261f28255Scgd.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2361f28255Scgd.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2461f28255Scgd.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2561f28255Scgd.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2661f28255Scgd.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2761f28255Scgd.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2861f28255Scgd.\" SUCH DAMAGE.
2961f28255Scgd.\"
300114e805Scgd.\"	@(#)fsck.8	8.3 (Berkeley) 11/29/94
31346aa5ddScgd.\"
32dfb7cec7Schristos.Dd May 4, 2018
33fea3644fScgd.Dt FSCK_FFS 8
3473f545bbSwiz.Os
35adb370a8Sjtc.Sh NAME
363cd14137Schristos.Nm fsck_ffs
37fea3644fScgd.Nd Fast File System consistency check and interactive repair
38adb370a8Sjtc.Sh SYNOPSIS
39990562bfSwiz.Nm
40dfb7cec7Schristos.Op Fl adFfPpqUXz
419aaa32d9Sbouyer.Op Fl B Ar byteorder
4265a50720Swiz.Op Fl b Ar block
43ccfa3742Smycroft.Op Fl c Ar level
443cd14137Schristos.Op Fl m Ar mode
45a8ac39afSbouyer.Op Fl x Ar snap-backup
46e69ce3e4Sdsl.Op Fl y | n
47f6590b22Smycroft.Ar filesystem ...
48adb370a8Sjtc.Sh DESCRIPTION
49b1db0383Slukem.Nm
503cd14137Schristosperforms interactive file system consistency checks and repair for each of
512fb4b1dbSwizthe file systems specified on the command line.
522fb4b1dbSwizIt is normally invoked from
533cd14137Schristos.Xr fsck 8 .
54adb370a8Sjtc.Pp
55ccfa3742SmycroftThe kernel takes care that only a restricted class of innocuous file system
5661f28255Scgdinconsistencies can happen unless hardware or software failures intervene.
5761f28255ScgdThese are limited to the following:
583cd14137Schristos.Pp
5965a50720Swiz.Bl -item -compact -offset indent
60adb370a8Sjtc.It
6161f28255ScgdUnreferenced inodes
62adb370a8Sjtc.It
6361f28255ScgdLink counts in inodes too large
64adb370a8Sjtc.It
6561f28255ScgdMissing blocks in the free map
66adb370a8Sjtc.It
6761f28255ScgdBlocks in the free map also in files
68adb370a8Sjtc.It
6961f28255ScgdCounts in the super-block wrong
70adb370a8Sjtc.El
71adb370a8Sjtc.Pp
7261f28255ScgdThese are the only inconsistencies that
73b1db0383Slukem.Nm
7465a50720Swizin
7565a50720Swiz.Dq preen
763cd14137Schristosmode (with the
77adb370a8Sjtc.Fl p
783cd14137Schristosoption) will correct; if it encounters other inconsistencies, it exits
793cd14137Schristoswith an abnormal return status.
8061f28255ScgdFor each corrected inconsistency one or more lines will be printed
8161f28255Scgdidentifying the file system on which the correction will take place,
822fb4b1dbSwizand the nature of the correction.
832fb4b1dbSwizAfter successfully correcting a file system,
84b1db0383Slukem.Nm
8561f28255Scgdwill print the number of files on that file system,
8661f28255Scgdthe number of used and free blocks,
8761f28255Scgdand the percentage of fragmentation.
88adb370a8Sjtc.Pp
89ccfa3742SmycroftIf sent a
90ccfa3742Smycroft.Dv QUIT
91ccfa3742Smycroftsignal,
92b1db0383Slukem.Nm
933cd14137Schristoswill finish the file system checks, then exit with an abnormal return status.
94adb370a8Sjtc.Pp
95bb82a84dSlukemIf
96bb82a84dSlukem.Nm
97bb82a84dSlukemreceives a
98bb82a84dSlukem.Dv SIGINFO
99bb82a84dSlukemsignal
100bb82a84dSlukem(see the
101bb82a84dSlukem.Sy status
102bb82a84dSlukemargument for
103bb82a84dSlukem.Xr stty 1 ) ,
104bb82a84dSlukema line will be written to the standard error output indicating
105bb82a84dSlukemthe name of the device currently being checked, the current phase
106bb82a84dSlukemnumber and phase-specific progress information.
107bb82a84dSlukem.Pp
10861f28255ScgdWithout the
109adb370a8Sjtc.Fl p
11061f28255Scgdoption,
111b1db0383Slukem.Nm
11261f28255Scgdaudits and interactively repairs inconsistent conditions for file systems.
11361f28255ScgdIf the file system is inconsistent the operator is prompted for concurrence
11461f28255Scgdbefore each correction is attempted.
11561f28255ScgdIt should be noted that some of the corrective actions which are not
11661f28255Scgdcorrectable under the
117adb370a8Sjtc.Fl p
11861f28255Scgdoption will result in some loss of data.
11961f28255ScgdThe amount and severity of data lost may be determined from the diagnostic
12061f28255Scgdoutput.
12161f28255ScgdThe default action for each consistency correction
122adb370a8Sjtcis to wait for the operator to respond
123ccfa3742Smycroft.Li yes
124adb370a8Sjtcor
125ccfa3742Smycroft.Li no .
12661f28255ScgdIf the operator does not have write permission on the file system
127b1db0383Slukem.Nm
12861f28255Scgdwill default to a
129adb370a8Sjtc.Fl n
130adb370a8Sjtcaction.
131adb370a8Sjtc.Pp
132b1db0383Slukem.Nm
13361f28255Scgdhas more consistency checks than
13461f28255Scgdits predecessors
135ccfa3742Smycroft.Em check , dcheck , fcheck ,
136adb370a8Sjtcand
137ccfa3742Smycroft.Em icheck
13861f28255Scgdcombined.
139adb370a8Sjtc.Pp
14061f28255ScgdThe following flags are interpreted by
141990562bfSwiz.Nm .
14265a50720Swiz.Bl -tag -width XBXbyteorderXX -offset indent
14343395bd5Sdbj.It Fl a
14443395bd5SdbjInterpret the filesystem as an Apple UFS filesystem, even if
14543395bd5Sdbjthere is no Apple UFS volume label present.
14665a50720Swiz.It Fl B Ar byteorder
14765a50720SwizConvert the file system metadata to
14865a50720Swiz.Ar byteorder
14965a50720Swizbyte order if needed.
15065a50720SwizValid byte orders are
15165a50720Swiz.Dq be
15265a50720Swizand
15365a50720Swiz.Dq le .
1542fb4b1dbSwizIf
155990562bfSwiz.Nm
15684958ed0Slukemis interrupted while swapping the metadata byte order, the file system cannot
1579aaa32d9Sbouyerbe recovered.
158990562bfSwiz.Nm
1596e6138d6Smsaitohwill print a message in interactive mode if the file system is not in host
1609aaa32d9Sbouyerbyte order.
16165a50720Swiz.It Fl b Ar block
16265a50720SwizUse the block number
16365a50720Swiz.Ar block
16465a50720Swizas the super block for the file system.
1652fb4b1dbSwizBlock 32 is usually an alternative super block.
166f801d654SwizThe
167f801d654Swiz.Fl b
168f801d654Swizoption of the
169f801d654Swiz.Xr scan_ffs 8
170f801d654Swizutility can also be used to find the offset of other super block backups
171f801d654Swizin a file system.
17265a50720Swiz.It Fl c Ar level
17351d7a18bSlukemConvert the FFSv1 file system to the level
17465a50720Swiz.Ar level .
175ccfa3742SmycroftNote that the level of a file system can only be raised.
1760b112129SfairThere are currently five levels defined:
17765a50720Swiz.Bl -tag -width 3n -offset indent
178ccfa3742Smycroft.It 0
179ccfa3742SmycroftThe file system is in the old (static table) format.
180ccfa3742Smycroft.It 1
181ccfa3742SmycroftThe file system is in the new (dynamic table) format.
182aae84c3aSdhollandSuch file systems are made by using the
183aae84c3aSdholland.Fl O Ar 0
184aae84c3aSdhollandoption to
185aae84c3aSdholland.Xr newfs 8 .
186ccfa3742Smycroft.It 2
18765a50720SwizThe file system supports 32-bit UIDs and GIDs,
188ccfa3742Smycroftshort symbolic links are stored in the inode,
189ccfa3742Smycroftand directories have an added field showing the file type.
190aae84c3aSdhollandThis format was introduced in
191aae84c3aSdholland.Bx 4.4 .
1920826920cSmycroft.It 3
1930826920cSmycroftIf maxcontig is greater than one,
1940826920cSmycroftbuild the free segment maps to aid in finding contiguous sets of blocks.
1950826920cSmycroftIf maxcontig is equal to one, delete any existing segment maps.
196aae84c3aSdhollandThis was the default before
197aae84c3aSdholland.Nx 2.0 .
198753116e0Sdbj.It 4
19951d7a18bSlukemRearrange the super block to the same layout as FFSv2;
200cf9b70c6Swizdisable the rotational layout tables and per cylinder group
201753116e0Sdbjblock totals.
202aae84c3aSdhollandSuch file systems are made by using the
203aae84c3aSdholland.Fl O Ar 1
204aae84c3aSdhollandoption to
205aae84c3aSdholland.Xr newfs 8 .
206ccfa3742Smycroft.El
207ccfa3742Smycroft.Pp
208*87ba0e2aSchsNote that FFSv2 file systems always have the features of FFSv1 level 4.
209*87ba0e2aSchs.Pp
210*87ba0e2aSchsFFSv2 file systems have separate conversion options:
211*87ba0e2aSchs.Bl -tag -width 3n -offset indent
212*87ba0e2aSchs.It ea
213*87ba0e2aSchsConvert the file system to the format which supports extended attributes
214*87ba0e2aSchs(and access control lists).
215*87ba0e2aSchsAfter this conversion is performed, the file system will no longer be
216*87ba0e2aSchsrecognized at all by releases prior to
217*87ba0e2aSchs.Nx 10.0 .
218*87ba0e2aSchs.It no-ea
219*87ba0e2aSchsConvert the file system to the format which does not support extended attributes
220*87ba0e2aSchs(or access control lists).
221*87ba0e2aSchsThis will remove any existing extended attributes, and the file system
222*87ba0e2aSchswill become recognizable to releases prior to
223*87ba0e2aSchs.Nx 10.0 .
224*87ba0e2aSchs.El
225aae84c3aSdholland.Pp
22661f28255ScgdIn interactive mode,
227b1db0383Slukem.Nm
228ccfa3742Smycroftwill list the conversion to be made
22961f28255Scgdand ask whether the conversion should be done.
23061f28255ScgdIf a negative answer is given,
23161f28255Scgdno further operations are done on the file system.
23261f28255ScgdIn preen mode,
233ccfa3742Smycroftthe conversion is listed and done if
23461f28255Scgdpossible without user interaction.
23561f28255ScgdConversion in preen mode is best used when all the file systems
23661f28255Scgdare being converted at once.
23751d7a18bSlukem.Pp
23851d7a18bSlukemThe output of
23951d7a18bSlukem.Xr dumpfs 8
24051d7a18bSlukemcan be examined to determine the format of the file system
24151d7a18bSlukem.Dq ( format
24251d7a18bSlukemin the second line)
24351d7a18bSlukemand the file system level
24451d7a18bSlukem.Dq ( fslevel
24551d7a18bSlukemin the sixth line).
246*87ba0e2aSchs.Pp
2473cd14137Schristos.It Fl d
2483cd14137SchristosPrint debugging output.
24984958ed0Slukem.It Fl F
25084958ed0SlukemIndicates that
25184958ed0Slukem.Ar filesystem
2520c249d8fSlukemis a file system image, rather than a raw character device.
2530c249d8fSlukem.Ar filesystem
2540c249d8fSlukemwill be accessed
2550c249d8fSlukem.Sq as-is ,
2560c249d8fSlukemand no attempts will be made to read a disklabel.
2573cd14137Schristos.It Fl f
2582fb4b1dbSwizForce checking of file systems.
2592fb4b1dbSwizNormally, if a file system is cleanly unmounted, the kernel will set a
2603cd14137Schristos.Dq clean flag
2613cd14137Schristosin the file system super block, and
2623cd14137Schristos.Nm
2632fb4b1dbSwizwill not check the file system.
2642fb4b1dbSwizThis option forces
2653cd14137Schristos.Nm
2663cd14137Schristosto check the file system, regardless of the state of the clean flag.
26765a50720Swiz.It Fl m Ar mode
26865a50720SwizUse the octal value
26965a50720Swiz.Ar mode
27065a50720Swizas the permission bits to use when creating the
2713cd14137Schristos.Pa lost+found
272b6daab9fSmrgdirectory rather than the default 1700.
2733cd14137SchristosIn particular, systems that do not wish to have lost files accessible
2743cd14137Schristosby all users on the system should use a more restrictive
2753cd14137Schristosset of permissions such as 700.
2763cd14137Schristos.It Fl n
2773cd14137SchristosAssume a no response to all questions asked by
278b1db0383Slukem.Nm
2793cd14137Schristosexcept for
2803cd14137Schristos.Ql CONTINUE? ,
2813cd14137Schristoswhich is assumed to be affirmative;
2823cd14137Schristosdo not open the file system for writing.
283a73c2bd5Schristos.It Fl P
284a73c2bd5SchristosDisplay a progress meter for the file system check.
285a73c2bd5SchristosA new meter is displayed for each of the 5 file system check passes, unless
286a73c2bd5Schristos.Fl p
287a73c2bd5Schristosis specified, in which case only one meter for overall progress is displayed.
288a73c2bd5SchristosProgress meters are disabled if the
289b15d62ffSwiz.Fl d
290a73c2bd5Schristosoption is specified.
291b15d62ffSwiz.It Fl p
292b15d62ffSwizSpecify
293b15d62ffSwiz.Dq preen
294b15d62ffSwizmode, described above.
29536fa5776Swiz.It Fl q
29636fa5776SwizQuiet mode, do not output any messages for clean filesystems.
29736fa5776Swiz.It Fl U
29836fa5776SwizResolve user ids to usernames.
29936fa5776Swiz.It Fl X
30036fa5776SwizSimilar to
30136fa5776Swiz.Fl x
30236fa5776Swizbut uses a file system internal snapshot on the file system to be checked.
303a8ac39afSbouyer.It Fl x Ar snap-backup
304a8ac39afSbouyerUse a snapshot with
305a8ac39afSbouyer.Ar snap-backup
3063932d281Swizas backup to check a read-write mounted filesystem.
3073932d281SwizMust be used with
308a8ac39afSbouyer.Fl n .
309a8ac39afSbouyerSee
310a8ac39afSbouyer.Xr fss 4
311a8ac39afSbouyerfor more details.
3124a8ce74dSgdtThe point is to check an internally-consistent version of the
3134a8ce74dSgdtfilesystem to find out if it is damaged; on failure one should unmount
3144a8ce74dSgdtthe filesystem and repair it.
3153cd14137Schristos.It Fl y
3163cd14137SchristosAssume a yes response to all questions asked by
317990562bfSwiz.Nm ;
3183cd14137Schristosthis should be used with great caution as this is a free license
3193cd14137Schristosto continue after essentially unlimited trouble has been encountered.
320dfb7cec7Schristos.It Fl z
321dfb7cec7SchristosClear unused directory space.
322dfb7cec7SchristosThe cleared space includes deleted file names and name padding.
3233cd14137Schristos.El
324adb370a8Sjtc.Pp
32561f28255ScgdInconsistencies checked are as follows:
32665a50720Swiz.Bl -enum -offset indent -compact
327adb370a8Sjtc.It
32861f28255ScgdBlocks claimed by more than one inode or the free map.
329adb370a8Sjtc.It
33061f28255ScgdBlocks claimed by an inode outside the range of the file system.
331adb370a8Sjtc.It
33261f28255ScgdIncorrect link counts.
333adb370a8Sjtc.It
33461f28255ScgdSize checks:
3358bd7cb6aSross.Bl -item -offset indent -compact
336adb370a8Sjtc.It
337ccfa3742SmycroftDirectory size not a multiple of DIRBLKSIZ.
338adb370a8Sjtc.It
33961f28255ScgdPartially truncated file.
340adb370a8Sjtc.El
341adb370a8Sjtc.It
34261f28255ScgdBad inode format.
343adb370a8Sjtc.It
34461f28255ScgdBlocks not accounted for anywhere.
345adb370a8Sjtc.It
34661f28255ScgdDirectory checks:
3478bd7cb6aSross.Bl -item -offset indent -compact
348adb370a8Sjtc.It
34961f28255ScgdFile pointing to unallocated inode.
350adb370a8Sjtc.It
35161f28255ScgdInode number out of range.
352adb370a8Sjtc.It
35361f28255ScgdDot or dot-dot not the first two entries of a directory
35461f28255Scgdor having the wrong inode number.
355adb370a8Sjtc.El
356adb370a8Sjtc.It
35761f28255ScgdSuper Block checks:
3588bd7cb6aSross.Bl -item -offset indent -compact
359adb370a8Sjtc.It
36061f28255ScgdMore blocks for inodes than there are in the file system.
361adb370a8Sjtc.It
36261f28255ScgdBad free block map format.
363adb370a8Sjtc.It
36461f28255ScgdTotal free block and/or free inode count incorrect.
365adb370a8Sjtc.El
366ccfa3742Smycroft.El
367adb370a8Sjtc.Pp
36861f28255ScgdOrphaned files and directories (allocated but unreferenced) are,
36961f28255Scgdwith the operator's concurrence, reconnected by
37061f28255Scgdplacing them in the
371adb370a8Sjtc.Pa lost+found
37261f28255Scgddirectory.
37361f28255ScgdThe name assigned is the inode number.
37461f28255ScgdIf the
375adb370a8Sjtc.Pa lost+found
37661f28255Scgddirectory does not exist, it is created.
37761f28255ScgdIf there is insufficient space its size is increased.
378adb370a8Sjtc.Pp
37961f28255ScgdBecause of inconsistencies between the block device and the buffer cache,
38061f28255Scgdthe raw device should always be used.
381adb370a8Sjtc.Sh DIAGNOSTICS
38261f28255ScgdThe diagnostics produced by
383b1db0383Slukem.Nm
38461f28255Scgdare fully enumerated and explained in Appendix A of
385ccfa3742Smycroft.Rs
386ccfa3742Smycroft.%T "Fsck \- The UNIX File System Check Program"
387ccfa3742Smycroft.Re
388adb370a8Sjtc.Sh SEE ALSO
389a8ac39afSbouyer.Xr fss 4 ,
390adb370a8Sjtc.Xr fs 5 ,
391c8fa8a4dSwiz.Xr fstab 5 ,
39251d7a18bSlukem.Xr dumpfs 8 ,
393c8fa8a4dSwiz.Xr fsck 8 ,
394adb370a8Sjtc.Xr fsdb 8 ,
395adb370a8Sjtc.Xr newfs 8 ,
396f801d654Swiz.Xr reboot 8 ,
397f801d654Swiz.Xr scan_ffs 8
398645829aaSsevan.Sh HISTORY
399645829aaSsevanA
400645829aaSsevan.Nm fsck
401645829aaSsevanutility appeared in
402645829aaSsevan.Bx 4.0 .
403645829aaSsevanIt was renamed to
404645829aaSsevan.Nm
405645829aaSsevanin
406645829aaSsevan.Nx 1.3
407645829aaSsevanwith the introduction of a filesystem independent wrapper as
408645829aaSsevan.Nm fsck .
409