ArticleslgStudy

computer science

Fsck

Fsck is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Fsck rather than just read about it. In short: The system utility fsck (file system check) is a tool for checking the consistency of a file system in Unix and Unix-like operating systems, such as Linux, macOS, and FreeBSD. The equivalent programs for MS-DOS and Windows are CHKDSK, SFC, and SCANDISK.

Fsck — main illustration
Fsck — illustration

Key takeaways

  • Fsck belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Fsck to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Fsck from memory before moving on to harder problems.

Reference excerpt

The system utility fsck (file system check) is a tool for checking the consistency of a file system in Unix and Unix-like operating systems, such as Linux, macOS, and FreeBSD. The equivalent programs for MS-DOS and Windows are CHKDSK, SFC, and SCANDISK.

Use Generally, fsck is run either automatically at boot time, or manually by the system administrator. The command works directly on data structures stored on disk, which are internal and specific to the particular file system in use - so an fsck command tailored to the file system is generally required. The exact behaviors of various fsck implementations vary, but they typically follow a common order of internal operations and provide a common command-line interface to the user. On modern systems, fsck simply detects the type of filesystem and calls the specialized fsck.type (Linux) or fsck_type (BSD, macOS) program for each type. Most fsck utilities provide options for either interactively repairing damaged file systems (the user must decide how to fix specific problems), automatically deciding how to fix specific problems (so the user does not have to answer any questions), or reviewing the problems that need to be resolved on a file system without actually fixing them. Partially recovered files where the original file name cannot be reconstructed are typically recovered to a "lost+found" directory that is stored at the root of the file system. A system administrator can also run fsck manually if they believe there is a problem with the file system. The file system is normally checked while unmounted, mounted read-only, or with the system in a special maintenance mode.

Boot time As at boot time fsck is expected to run without user intervention, it generally defaults to not perform any destructive operations. This may be in the form of a read-only check (failing whenever issues are found), or more commonly, a "preen" -p mode that only fixes innocuous issues commonly found after an unclean shutdown (i.e., crash, power fail). ext2/3/4 offers an option to force a boot-time check after a specified number of mounts, so that periodic checking can be done. Some modern file systems do not require fsck to be at boot after an unclean shutdown. Some examples are:

XFS, a journaling file system. It has a dummy fsck which does nothing and an actual xfs_repair tool to be run when problems are suspected. UFS2 file system in FreeBSD, which can delay the check to background if soft updates are enabled. As a result, it is usually not necessary to wait for fsck to finish before accessing the disk. This design is reflected by the -F flag used at boot. ZFS and Btrfs, two full copy-on-write file systems. They avoid in-place changes to assure levels of consistency similar to a journal. They also provide a dummy fsck. btrfs-check is still available to check for suspected problems in filesystem structure (e.g., when a software bug or hardware issue is suspected). Independent of checking the file system structure, modern file systems may offer a data scrubbing tool to check for silent corruption in stored data against a mirror or a checksum. Scrubs tend to be slow as they cover all data on a disk, but periodic runs can defend against data rot and help identify failing drives.

History fsck first appeared in the Bell Labs "V7 addendum tape" of 1980. It turned into its modern wrapper form in NetBSD 1.3 (1998). fsck is not defined by any extant standard, but the primitive non-wrapper form is present in the 1995 draft Systems Management: File System and Scheduling Utilities (FSSU) from X/Open.

As a minced oath The severity of file system corruption led to the terms "fsck" and "fscked" becoming used among Unix system administrators as a minced oath for "fuck" and "fucked". It is unclear whether this usage was cause or effect, as a report from a question and answer session at USENIX 1998 claims that "fsck" originally had a different name:

Dennis Ritchie: "So fsck was originally called something else" Question: "What was it called?" Dennis Ritchie: "Well, the second letter was different" That story was confirmed by Rob Pike on the Mastodon social network on December 17, 2023:

Ted Kowalski, username frodo, may he rest in peace, was the original author, just down the hall from my office in Murray Hill, and his name for the program had a 'u' where there is now an 's'. Management made him change it for distribution, but they couldn't make him change his pronunciation.

Examples The following example checks the file system configured to be mounted on /usr partition; the file system needs to be unmounted first:

The following example checks the Linux JFS file system on a mdadm software RAID device:

See also List of Unix commands List of file systems e2fsprogs, which includes the e2fsck utility, standard on many Linux distributions scrub, Oracle Solaris ZFS file system checking utility

References

External links man fsck Checking and Repairing File system with fsck Jargon File entry: fscking The many faces of fsck

Illustrations

Fsck illustration

Worked examples

Example 1 — a first encounter with Fsck

Start with the simplest possible case. Write down what Fsck claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Fsck before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Fsck ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Fsck

In research
Fsck appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Fsck in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Fsck is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer file systems, Hard disk software, Unix file system-related software, so understanding it makes those chapters shorter.
In everyday life
Look for Fsck outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Fsck” →

How to study Fsck in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Fsck means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Fsck out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Fsck in simple terms?

The system utility fsck (file system check) is a tool for checking the consistency of a file system in Unix and Unix-like operating systems, such as Linux, macOS, and FreeBSD. The equivalent programs for MS-DOS and Windows are CHKDSK, SFC, and SCANDISK.

Why does Fsck matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Fsck?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Fsck.

Tags

  • Computer file systems
  • Hard disk software
  • Unix file system-related software

Keep exploring