1*41ce3b17Snaddy.\" $OpenBSD: fsck_ext2fs.8,v 1.19 2022/03/31 17:27:19 naddy Exp $ 25ff4e0c8Sdownsj.\" $NetBSD: fsck_ext2fs.8,v 1.1 1997/06/11 11:21:48 bouyer Exp $ 38c424e8eSdownsj.\" 45ff4e0c8Sdownsj.\" Copyright (c) 1997 Manuel Bouyer. 58c424e8eSdownsj.\" Copyright (c) 1980, 1989, 1991, 1993 68c424e8eSdownsj.\" The Regents of the University of California. All rights reserved. 78c424e8eSdownsj.\" 88c424e8eSdownsj.\" Redistribution and use in source and binary forms, with or without 98c424e8eSdownsj.\" modification, are permitted provided that the following conditions 108c424e8eSdownsj.\" are met: 118c424e8eSdownsj.\" 1. Redistributions of source code must retain the above copyright 128c424e8eSdownsj.\" notice, this list of conditions and the following disclaimer. 138c424e8eSdownsj.\" 2. Redistributions in binary form must reproduce the above copyright 148c424e8eSdownsj.\" notice, this list of conditions and the following disclaimer in the 158c424e8eSdownsj.\" documentation and/or other materials provided with the distribution. 161ef0d710Smillert.\" 3. Neither the name of the University nor the names of its contributors 178c424e8eSdownsj.\" may be used to endorse or promote products derived from this software 188c424e8eSdownsj.\" without specific prior written permission. 198c424e8eSdownsj.\" 208c424e8eSdownsj.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 218c424e8eSdownsj.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 228c424e8eSdownsj.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 238c424e8eSdownsj.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 248c424e8eSdownsj.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 258c424e8eSdownsj.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 268c424e8eSdownsj.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 278c424e8eSdownsj.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 288c424e8eSdownsj.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 298c424e8eSdownsj.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 308c424e8eSdownsj.\" SUCH DAMAGE. 318c424e8eSdownsj.\" 328c424e8eSdownsj.\" @(#)fsck.8 8.3 (Berkeley) 11/29/94 338c424e8eSdownsj.\" 34*41ce3b17Snaddy.Dd $Mdocdate: March 31 2022 $ 35bcc85194Sdownsj.Dt FSCK_EXT2FS 8 36bcc85194Sdownsj.Os 378c424e8eSdownsj.Sh NAME 388c424e8eSdownsj.Nm fsck_ext2fs 39bcc85194Sdownsj.Nd Second Extended File System consistency check and interactive repair 408c424e8eSdownsj.Sh SYNOPSIS 417349792aSaaron.Nm fsck_ext2fs 42139a4000Sjaredy.Op Fl dfnpy 438c424e8eSdownsj.Op Fl b Ar block# 448c424e8eSdownsj.Op Fl m Ar mode 45fd4c6d5dSderaadt.Ar filesystem 468c424e8eSdownsj.Sh DESCRIPTION 4758aefd4bSaaron.Nm 48fd4c6d5dSderaadtperforms interactive file system consistency checks and repairs 49fd4c6d5dSderaadtthe filesystem specified. 509615e1d4SaaronIt is normally invoked from 518c424e8eSdownsj.Xr fsck 8 . 528c424e8eSdownsj.Pp 538c424e8eSdownsjThe kernel takes care that only a restricted class of innocuous file system 548c424e8eSdownsjinconsistencies can happen unless hardware or software failures intervene. 558c424e8eSdownsjThese are limited to the following: 568c424e8eSdownsj.Pp 57139a4000Sjaredy.Bl -item -compact -offset indent 588c424e8eSdownsj.It 598c424e8eSdownsjUnreferenced inodes 608c424e8eSdownsj.It 618c424e8eSdownsjLink counts in inodes too large 628c424e8eSdownsj.It 638c424e8eSdownsjMissing blocks in the free map 648c424e8eSdownsj.It 658c424e8eSdownsjBlocks in the free map also in files 668c424e8eSdownsj.It 678c424e8eSdownsjCounts in the super-block wrong 688c424e8eSdownsj.El 698c424e8eSdownsj.Pp 708c424e8eSdownsjThese are the only inconsistencies that 7158aefd4bSaaron.Nm 7295675cd5Saaronin 7395675cd5Saaron.Dq preen 748c424e8eSdownsjmode (with the 758c424e8eSdownsj.Fl p 768c424e8eSdownsjoption) will correct; if it encounters other inconsistencies, it exits 778c424e8eSdownsjwith an abnormal return status. 788c424e8eSdownsjFor each corrected inconsistency one or more lines will be printed 798c424e8eSdownsjidentifying the file system on which the correction will take place, 809615e1d4Saaronand the nature of the correction. 819615e1d4SaaronAfter successfully correcting a file system, 8258aefd4bSaaron.Nm 838c424e8eSdownsjwill print the number of files on that file system 848c424e8eSdownsjand the number of used and free blocks. 858c424e8eSdownsj.Pp 868c424e8eSdownsjIf sent a 878c424e8eSdownsj.Dv QUIT 888c424e8eSdownsjsignal, 8958aefd4bSaaron.Nm 908c424e8eSdownsjwill finish the file system checks, then exit with an abnormal return status. 918c424e8eSdownsj.Pp 928c424e8eSdownsjWithout the 938c424e8eSdownsj.Fl p 948c424e8eSdownsjoption, 9558aefd4bSaaron.Nm 96fd4c6d5dSderaadtaudits and interactively repairs inconsistent conditions for the filesystem. 97139a4000SjaredyIf the file system is inconsistent, the operator is prompted for concurrence 988c424e8eSdownsjbefore each correction is attempted. 998c424e8eSdownsjIt should be noted that some of the corrective actions which are not 1008c424e8eSdownsjcorrectable under the 1018c424e8eSdownsj.Fl p 1028c424e8eSdownsjoption will result in some loss of data. 1038c424e8eSdownsjThe amount and severity of data lost may be determined from the diagnostic 1048c424e8eSdownsjoutput. 1058c424e8eSdownsjThe default action for each consistency correction 1068c424e8eSdownsjis to wait for the operator to respond 1075eaf1a72Saaron.Dq yes 1088c424e8eSdownsjor 1095eaf1a72Saaron.Dq no . 1105eaf1a72SaaronIf the operator does not have write permission on the file system, 11158aefd4bSaaron.Nm 1128c424e8eSdownsjwill default to a 1138c424e8eSdownsj.Fl n 1148c424e8eSdownsjaction. 1158c424e8eSdownsj.Pp 1168c424e8eSdownsjThe following flags are interpreted by 1175eaf1a72Saaron.Nm fsck_ext2fs : 1188c424e8eSdownsj.Bl -tag -width indent 119b24688ffSderaadt.It Fl b Ar block# 1208c424e8eSdownsjUse the block specified immediately after the flag as 1219615e1d4Saaronthe super block for the file system. 1229615e1d4SaaronBlock 8193 is usually an alternate super block. 1238c424e8eSdownsj.It Fl d 1248c424e8eSdownsjPrint debugging output. 1258c424e8eSdownsj.It Fl f 126fd4c6d5dSderaadtForce checking of the filesystem. 1279615e1d4SaaronNormally, if a file system is cleanly unmounted, the kernel will set a 1288c424e8eSdownsj.Dq clean flag 1295eaf1a72Saaronin the file system superblock and 1308c424e8eSdownsj.Nm 1319615e1d4Saaronwill not check the file system. 1329615e1d4SaaronThis option forces 1338c424e8eSdownsj.Nm 1348c424e8eSdownsjto check the file system, regardless of the state of the clean flag. 135b24688ffSderaadt.It Fl m Ar mode 136b24688ffSderaadtUse the 137b24688ffSderaadt.Ar mode 138b24688ffSderaadtspecified in octal as the 1398c424e8eSdownsjpermission bits to use when creating the 1408c424e8eSdownsj.Pa lost+found 1418c424e8eSdownsjdirectory rather than the default 1777. 1428c424e8eSdownsjIn particular, systems that do not wish to have lost files accessible 1438c424e8eSdownsjby all users on the system should use a more restrictive 1448c424e8eSdownsjset of permissions such as 700. 1458c424e8eSdownsj.It Fl n 1465eaf1a72SaaronAssume a 1475eaf1a72Saaron.Dq no 1485eaf1a72Saaronresponse to all questions asked by 14958aefd4bSaaron.Nm 1508c424e8eSdownsjexcept for 15195675cd5Saaron.Dq CONTINUE? , 152139a4000Sjaredywhich is assumed to be affirmative. 153fd4c6d5dSderaadtThe filesystem will not be opened for writing. 154139a4000SjaredyThis is the default for file systems to be checked that are 155139a4000Sjaredyconcurrently mounted writable. 1568c424e8eSdownsj.It Fl p 15795675cd5SaaronSpecify 15895675cd5Saaron.Dq preen 15995675cd5Saaronmode, described above. 1608c424e8eSdownsj.It Fl y 1615eaf1a72SaaronAssume a 1625eaf1a72Saaron.Dq yes 1635eaf1a72Saaronresponse to all questions asked by 1648c424e8eSdownsj.Nm fsck_ext2fs ; 1658c424e8eSdownsjthis should be used with great caution as this is a free license 1668c424e8eSdownsjto continue after essentially unlimited trouble has been encountered. 1678c424e8eSdownsj.El 1688c424e8eSdownsj.Pp 169fae40a5eSjmcIf neither of the 170fae40a5eSjmc.Fl y 171fae40a5eSjmcor 172fae40a5eSjmc.Fl n 173fae40a5eSjmcoptions are specified, the user may force 174fae40a5eSjmc.Nm 175fae40a5eSjmcto assume an answer of 176fae40a5eSjmc.Dq yes 177fae40a5eSjmcto all the remaining questions by replying to a question with a value of 178fae40a5eSjmc.Dq F . 179fae40a5eSjmc.Pp 1808c424e8eSdownsjInconsistencies checked are as follows: 1815eaf1a72Saaron.Pp 1828679fc4cSjmc.Bl -enum -compact 1838c424e8eSdownsj.It 184139a4000SjaredyBlocks claimed more than once by inodes or the free map. 1858c424e8eSdownsj.It 1868c424e8eSdownsjBlocks claimed by an inode outside the range of the file system. 1878c424e8eSdownsj.It 1888c424e8eSdownsjIncorrect link counts. 1898c424e8eSdownsj.It 1908c424e8eSdownsjSize checks: 191139a4000Sjaredy.Bl -item -compact -offset indent 1928c424e8eSdownsj.It 1938c424e8eSdownsjDirectory size not a multiple of file system block size. 1948c424e8eSdownsj.It 1958c424e8eSdownsjPartially truncated file. 1968c424e8eSdownsj.El 1978c424e8eSdownsj.It 1988c424e8eSdownsjBad inode format. 1998c424e8eSdownsj.It 2008c424e8eSdownsjBlocks not accounted for anywhere. 2018c424e8eSdownsj.It 2028c424e8eSdownsjDirectory checks: 203139a4000Sjaredy.Bl -item -compact -offset indent 2048c424e8eSdownsj.It 2058c424e8eSdownsjFile pointing to unallocated inode. 2068c424e8eSdownsj.It 2078c424e8eSdownsjInode number out of range. 2088c424e8eSdownsj.It 2098c424e8eSdownsjDot or dot-dot not the first two entries of a directory 2108c424e8eSdownsjor having the wrong inode number. 2118c424e8eSdownsj.El 2128c424e8eSdownsj.It 2138c424e8eSdownsjSuper Block checks: 214139a4000Sjaredy.Bl -item -compact -offset indent 2158c424e8eSdownsj.It 2168c424e8eSdownsjMore blocks for inodes than there are in the file system. 2178c424e8eSdownsj.It 2188c424e8eSdownsjBad free block map format. 2198c424e8eSdownsj.It 2208c424e8eSdownsjTotal free block and/or free inode count incorrect. 2218c424e8eSdownsj.El 2228c424e8eSdownsj.El 2238c424e8eSdownsj.Pp 2248c424e8eSdownsjOrphaned files and directories (allocated but unreferenced) are, 2258c424e8eSdownsjwith the operator's concurrence, reconnected by 2268c424e8eSdownsjplacing them in the 2278c424e8eSdownsj.Pa lost+found 2288c424e8eSdownsjdirectory. 2298c424e8eSdownsjThe name assigned is the inode number. 2308c424e8eSdownsjIf the 2318c424e8eSdownsj.Pa lost+found 2328c424e8eSdownsjdirectory does not exist, it is created. 233*41ce3b17SnaddyIf there is insufficient space, its size is increased. 2348c424e8eSdownsj.Pp 2358c424e8eSdownsjBecause of inconsistencies between the block device and the buffer cache, 2368c424e8eSdownsjthe raw device should always be used. 2378c424e8eSdownsj.Sh DIAGNOSTICS 2388c424e8eSdownsjThe diagnostics produced by 23958aefd4bSaaron.Nm 2408c424e8eSdownsjare fully enumerated and explained in Appendix A of 2418c424e8eSdownsj.Rs 242139a4000Sjaredy.%T "Fsck_ffs \- The UNIX File System Check Program" 2438c424e8eSdownsj.Re 2448c424e8eSdownsj.Sh SEE ALSO 2458c424e8eSdownsj.Xr fs 5 , 2467acc01d2Saaron.Xr fstab 5 , 2477acc01d2Saaron.Xr fsck 8 , 248139a4000Sjaredy.Xr mount_ext2fs 8 , 249139a4000Sjaredy.Xr rc 8 250