Fsck: Difference between revisions

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
imported>Citation bot
Added date. | Use this bot. Report bugs. | Suggested by Whoop whoop pull up | #UCB_webform
 
imported>GnocchiFan
m As a minced oath: subheading should not have wikilink
 
(One intermediate revision by one other user not shown)
Line 27: Line 27:


=== Boot time ===
=== Boot time ===
As 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" {{code|-p}} mode that only fixes innocuous issues commonly found after an unclean shutdown (i.e. crash, power fail).<ref name=FreeBSD/>  
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" {{code|-p}} mode that only fixes innocuous issues commonly found after an unclean shutdown (i.e., crash, power fail).<ref name=FreeBSD/>  


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.<ref>{{man|8|tune2fs|Linux}}</ref>
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.<ref>{{man|8|tune2fs|Linux}}</ref>
Line 34: Line 34:
* [[XFS]], a [[journaling file system]]. It has a dummy fsck which does nothing<ref>{{man|8|fsck.xfs|Linux}}: "XFS is a journaling filesystem and performs recovery at mount(8) time if necessary"</ref> and an actual <code>xfs_repair</code> tool to be run when problems are suspected.
* [[XFS]], a [[journaling file system]]. It has a dummy fsck which does nothing<ref>{{man|8|fsck.xfs|Linux}}: "XFS is a journaling filesystem and performs recovery at mount(8) time if necessary"</ref> and an actual <code>xfs_repair</code> tool to be run when problems are suspected.
* [[Unix File System|UFS2]] file system in [[FreeBSD]], which can delay the check to background if [[soft updates]] are enabled.<ref>{{man|8|fsck_ffs|FreeBSD}}</ref> As a result, it is usually not necessary to wait for fsck to finish before accessing the disk. This design is reflected by the {{code|-F}} flag used at boot.<ref name=FreeBSD/>
* [[Unix File System|UFS2]] file system in [[FreeBSD]], which can delay the check to background if [[soft updates]] are enabled.<ref>{{man|8|fsck_ffs|FreeBSD}}</ref> As a result, it is usually not necessary to wait for fsck to finish before accessing the disk. This design is reflected by the {{code|-F}} flag used at boot.<ref name=FreeBSD/>
* [[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.<ref>{{man|8|fsck.btrfs|Linux}}, : "do nothing, successfully" "Traditional filesystems need to run their respective fsck utility in case the filesystem was not unmounted cleanly and the log needs to be replayed before mount. This is not needed for BTRFS."</ref> <code>btrfs-check</code> is still available to check for suspected problems in filesystem structure (e.g. when a software bug or hardware issue is suspected).
* [[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.<ref>{{man|8|fsck.btrfs|Linux}}, : "do nothing, successfully" "Traditional filesystems need to run their respective fsck utility in case the filesystem was not unmounted cleanly and the log needs to be replayed before mount. This is not needed for BTRFS."</ref> <code>btrfs-check</code> 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.<ref>{{cite web |last1=Swearingen |first1=Cindy |title=Scheduled Pool Scrubs in Oracle Solaris ZFS |url=https://blogs.oracle.com/solaris/post/scheduled-pool-scrubs-in-oracle-solaris-zfs}}</ref>
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.<ref>{{cite web |last1=Swearingen |first1=Cindy |title=Scheduled Pool Scrubs in Oracle Solaris ZFS |url=https://blogs.oracle.com/solaris/post/scheduled-pool-scrubs-in-oracle-solaris-zfs}}</ref>
Line 41: Line 41:
fsck first appeared in the Bell Labs "V7 addendum tape" of 1980.<ref>{{cite newsgroup |url=http://chambers.nycbug.org/pub/The_Unix_Archive/Unix_Usenet/net.bugs.usg/1986-April/000191.html |title="fgrep" doesn't always match everything it should |first=Guy |last=Harris |date=April 18, 1986 |newsgroup=net.bugs.usg}}</ref><ref>{{cite web |url=https://www.tuhs.org/cgi-bin/utree.pl?file=V7addenda/README |title=README |work=Addenda to UNIX 7th edition distribution tape, 12/2/80.}}</ref> It turned into its modern wrapper form in NetBSD 1.3 (1998). fsck is not defined by any extant standard,<ref name=FreeBSD/> but the primitive non-wrapper form is present in the 1995 draft ''Systems Management: File System and Scheduling Utilities (FSSU)'' from [[X/Open]].<ref>{{cite web |title=Systems Management: File System and Scheduling Utilities (FSSU) |url=https://pubs.opengroup.org/onlinepubs/008347899/toc.pdf |website=opengroup.org |access-date=8 April 2023 |pages=18 |date=1995}}</ref>
fsck first appeared in the Bell Labs "V7 addendum tape" of 1980.<ref>{{cite newsgroup |url=http://chambers.nycbug.org/pub/The_Unix_Archive/Unix_Usenet/net.bugs.usg/1986-April/000191.html |title="fgrep" doesn't always match everything it should |first=Guy |last=Harris |date=April 18, 1986 |newsgroup=net.bugs.usg}}</ref><ref>{{cite web |url=https://www.tuhs.org/cgi-bin/utree.pl?file=V7addenda/README |title=README |work=Addenda to UNIX 7th edition distribution tape, 12/2/80.}}</ref> It turned into its modern wrapper form in NetBSD 1.3 (1998). fsck is not defined by any extant standard,<ref name=FreeBSD/> but the primitive non-wrapper form is present in the 1995 draft ''Systems Management: File System and Scheduling Utilities (FSSU)'' from [[X/Open]].<ref>{{cite web |title=Systems Management: File System and Scheduling Utilities (FSSU) |url=https://pubs.opengroup.org/onlinepubs/008347899/toc.pdf |website=opengroup.org |access-date=8 April 2023 |pages=18 |date=1995}}</ref>


==As an expletive==
==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".<ref>{{cite web|url=http://www.catb.org/~esr/jargon/oldversions/jarg415.txt |title=fscking |work=[[The Jargon File]] |date=September 24, 1999 |author-link=Eric S. Raymond |last=Raymond |first=Eric S |quote=fcking: /fus'-king/ or /eff'-seek-ing/ adj. [Usenet; common] ''Fucking'', in the expletive sense (it refers to the Unix filesystem-repair command fsck(1), of which it can be said that if you have to use it at all you are having a bad day). Originated on {[[alt.sysadmin.recovery|scary devil monastery]]} and the [[Bastard Operator From Hell|bofh.net]] newsgroups, but became much more widespread following the passage of {[[Communications Decency Act|CDA]]}. Also occasionally seen in the variant ‘What the fsck?’ |archive-url=https://www.webcitation.org/5mVBHbWKJ?url=http://www.catb.org/~esr/jargon/oldversions/jarg415.txt |archive-date=2009-01-03 |url-status=dead }}</ref> 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:
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".<ref>{{cite web|url=http://www.catb.org/~esr/jargon/oldversions/jarg415.txt |title=fscking |work=[[The Jargon File]] |date=September 24, 1999 |author-link=Eric S. Raymond |last=Raymond |first=Eric S |quote=fcking: /fus'-king/ or /eff'-seek-ing/ adj. [Usenet; common] ''Fucking'', in the expletive sense (it refers to the Unix filesystem-repair command fsck(1), of which it can be said that if you have to use it at all you are having a bad day). Originated on {[[alt.sysadmin.recovery|scary devil monastery]]} and the [[Bastard Operator From Hell|bofh.net]] newsgroups, but became much more widespread following the passage of {[[Communications Decency Act|CDA]]}. Also occasionally seen in the variant ‘What the fsck?’ |archive-url=https://www.webcitation.org/5mVBHbWKJ?url=http://www.catb.org/~esr/jargon/oldversions/jarg415.txt |archive-date=2009-01-03 |url-status=dead }}</ref> 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:


Line 48: Line 48:
:'''Dennis Ritchie''': ''"Well, the second letter was different"''<ref>{{cite web | url=https://groups.google.com/forum/#!msg/alt.sysadmin.recovery/tsGbbkvHo2c/6T-Pj9d3A6wJ | title=Report from Usenix | publisher=[[Usenet]] | work=alt.sysadmin.recovery | access-date=2016-02-20 | author=Crosby, Matthew}}</ref><ref>{{cite web | url=http://www.c2.com/cgi/wiki?MindFsck | title=Mind Fsck | publisher=C2 | work=[[WikiWikiWeb]]}}</ref>
:'''Dennis Ritchie''': ''"Well, the second letter was different"''<ref>{{cite web | url=https://groups.google.com/forum/#!msg/alt.sysadmin.recovery/tsGbbkvHo2c/6T-Pj9d3A6wJ | title=Report from Usenix | publisher=[[Usenet]] | work=alt.sysadmin.recovery | access-date=2016-02-20 | author=Crosby, Matthew}}</ref><ref>{{cite web | url=http://www.c2.com/cgi/wiki?MindFsck | title=Mind Fsck | publisher=C2 | work=[[WikiWikiWeb]]}}</ref>


That story has been confirmed by [[Rob Pike]] on the Mastodon social network on December 17, 2023:
That story was confirmed by [[Rob Pike]] on the Mastodon social network on December 17, 2023:
{{Blockquote
{{Blockquote
|author=[[Rob Pike]]
|author=[[Rob Pike]]
Line 55: Line 55:
}}
}}


"Go fsck yourself", is occasionally used online as an injunction to a person to go and correct their issue (attitude, ignorance of the subject matter, etc.) - in the same way that running fsck involves fixing fundamental errors.
"Go fsck yourself" is occasionally used online as an injunction to a person to go and correct their issue (attitude, ignorance of the subject matter, etc.) analogous to fsck fixing fundamental errors.


==Examples==
==Examples==

Latest revision as of 09:36, 26 October 2025

Template:Short descriptionScript error: No such module "For". Template:Lowercase Template:Infobox Software 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.[1] The equivalent programs on MS-DOS and Microsoft 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.[1][2]

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).[2]

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.[3]

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[4] 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.[5] 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.[2]
  • 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.[6] 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.[7]

History

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

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".[11] 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"[12][13]

That story was confirmed by Rob Pike on the Mastodon social network on December 17, 2023:

<templatestyles src="Template:Blockquote/styles.css" />

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.

Script error: No such module "Check for unknown parameters".

"Go fsck yourself" is occasionally used online as an injunction to a person to go and correct their issue (attitude, ignorance of the subject matter, etc.) analogous to fsck fixing fundamental errors.

Examples

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

fsck /usr

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

fsck -t jfs /dev/md0

See also

References

Template:Reflist

External links

Script error: No such module "Navbox".

  1. a b Template:Man "In actuality, fsck is simply a front-end for the various filesystem checkers (fsck.fstype) available under Linux."
  2. a b c d Template:Man "It was reimplemented as a filesystem independent wrapper in NetBSD 1.3 and first appeared in FreeBSD 5.0."
  3. Template:Man
  4. Template:Man: "XFS is a journaling filesystem and performs recovery at mount(8) time if necessary"
  5. Template:Man
  6. Template:Man, : "do nothing, successfully" "Traditional filesystems need to run their respective fsck utility in case the filesystem was not unmounted cleanly and the log needs to be replayed before mount. This is not needed for BTRFS."
  7. Script error: No such module "citation/CS1".
  8. Script error: No such module "citation/CS1".
  9. Script error: No such module "citation/CS1".
  10. Script error: No such module "citation/CS1".
  11. Script error: No such module "citation/CS1".
  12. Script error: No such module "citation/CS1".
  13. Script error: No such module "citation/CS1".
  14. Script error: No such module "citation/CS1".