| 1 | .\" Copyright (c) 1980, 1989 Regents of the University of California. |
| 2 | .\" All rights reserved. The Berkeley software License Agreement |
| 3 | .\" specifies the terms and conditions for redistribution. |
| 4 | .\" |
| 5 | .\" @(#)fsck.8 6.8 (Berkeley) %G% |
| 6 | .\" |
| 7 | .TH FSCK 8 "" |
| 8 | .UC 4 |
| 9 | .de us |
| 10 | \\$1\l'|0\(ul' |
| 11 | .. |
| 12 | .SH NAME |
| 13 | fsck \- file system consistency check and interactive repair |
| 14 | .SH SYNOPSIS |
| 15 | .B fsck |
| 16 | .B \-p |
| 17 | [ |
| 18 | .B \-m |
| 19 | mode |
| 20 | ] |
| 21 | .br |
| 22 | .B fsck |
| 23 | [ |
| 24 | .B \-b |
| 25 | block# |
| 26 | ] [ |
| 27 | .B \-c |
| 28 | ] [ |
| 29 | .B \-y |
| 30 | ] [ |
| 31 | .B \-n |
| 32 | ] [ |
| 33 | .B \-m |
| 34 | mode |
| 35 | ] [ |
| 36 | filesystem |
| 37 | ] ... |
| 38 | .SH DESCRIPTION |
| 39 | The first form of |
| 40 | .I fsck |
| 41 | preens a standard set of filesystems or the specified file systems. |
| 42 | It is normally used in the script |
| 43 | .B /etc/rc |
| 44 | during automatic reboot. |
| 45 | Here |
| 46 | .I fsck |
| 47 | reads the table |
| 48 | .B /etc/fstab |
| 49 | to determine which file systems to check. |
| 50 | Only partitions in fstab that are mounted ``rw,'' ``rq'' or ``ro'' |
| 51 | and that have non-zero pass number are checked. |
| 52 | Filesystems with pass number 1 (normally just the root filesystem) |
| 53 | are checked one at a time. |
| 54 | When pass 1 completes, all remaining filesystems are checked, |
| 55 | running one process per disk drive. |
| 56 | The disk drive containing each filesystem is inferred from the longest prefix |
| 57 | of the device name that ends in a digit; the remaining characters are assumed |
| 58 | to be the partition designator. |
| 59 | .PP |
| 60 | The system takes care that only a restricted class of innocuous |
| 61 | inconsistencies can happen unless hardware or software failures intervene. |
| 62 | These are limited to the following: |
| 63 | .IP |
| 64 | Unreferenced inodes |
| 65 | .ns |
| 66 | .IP |
| 67 | Link counts in inodes too large |
| 68 | .ns |
| 69 | .IP |
| 70 | Missing blocks in the free map |
| 71 | .ns |
| 72 | .IP |
| 73 | Blocks in the free map also in files |
| 74 | .ns |
| 75 | .IP |
| 76 | Counts in the super-block wrong |
| 77 | .PP |
| 78 | These are the only inconsistencies that |
| 79 | .I fsck |
| 80 | with the |
| 81 | .B \-p |
| 82 | option will correct; if it encounters other inconsistencies, it exits |
| 83 | with an abnormal return status and an automatic reboot will then fail. |
| 84 | For each corrected inconsistency one or more lines will be printed |
| 85 | identifying the file system on which the correction will take place, |
| 86 | and the nature of the correction. After successfully correcting a file |
| 87 | system, |
| 88 | .I fsck |
| 89 | will print the number of files on that file system, |
| 90 | the number of used and free blocks, |
| 91 | and the percentage of fragmentation. |
| 92 | .PP |
| 93 | If sent a QUIT signal, |
| 94 | .I fsck |
| 95 | will finish the file system checks, then exit with an abnormal |
| 96 | return status that causes an automatic reboot to fail. |
| 97 | This is useful when to finish the file system checks during an automatic reboot, |
| 98 | but do not want the machine to come up multiuser after the checks complete. |
| 99 | .PP |
| 100 | Without the |
| 101 | .B \-p |
| 102 | option, |
| 103 | .I fsck |
| 104 | audits and interactively repairs inconsistent conditions for file systems. |
| 105 | If the file system is inconsistent the operator is prompted for concurrence |
| 106 | before each correction is attempted. |
| 107 | It should be noted that some of the corrective actions which are not |
| 108 | correctable under the |
| 109 | .B \-p |
| 110 | option will result in some loss of data. |
| 111 | The amount and severity of data lost may be determined from the diagnostic |
| 112 | output. |
| 113 | The default action for each consistency correction |
| 114 | is to wait for the operator to respond \fByes\fP or \fBno\fP. |
| 115 | If the operator does not have write permission on the file system |
| 116 | .I fsck |
| 117 | will default to a |
| 118 | .BR "\-n " action. |
| 119 | .PP |
| 120 | .I Fsck |
| 121 | has more consistency checks than |
| 122 | its predecessors |
| 123 | .IR "check, dcheck, fcheck, " "and" " icheck" |
| 124 | combined. |
| 125 | .PP |
| 126 | The following flags are interpreted by |
| 127 | .I fsck. |
| 128 | .TP 6 |
| 129 | .B \-b |
| 130 | Use the block specified immediately after the flag as |
| 131 | the super block for the file system. Block 32 is usually |
| 132 | an alternate super block. |
| 133 | .TP 6 |
| 134 | .B \-l |
| 135 | Limit the number of parallel checks to the number specified in the following |
| 136 | argument. |
| 137 | By default, the limit is the number of disks, running one process per disk. |
| 138 | If a smaller limit is given, the disks are checked round-robin, one filesystem |
| 139 | at a time. |
| 140 | .TP 6 |
| 141 | .B \-m |
| 142 | Use the mode specified in octal immediately after the flag as the |
| 143 | permission bits to use when creating the lost+found directory |
| 144 | rather than the default 1777. |
| 145 | In particular, systems that do not wish to have lost files accessible |
| 146 | by all users on the system should use a more restrictive |
| 147 | set of permissions such as 700. |
| 148 | .TP 6 |
| 149 | .B \-y |
| 150 | Assume a yes response to all questions asked by |
| 151 | .IR fsck ; |
| 152 | this should be used with great caution as this is a free license |
| 153 | to continue after essentially unlimited trouble has been encountered. |
| 154 | .TP 6 |
| 155 | .B \-n |
| 156 | Assume a no response to all questions asked by |
| 157 | .I fsck |
| 158 | except for ``CONTINUE?'', which is assumed to be affirmative; |
| 159 | do not open the file system for writing. |
| 160 | .TP 6 |
| 161 | .B \-c |
| 162 | If the file system is in the old (static table) format, |
| 163 | convert it to the new (dynamic table) format. |
| 164 | If the file system is in the new format, |
| 165 | convert it to the old format provided the old format |
| 166 | can support the filesystem configuration. |
| 167 | In interactive mode, |
| 168 | .I fsck |
| 169 | will list the direction the conversion is to be made |
| 170 | and ask whether the conversion should be done. |
| 171 | If a negative answer is given, |
| 172 | no further operations are done on the filesystem. |
| 173 | In preen mode, |
| 174 | the direction of the conversion is listed and done if |
| 175 | possible without user interaction. |
| 176 | Conversion in preen mode is best used when all the file systems |
| 177 | are being converted at once. |
| 178 | The format of a file system can be determined from the |
| 179 | first line of output from |
| 180 | .IR dumpfs (8). |
| 181 | .PP |
| 182 | If no filesystems are given to |
| 183 | .I fsck |
| 184 | then a default list of file systems is read from |
| 185 | the file |
| 186 | .BR /etc/fstab . |
| 187 | .PP |
| 188 | .ne 10 |
| 189 | Inconsistencies checked are as follows: |
| 190 | .TP 6 |
| 191 | 1. |
| 192 | Blocks claimed by more than one inode or the free map. |
| 193 | .br |
| 194 | .br |
| 195 | .ns |
| 196 | .TP 6 |
| 197 | 2. |
| 198 | Blocks claimed by an inode outside the range of the file system. |
| 199 | .br |
| 200 | .br |
| 201 | .ns |
| 202 | .TP 6 |
| 203 | 3. |
| 204 | Incorrect link counts. |
| 205 | .br |
| 206 | .br |
| 207 | .ns |
| 208 | .TP 6 |
| 209 | 4. |
| 210 | Size checks: |
| 211 | .br |
| 212 | .ns |
| 213 | .IP "" 12 |
| 214 | Directory size not of proper format. |
| 215 | .br |
| 216 | Partially truncated file. |
| 217 | .br |
| 218 | .br |
| 219 | .ns |
| 220 | .TP 6 |
| 221 | 5. |
| 222 | Bad inode format. |
| 223 | .br |
| 224 | .br |
| 225 | .ns |
| 226 | .TP 6 |
| 227 | 6. |
| 228 | Blocks not accounted for anywhere. |
| 229 | .br |
| 230 | .br |
| 231 | .ns |
| 232 | .TP 6 |
| 233 | 7. |
| 234 | Directory checks: |
| 235 | .br |
| 236 | .br |
| 237 | .ns |
| 238 | .IP "" 12 |
| 239 | File pointing to unallocated inode. |
| 240 | .br |
| 241 | Inode number out of range. |
| 242 | .br |
| 243 | Dot or dot-dot not the first two entries of a directory |
| 244 | or having the wrong inode number. |
| 245 | .br |
| 246 | .br |
| 247 | .ns |
| 248 | .TP 6 |
| 249 | 8. |
| 250 | Super Block checks: |
| 251 | .br |
| 252 | .br |
| 253 | .ns |
| 254 | .IP "" 12 |
| 255 | More blocks for inodes than there are in the file system. |
| 256 | .br |
| 257 | .br |
| 258 | .ns |
| 259 | .TP 6 |
| 260 | 9. |
| 261 | Bad free block map format. |
| 262 | .br |
| 263 | .br |
| 264 | .ns |
| 265 | .TP 6 |
| 266 | 10. |
| 267 | Total free block and/or free inode count incorrect. |
| 268 | .PP |
| 269 | Orphaned files and directories (allocated but unreferenced) are, |
| 270 | with the operator's concurrence, reconnected by |
| 271 | placing them in the |
| 272 | .B lost+found |
| 273 | directory. |
| 274 | The name assigned is the inode number. |
| 275 | If the |
| 276 | .I lost+found |
| 277 | directory does not exist, it is created. |
| 278 | If there is insufficient space its size is increased. |
| 279 | .PP |
| 280 | Because of inconsistencies between the block device and the buffer cache, |
| 281 | the raw device should always be used. |
| 282 | .SH FILES |
| 283 | .br |
| 284 | .ns |
| 285 | .TP 21 |
| 286 | /etc/fstab |
| 287 | contains default list of file systems to check. |
| 288 | .SH DIAGNOSTICS |
| 289 | The diagnostics produced by |
| 290 | .I fsck |
| 291 | are fully enumerated and explained in Appendix A of |
| 292 | ``Fsck \- The UNIX File System Check Program'' (SMM:5). |
| 293 | .SH "SEE ALSO" |
| 294 | fstab(5), |
| 295 | fs(5), |
| 296 | fsdb(8), |
| 297 | newfs(8), |
| 298 | mkfs(8), |
| 299 | reboot(8) |