{{short description| Verifies the data integrity of a storage volume}} {{Infobox software | name = chkdsk | screenshot = Windows XP CHKDSK.png | caption = CHKDSK on boot in Windows XP | author = Tim Paterson | developer = SCP, Microsoft, IBM, DR, Datalight, Novell, Toshiba, PhysTechSoft, ReactOS Contributors | released = {{Start date and age|1980}} | programming language = MS-DOS: x86 assembly language<br />FreeDOS, ReactOS: C | operating system = 86-DOS, MS-DOS, PC DOS, MSX-DOS, SISNE plus, OS/2, eComStation, ArcaOS, FlexOS, DR-DOS, ROM-DOS, 4690 OS, PTS-DOS, Windows, FreeDOS, ReactOS | platform = Cross-platform | genre = Command | license = MS-DOS: MIT<br />FreeDOS, ReactOS: GPLv2 }} '''<code>CHKDSK</code>''' (short for "check disk") is a shell command that verifies the data integrity of the file system on a volume (usually a partition) and attempts to fix logical errors {{endash}} software-level problems with a filesystem (or its metadata) as a result of prior software malfunction (e.g. crashes) or irregular use (e.g. hard resets). Logical errors are contrasted with and usually less severe than hardware-level errors, which can not be fixed with <code>CHKDSK</code> and may instead require specialized data recovery software or hardware service or replacement. Although the name ends with "DSK" as an abbreviation for "disk", the command supports storage media other than disk-based.
The command is available in DOS, Windows, FlexOS,<ref>{{cite web |url=http://www.bitsavers.org/pdf/digitalResearch/flexos/1073-2003_FlexOS_Users_Guide_V1.3_Nov86.pdf |title=FlexOS User's Guide |date=1986 |website=www.bitsavers.org |access-date=2020-09-14 |archive-date=2018-09-14 |archive-url=https://web.archive.org/web/20180914132130/http://www.bitsavers.org/pdf/digitalResearch/flexos/1073-2003_FlexOS_Users_Guide_V1.3_Nov86.pdf |url-status=dead }}</ref> 4690 OS,<ref> [https://archive.org/details/4690OSV6r2UsersGuide/page/n169]{{dead link|date=September 2020}}</ref> OS/2,<ref>{{Cite web |url=http://www.jatomes.com/Help/Os2Cmd.php#CHKDSK |title=JaTomes Help - OS/2 Commands |access-date=2019-07-20 |archive-date=2019-04-14 |archive-url=https://web.archive.org/web/20190414130029/http://www.jatomes.com/Help/Os2Cmd.php#CHKDSK |url-status=dead }}</ref> DR DOS 6.0,<ref name="drdos6userguide">{{Cite web |url=https://www.4corn.co.uk/archive/docs/DR%20DOS%206.0%20User%20Guide-opt.pdf |title=DR DOS 6.0 User Guide Optimisation and Configuration Tips |access-date=2019-08-13 |archive-url=https://web.archive.org/web/20190930135943/http://www.4corn.co.uk/archive/docs/DR%20DOS%206.0%20User%20Guide-opt.pdf |archive-date=2019-09-30 |url-status=dead }}</ref> and FreeDOS.<ref>{{Cite web|url=http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/chkdsk.html|title=ibiblio.org FreeDOS Package -- chkdsk (FreeDOS Base)|website=www.ibiblio.org|access-date=2020-07-26|archive-date=2020-11-28|archive-url=https://web.archive.org/web/20201128082210/http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/repos/pkg-html/chkdsk.html|url-status=live}}</ref>
<code>CHKDSK</code> is similar to the <code>fsck</code> command in Unix and similar to Microsoft ScanDisk, which co-existed with <code>CHKDSK</code> in Windows 9x and MS-DOS 6.x.
==Variants== ===CHECKDSK=== An early variant of a disk checking tool was a part of Digital Equipment Corporation hardware's diagnostics, running on early 1970s TENEX and TOPS-20.<ref>{{cite web |website=BitSavers |url=http://www.bitsavers.org/bits/Foonly/F2/text/DSK:%253CFOONEX%253EJOBZRO.MAC%3B37.txt |title=134-TENEX JOBZRO.MAC |date=1979-09-16 |access-date=2020-08-14 |archive-date=2019-01-27 |archive-url=https://web.archive.org/web/20190127231604/http://bitsavers.org/bits/Foonly/F2/text/DSK:%3cFOONEX%3eJOBZRO.MAC;37.txt |url-status=dead }}</ref> <ref>{{cite web |url=http://bitsavers.informatik.uni-stuttgart.de/pdf/xerox/maxc/MAXC_Operations_May74.pdf |title=Xerox Palo Alto Research Center |quote=Under Tenex .. Hardware Maintenance Procedures .. Recovery from Checkdsk Errors |access-date=2021-10-11 |archive-date=2012-10-04 |archive-url=https://web.archive.org/web/20121004030204/http://bitsavers.informatik.uni-stuttgart.de/pdf/xerox/maxc/MAXC_Operations_May74.pdf |url-status=live }}</ref>
===SCP 86-DOS=== The <code>CHKDSK</code> command was first written in 1980 by Tim Paterson and included in 86-DOS.<ref>{{Cite web |url=http://www.patersontech.com/Dos/docs/86_Dos_usr_03.pdf |title=86-DOS User's Manual - Version 0.3 |access-date=2019-06-09 |archive-url=https://web.archive.org/web/20190714004434/http://www.patersontech.com/dos/docs/86_Dos_usr_03.pdf |archive-date=2019-07-14 |url-status=dead }}</ref>
===DOS=== [[File:IBM PC DOS 1.0 screenshot.png|thumb|300px|<code>CHKDSK.COM</code> (among several other COM files) in IBM PC DOS 1.0.]] The command is available in MS-DOS versions 1 and later.<ref name="RUNNINGMSDOS">{{Cite book|author-last=Wolverton|author-first=Van|title=Running MS-DOS Version 6.22 (20th Anniversary Edition), 6th Revised edition|date=2003|publisher=Microsoft Press|isbn=0-7356-1812-7}}</ref> <code>CHKDSK</code> is implemented as an external command. MS-DOS versions 2.x - 4.x use <code>chkdsk.com</code> as the executable file. MS-DOS versions 5.x and later use <code>chkdsk.exe</code> as the executable file.<ref>{{Cite web|url=https://www.computerhope.com/chkdskh.htm|title=MS-DOS and Windows command line chkdsk command|website=www.computerhope.com|access-date=2019-08-13|archive-date=1999-08-21|archive-url=https://web.archive.org/web/19990821050442/https://www.computerhope.com/chkdskh.htm|url-status=live}}</ref>
<code>CHKDSK</code> can also show the memory usage, this was used before the command <code>MEM.EXE</code> was introduced in MS-DOS 4.0 to show the memory usage. In DR DOS the parameter <code>/A</code> limited the output to only show the memory usage.
====MS-DOS 5.0 bug==== <code>CHKDSK</code> and <code>UNDELETE</code> in MS-DOS 5.0 have a bug which can corrupt data: If the file allocation table of a disk uses 256 sectors, running <code>CHKDSK /F</code> can cause data loss and running <code>UNDELETE</code> can cause unpredictable results. This normally affects disks with a capacity of approximately a multiple of 128 MB. This applies to <code>CHKDSK.EXE</code> and <code>UNDELETE.EXE</code> bearing a datestamp of April 9, 1991. This bug was fixed in MS-DOS 5.0a.<ref>{{Cite web|url = http://support.microsoft.com/kb/80496|title = When Not to Use MS-DOS 5.0 <code>CHKDSK</code> and <code>UNDELETE</code> Commands|date = 16 November 2006|website = Support|publisher = Microsoft|edition = 1.1|access-date = 6 November 2014|archive-date = 12 March 2007|archive-url = https://web.archive.org/web/20070312053204/http://support.microsoft.com/kb/80496|url-status = live}}</ref>
===Windows=== [[File:Chkdsk screenshot.png|thumb|300px|The {{code|chkdsk}} command on Windows XP]] <code>CHKDSK</code> can be run via typical command line interfaces such as PowerShell and Command Prompt, and a special version is available in the Recovery Console.<ref>{{Cite web|url = http://support.microsoft.com/kb/314058|title = Description of the Windows XP Recovery Console for advanced users|date = 11 July 2013|access-date = 4 September 2014|website = Support|publisher = Microsoft|edition = 8.0|archive-date = 19 October 2004|archive-url = https://web.archive.org/web/20041019212739/http://support.microsoft.com/kb/314058|url-status = live}}</ref>
In Windows NT, <code>CHKDSK</code> can also mark bad sectors. In MS-DOS 6.x and Windows 9x, this is a done via Microsoft ScanDisk. The Windows Server version of <code>CHKDSK</code> is RAID-aware and can fully recover data in bad sectors of a disk in a RAID-1 or RAID-5 array if other disks in the set are intact.<ref>{{Cite book |title=Managing and Maintaining a Microsoft Windows Server 2003 Environment |first1=Dan |last1=Holm |first2=Orin |last2=Thomas |publisher=Microsoft Press |isbn=9780735614376 |year=2003 |chapter=11-3: Maintaining Disk Storage Volumes |page=[https://archive.org/details/mcsaselfpacedtra00micr/page/11 11.25<!--This is a page number, not a page range.-->] |chapter-url=https://archive.org/details/mcsaselfpacedtra00micr/page/11 }}</ref>
Fragments of files and directories deemed as corrupt as a result of, for example, power outages while writing, file name overlength, and/or invalid characters in file name, are moved into a directory under the partition's root, named <code>found.000</code>, and renamed into generic hexadecimally numbered files and directories starting with <code>file00000000.chk</code> and <code>dir_00000000.chk</code> respectively.<ref>{{Cite web|url=https://www.howtogeek.com/282798/what-are-the-found000-folder-and-file0000chk-file-in-windows/|title=What Are the FOUND.000 Folder and FILE0000.CHK File in Windows?|date=5 December 2016|access-date=25 May 2021|archive-date=5 December 2016|archive-url=https://web.archive.org/web/20161205195019/https://www.howtogeek.com/282798/what-are-the-found000-folder-and-file0000chk-file-in-windows/|url-status=live}}</ref><ref>{{Cite web|url=https://www.msftnext.com/delete-file-when-path-too-long-or-name-ends-with-dots-or-space/|title=Delete File when Path Too Long or Name Ends with Dots or Space|access-date=2021-05-25|archive-date=2021-04-13|archive-url=https://web.archive.org/web/20210413202851/https://www.msftnext.com/delete-file-when-path-too-long-or-name-ends-with-dots-or-space/|url-status=live}}</ref>
In the Windows NT family, a standard <code>CHKDSK</code> scan consists of three phases of testing file metadata. It looks for errors but does not fix them unless it is explicitly ordered to do so. The same applies to surface scan—this test, which could be extremely time-consuming on large or low-performance disks, is not carried out unless explicitly requested. <code>CHKDSK</code> requires exclusive write access to the volume to perform repairs.<ref>{{cite web |title=An explanation of the new /C and /I Switches that are available to use with Chkdsk.exe |url=http://support2.microsoft.com/kb/314835 |website=Microsoft Support |publisher=Microsoft |access-date=25 January 2019 |archive-url=https://web.archive.org/web/20141024211818/http://support2.microsoft.com/kb/314835 |archive-date=24 October 2014 |date=1 December 2007}}</ref><ref>{{Cite web|url = https://technet.microsoft.com/en-us/library/bb457122.aspx|title = Troubleshooting Disks and File Systems|date = 3 November 2005|access-date = 4 September 2014|website = Windows XP Professional Resource Kit|publisher = Microsoft|archive-date = 13 June 2007|archive-url = https://web.archive.org/web/20070613231130/https://technet.microsoft.com/en-us/library/bb457122.aspx|url-status = live}}</ref>
Due to the requirement of the monopolized access to the drive, the <code>CHKDSK</code> cannot check the system disk in the normal system mode. Instead, the system sets a dirty bit to the disk volume and then reboots the computer. During the Windows start-up, a special version of <code>CHKDSK</code> called <code>Autochk</code> (a Native API application, short for "autocheck") is started by SMSS.EXE and checks and attempts repairing the file system if the dirty bit is set.
Because of the exclusive access requirement and the time-consuming nature of <code>CHKDSK</code> operation, Windows Vista implemented a new file system health model in which the operating system fixes errors on the volumes as it encounters them. In the event that the problem is grave and a full scan is required, Action Center notifies the user to take the volume offline at the first convenience.<ref>{{Cite web|url = http://blogs.msdn.com/b/b8/archive/2012/05/09/redesigning-chkdsk-and-the-new-ntfs-health-model.aspx|title = Redesigning chkdsk and the new NTFS health model|date = 10 May 2012|website = Building Windows 8|publisher = Microsoft|last = Bangalore|first = Kiran|editor-first = Steven|editor-last = Sinofsky|archive-url=https://web.archive.org/web/20120512015753/http://blogs.msdn.com/b/b8/archive/2012/05/09/redesigning-chkdsk-and-the-new-ntfs-health-model.aspx|archive-date=2012-05-12|url-status=dead}}</ref>
Windows Vista and Windows Server 2008 added self-healing ability, turned on by default, in addition to providing the <code>CHKDSK</code> command. It detects physical file system errors and silently fixes them on the fly. Thus, many problems previously discovered on running <code>CHKDSK</code> never appear. It is administered by <code>fsutil repair</code> command.<ref>{{Cite web|last1=Chen|first1=Ken|title=NTFS Self-Healing is An Overlooked but Useful Feature in Windows 7|url=http://www.nextofwindows.com/ntfs-self-healing-is-an-overlooked-but-useful-feature-in-windows-7/|website=Next of Windows|date=4 August 2014|access-date=19 November 2014|archive-date=29 July 2013|archive-url=https://web.archive.org/web/20130729015159/http://www.nextofwindows.com/ntfs-self-healing-is-an-overlooked-but-useful-feature-in-windows-7/|url-status=dead}}</ref><ref>{{Cite web |last1=Pawar |first1=Amit |date=13 February 2008 |title=Self-healing NTFS in Windows Server 2008 and Windows Vista |url=https://learn.microsoft.com/en-us/archive/blogs/apawar/self-healing-ntfs-in-windows-server-2008-and-windows-vista |website=Amit Pawar - Infrastructure blog |publisher=Microsoft}}</ref>
Criticism has been aimed at the tendency of <code>AUTOCHK</code> to automatically modify the file system when not explicitly solicited by the user who may wish to back up their data in prior, as an attempted repair may scramble, undermine and disown file and directory paths, especially on a multiboot installation where multiple operating systems may have interferingly written to the same partition.<ref>{{cite web |title=Will Scandisk or CHKDSK Cause Computer Data Loss? |url=https://www.datanumen.com/blogs/will-scandisk-chkdsk-cause-computer-data-loss/ |website=Data Recovery Blog |date=8 February 2017 |access-date=12 December 2020 |archive-date=12 December 2020 |archive-url=https://web.archive.org/web/20201212141127/https://www.datanumen.com/blogs/will-scandisk-chkdsk-cause-computer-data-loss/ |url-status=live }}</ref><ref>{{cite web |title=Disable or Stop Auto CHKDSK During Windows Startup • Raymond.CC |url=https://www.raymond.cc/blog/disable-or-stop-auto-chkdsk-during-windows-startup/ |website=Raymond.CC |date=23 February 2008 |access-date=12 December 2020 |archive-date=2 December 2020 |archive-url=https://web.archive.org/web/20201202122518/https://www.raymond.cc/blog/disable-or-stop-auto-chkdsk-during-windows-startup/ |url-status=live }}</ref><ref>{{cite web |title=How to Fix a Corrupted Windows NTFS Filesystem With Ubuntu |url=https://www.makeuseof.com/tag/fix-corrupted-windows-ntfs-filesystem-ubuntu/ |website=MakeUseOf |date=22 September 2010 |access-date=12 December 2020 |archive-date=12 November 2020 |archive-url=https://web.archive.org/web/20201112004141/https://www.makeuseof.com/tag/fix-corrupted-windows-ntfs-filesystem-ubuntu/ |url-status=live }}</ref>
====The alleged Windows 7 bug==== Before the release of Windows 7, ''InfoWorld'' reported an alleged memory leak in <code>CHKDSK</code>; according to the report, the <code>chkdsk /r</code> command would cause the memory consumption to reach the maximum and the system to crash. Randall C. Kennedy of ''InfoWorld'' attributed the original report to "various Web sources" and said that in his tests, the memory consumption reached above 90%, although he did not experience a crash. Nevertheless, Kennedy took the memory consumption for a critical bug that would derail Windows 7's launch and chastised Microsoft.<ref>{{cite web|last1=Kennedy|first1=Randall C.|title=Critical Windows 7 bug risks derailing product launch|url=http://www.infoworld.com/article/2631567/microsoft-windows/critical-windows-7-bug-risks-derailing-product-launch.html|website=InfoWorld|publisher=IDG|access-date=19 February 2015|date=5 August 2009|archive-date=19 February 2015|archive-url=https://web.archive.org/web/20150219212657/http://www.infoworld.com/article/2631567/microsoft-windows/critical-windows-7-bug-risks-derailing-product-launch.html|url-status=live}}</ref> Tom Warren of Neowin dismissed Kennedy's assessment of the alleged leak's significance.<ref>{{cite web|last1=Warren|first1=Tom|title=Windows 7 RTM contains a rather nasty chkdsk bug|url=http://www.neowin.net/news/windows-7-rtm-contains-a-rather-nasty-chkdsk-bug|website=Neowin|access-date=19 February 2015|date=5 August 2009|archive-date=19 February 2015|archive-url=https://web.archive.org/web/20150219213218/http://www.neowin.net/news/windows-7-rtm-contains-a-rather-nasty-chkdsk-bug|url-status=live}}</ref> Steven Sinofsky of Microsoft also responded that Microsoft could not reproduce a crash either but that the massive memory consumption was by design, to improve performance, and not a leak. Ed Bott of ''ZDNet'' also reviewed the claim with his own tests and observed that no crash would occur. Noting that <code>chkdsk /r</code>, by design, does not work on the system drive while Windows is online, Bott concluded "it's arguably a feature, not a bug, and the likelihood that you'll ever crash a system this way is very, very small and completely avoidable."<ref>{{cite web|last1=Bott|first1=Ed|title=A killer Windows 7 bug? Sorry, no|url=https://www.zdnet.com/article/a-killer-windows-7-bug-sorry-no/|website=ZDNet|publisher=CBS Interactive|date=5 August 2009|access-date=5 July 2024|archive-date=1 December 2024|archive-url=https://web.archive.org/web/20241201231407/https://www.zdnet.com/article/a-killer-windows-7-bug-sorry-no/|url-status=live}}</ref>
===ReactOS=== [[File:ReactOS-0.4.13 chkdsk command 667x434.png|thumb|300px|The {{code|chkdsk}} command on ReactOS]] The ReactOS command is based on a free clone developed by Mark Russinovich for Sysinternals in 1998.<ref>{{Cite web|url=https://github.com/reactos/reactos|title=reactos/reactos|website=GitHub|date=3 January 2022|access-date=9 June 2019|archive-date=11 December 2017|archive-url=https://web.archive.org/web/20171211170155/https://github.com/reactos/reactos|url-status=live}}</ref> It was adapted to ReactOS by Emanuele Aliberti in 1999 and supports volumes using the FAT32 filesystem. The command does not support volumes using the Btrfs filesystem, although ReactOS supports it since version 0.4.1.
==See also== * Defragmentation * Data scrubbing * List of file systems * e2fsprogs {{clear}}
==References== {{Reflist|30em}}
==Further reading== *{{Cite book|author-last=Wolverton|author-first=Van|title=MS-DOS Commands: Microsoft Quick Reference, 4th Revised edition|date=1990|publisher=Microsoft Press|isbn=978-1556152894}} *{{Cite book|author1=Kathy Ivens|author2=Brian Proffit|year=1993|title=OS/2 Inside & Out|publisher=Osborne McGraw-Hill|isbn=978-0078818714}} *{{Cite book|first=Æleen|last=Frisch|year=2001|title=Windows 2000 Commands Pocket Reference|publisher=O'Reilly|isbn=978-0-596-00148-3}}
==External links== {{Wikibooks|Guide to Windows Commands}} {{Commons category|Screenshots of CHKDSK}} *[https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/chkdsk Official documentation about Microsoft CHKDSK] *[https://github.com/microsoft/MS-DOS/blob/master/v2.0/source/CHKDSK.ASM Open source CHKDSK implementation that comes with MS-DOS v2.0] <!-- ======================== {{No more links}} ============================ | PLEASE BE CAUTIOUS IN ADDING MORE LINKS TO THIS ARTICLE. Wikipedia | | is not a collection of links nor should it be used for advertising. | | | | Excessive or inappropriate links WILL BE DELETED. | | See Wikipedia:External links & Wikipedia:Spam for details. | | | | If there are already plentiful links, please propose additions or | | replacements on this article's discussion page, or submit your link | | to the relevant category at the Open Directory Project (dmoz.org) | | and link back to that category using the {{dmoz}} template. | =========================== {{No more links}} ============================= -->
{{Windows commands}}
Category:External DOS commands Category:Hard disk software Category:Microsoft free software Category:MSX-DOS commands Category:OS/2 commands