FSCK_FFS(8)
okay bestie, welcome to fsck_ffs(8) / fsck_ufs(8) β the System Manager's Manual entry for file system consistency check and interactive repair. she's thorough, she's iconic, and she's about to check ur vibes (and ur superblocks) π
β¨
π NAME π
fsck_ffs, fsck_ufs β file system consistency check and interactive repair π
β¨ SYNOPSIS β¨
fsck_ffs [-BCdEFfnpRrSyZz] [-b block] [-c level] [-m mode] filesystem
...
no cap, that's the whole shape of it β flags, then one or more filesystems π«Ά
π DESCRIPTION π
so like, the specified disk partitions and/or file systems get checked, obviously. in "preen" or "check clean" mode, the clean flag of each file system's superblock is examined and only those file systems that are not marked clean are checked. file systems are marked clean when they're unmounted, when they've been mounted read-only, or when fsck_ffs runs on them successfully. and if the -f option is specified? the file systems will be checked regardless of the state of their clean flag. periodt.
the kernel takes care that only a restricted class of innocuous file system inconsistencies can happen β unless hardware or software failures intervene, which, π. these are limited to the following:
- Unreferenced inodes
- Link counts in inodes too large
- Missing blocks in the free map
- Blocks in the free map also in files
- Counts in the super-block wrong
these are the only inconsistencies that fsck_ffs with the -p option will correct. if it encounters other inconsistencies, it exits with an abnormal return status and an automatic reboot will then fail. for each corrected inconsistency, one or more lines will be printed identifying the file system on which the correction will take place, and the nature of the correction. after successfully correcting a file system, fsck_ffs will print the number of files on that file system, the number of used and free blocks, and the percentage of fragmentation. it's giving receipts π
if sent a QUIT signal, fsck_ffs will finish the file system checks, then exit with an abnormal return status that causes an automatic reboot to fail. this is useful when you want to finish the file system checks during an automatic reboot, but do not want the machine to come up multiuser after the checks complete. lowkey a serve.
if fsck_ffs receives a SIGINFO signal (see the status argument for stty(1)), a line will be written to the standard output indicating the name of the device currently being checked, the current phase number, and phase-specific progress information. she's keeping u posted π«Ά
without the -p option, fsck_ffs audits and interactively repairs inconsistent conditions for file systems. if the file system is inconsistent, the operator is prompted for concurrence before each correction is attempted. it should be noted that some of the corrective actions which are not correctable under the -p option will result in some loss of data π. the amount and severity of data lost may be determined from the diagnostic output. the default action for each consistency correction is to wait for the operator to respond yes or no. if the operator does not have write permission on the file system, fsck_ffs will default to a -n action.
the following flags are interpreted by fsck_ffs:
π¦ OPTIONS π¦
-Bβ a check is done on the specified and possibly active file system π. the set of corrections that can be done is limited to those done when running in preen mode (see the-pflag). if unexpected errors are found, the file system is marked as needing a foreground check andfsck_ffsexits without attempting any further cleaning.-bβ use the block specified immediately after the flag as the super block for the file system. an alternate super block is usually located at block32for UFS1, and block192for UFS2.
see the -N flag of newfs(8).
-Cβ check if the file system was dismounted cleanly. if so, skip file system checks (like "preen"). however, if the file system was not cleanly dismounted, do full checks, as iffsck_ffswas invoked without-C. she's checking the vibes first π-cβ convert the file system to the specified level. note that the level of a file system can only be raised β¬οΈ. there are currently four levels defined:0β the file system is in the old (static table) format.1β the file system is in the new (dynamic table) format.2β the file system supports 32-bit uid's and gid's, short symbolic links are stored in the inode, and directories have an added field showing the file type.3β ifmaxcontigis greater than one, build the free segment maps to aid in finding contiguous sets of blocks. ifmaxcontigis equal to one, delete any existing segment maps.
in interactive mode, fsck_ffs will list the conversion to be made and ask whether the conversion should be done. if a negative answer is given, no further operations are done on the file system. in preen mode, the conversion is listed and done if possible without user interaction. conversion in preen mode is best used when all the file systems are being converted at once. the format of a file system can be determined from the first line of output from dumpfs(8).
this option implies the -f flag.
-dβ enable debugging messages πβ¨-Eβ clear unallocated blocks, notifying the underlying device that they are not used and that their contents may be discarded. this is useful for filesystems which have been mounted on systems without TRIM support, or with TRIM support disabled, as well as filesystems which have been copied from one device to another. no cap, very glow-up of them.
see the -E and -t flags of newfs(8), and the -t flag of tunefs(8).
-Fβ determine whether the file system needs to be cleaned immediately in foreground, or if its cleaning can be deferred to background. to be eligible for background cleaning it must have been running with soft updates, not have been marked as needing a foreground check, and be mounted and writable when the background check is to be done. if these conditions are met, thenfsck_ffsexits with a zero exit status. otherwise it exits with a non-zero exit status. if the file system is clean, it will exit with a non-zero exit status so that the clean status of the file system can be verified and reported during the foreground checks. note that when invoked with the-Fflag, no cleanups are done β the only thingfsck_ffsdoes is determine whether a foreground or background check is needed and exit with an appropriate status code. she's just giving u the tea, not doing the chores π«-fβ forcefsck_ffsto check 'clean' file systems when preening. like, even if she says she's fine, we're checking.-mβ use the mode specified in octal immediately after the flag as the permission bits to use when creating thelost+founddirectory rather than the default1777. in particular, systems that do not wish to have lost files accessible by all users on the system should use a more restrictive set of permissions such as700. privacy please π-nβ assume a no response to all questions asked byfsck_ffs, except for 'CONTINUE?', which is assumed to be affirmative; do not open the file system for writing. we're just looking, not touching π-pβ preen file systems (see above).-Rβ instructfsck_ffsto restart itself if it encounters certain errors that warrant another run. it will limit itself to a maximum of10restarts in a given run in order to avoid an endless loop with extremely corrupted filesystems ππ-rβ free up excess unused inodes. decreasing the number of preallocated inodes reduces the running time of future runs offsck_ffsand frees up space that can allocated to files. the-roption is ignored when running in preen mode.-Sβ surrender on error π³οΈ. with this flag enabled, a hard error returned on disk i/o will causefsck_ffsto abort instead of continuing on and possibly tripping over more i/o errors. sometimes u just gotta say "not today".-yβ assume a yes response to all questions asked byfsck_ffs; this should be used with great caution β οΈ as this is a free license to continue after essentially unlimited trouble has been encountered. like, she will simply agree to everything. be so fr.-Zβ similar to-E, but overwrites unused blocks with zeroes. if both-Eand-Zare specified, blocks are first zeroed and then erased. order matters, bestie β¨-zβ clear unused directory space. the cleared space includes deleted file names and name padding. bye bye leftovers π
πΈ INCONSISTENCIES CHECKED πΈ
the inconsistencies checked are as follows:
- Blocks claimed by more than one inode or the free map.
- Blocks claimed by an inode outside the range of the file system.
- Incorrect link counts.
- Size checks:
- Directory size not a multiple of
DIRBLKSIZ. - Partially truncated file.
- Directory size not a multiple of
- Bad inode format.
- Blocks not accounted for anywhere.
- Directory checks:
- File pointing to unallocated inode.
- Inode number out of range.
- Directories with unallocated blocks (holes).
- Dot or dot-dot not the first two entries of a directory or having the wrong inode number.
- Super Block checks:
- More blocks for inodes than there are in the file system.
- Bad free block map format.
- Total free block and/or free inode count incorrect.
orphaned files and directories (allocated but unreferenced) are, with the operator's concurrence, reconnected by placing them in the lost+found directory. the name assigned is the inode number. if the lost+found directory does not exist, it is created. if there is insufficient space, its size is increased. she's literally fostering them π₯Ή
the full foreground fsck_ffs checks for many more problems that may occur after an unrecoverable disk write error. thus, it is recommended that you perform foreground fsck_ffs on your systems periodically and whenever you encounter unrecoverable disk write errors or file-system-related panics. like a little checkup, bestie π©Ίπ
π FILES π
/etc/fstabβ contains default list of file systems to check.
π EXIT STATUS π
Okay bestie, so fsck_ffs exits with 0 when everything's chill, and anything >0 means something went sideways. Iconic.
And here's the tea on the specific non-zero exit values you might catch (iykyk):
1β Usage error. Translation: your command arguments were missing or just straight-up invalid, bestie. Try again with actual words.2β You used the-poption and aSIGQUITcame through, which is the system's way of saying "hey, take me back to single user mode after this file system check, thanks." π3β The file system superblock cannot be read. Lowkey could mean the file system device doesn't exist, or it's just not ready yet. Not it. π4β A mounted file system was modified. Bestie, the system should be rebooted. Periodt.5β You used the-Boption but soft updates are not enabled on the file system. Bummer.6β You used the-Boption and the kernel lacks needed support. So the kernel kinda ghosted you on that one. π7β You used the-Foption and the file system is clean. Honestly? Slay. Nothing to do here.8β General error exit. The catch-all. The main character of bad outcomes.16β The file system could not be completely repaired. But don't spiral! It may be able to be repaired by runningfsck_ffson the file system again. Second time's the charm, fr fr. β¨
π DIAGNOSTICS π
The diagnostics that fsck_ffs produces are fully enumerated and explained in Appendix A of Fsck - The UNIX File System Check Program. Like, every single one. Go read it, bestie, it's giving essential lore. π
π SEE ALSO π
πΈ HISTORY πΈ
So a fsck utility appeared in 4.0BSD β old money, honestly. π Then it became fsck_ffs in FreeBSD 5.0, which is when the filesystem independent wrapper came in as fsck. The way that stuff evolvesβ¦ iconic behavior. π¦
And that's the whole page, bestie β tea's all spilled, no cap. π«Ά This lil' number is from the Debian fam, dated November 17, 2023, and it's filed in the manuals as FSCK_FFS(8) β section 8, where the admin tools live. Go fix those file systems. You got this. π
β¨π
π¦ where this page comes from
- freebsd 15.1: base 15.1
- Copyright (c) 1980, 1989, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms