CHKDSK explained

chkdsk
Author:Tim Paterson
Developer:SCP, Microsoft, IBM, DR, Datalight, Novell, Toshiba, PhysTechSoft, ReactOS Contributors
Programming Language:MS-DOS

x86 assembly language
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
FreeDOS, ReactOS: GPLv2

In computing, CHKDSK (short for "check disk") is a system tool and command in DOS, Digital Research FlexOS,[1] IBM/Toshiba 4690 OS,[2] IBM OS/2,[3] Microsoft Windows and related operating systems. It verifies the file system integrity of a volume and attempts to fix logical file system errors. It is similar to the [[fsck]] command in Unix and similar to Microsoft ScanDisk, which co-existed with CHKDSK in Windows 9x and MS-DOS 6.x.

Implementations

An early implementation of a 'CheckDisk' was the CHECKDSK that was a part of Digital Equipment Corporation hardware's diagnostics, running on early 1970s TENEX and TOPS-20.[4] [5]

SCP 86-DOS

The CHKDSK command was first implemented in 1980 by Tim Paterson and included in Seattle Computer Products 86-DOS.[6]

MS-DOS / IBM PC DOS

The command is available in MS-DOS versions 1 and later.[7] CHKDSK is implemented as an external command. MS-DOS versions 2.x - 4.x use chkdsk.com as the executable file. MS-DOS versions 5.x and later use chkdsk.exe as the executable file.[8]

CHKDSK can also show the memory usage, this was used before the command MEM.EXE was introduced in MS-DOS 4.0 to show the memory usage. In DR DOS the parameter /A limited the output to only show the memory usage.

MS-DOS 5.0 bug

CHKDSK and UNDELETE in MS-DOS 5.0 have a bug which can corrupt data: If the file allocation table of a disk uses 256 sectors, running CHKDSK /F can cause data loss and running UNDELETE can cause unpredictable results. This normally affects disks with a capacity of approximately a multiple of 128 MB. This applies to CHKDSK.EXE and UNDELETE.EXE bearing a datestamp of April 9, 1991. This bug was fixed in MS-DOS 5.0a.[9]

Microsoft Windows

CHKDSK can be run from DOS prompt, Windows Explorer, Windows Command Prompt, Windows PowerShell or Recovery Console.[10]

On Windows NT operating systems, CHKDSK can also check the disk surface for bad sectors and mark them (in MS-DOS 6.x and Windows 9x, this is a task done by Microsoft ScanDisk). The Windows Server version of CHKDSK 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.[11]

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 found.000, and renamed into generic hexadecimally numbered files and directories starting with file00000000.chk and dir_00000000.chk respectively.[12] [13]

On Windows NT family, a standard CHKDSK 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. CHKDSK requires exclusive write access to the volume to perform repairs.[14] [15]

Due to the requirement of the monopolized access to the drive, the CHKDSK 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 CHKDSK called [[Autochk]] (a native mode application) is started by the 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 CHKDSK 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.[16]

Windows Vista and Windows Server 2008 added self-healing ability, turned on by default, in addition to providing the CHKDSK command. It detects physical file system errors and silently fixes them on the fly. Thus, many problems previously discovered on running CHKDSK never appear. It is administered by fsutil repair command.[17] [18]

Criticism has been aimed at the tendency of AUTOCHK 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.[19] [20] [21]

The alleged Windows 7 bug

Before the release of Windows 7, InfoWorld reported an alleged memory leak in CHKDSK; according to the report, the chkdsk /r 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.[22] Tom Warren of Neowin dismissed Kennedy's assessment of the alleged leak's significance.[23] 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 chkdsk /r, 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."[24]

DR/Novell DOS

DR DOS 6.0 also includes an implementation of the command.[25]

FreeDOS

The FreeDOS version was developed by Imre Leber and is licensed under the GNU GPL 2.[26]

ReactOS

The ReactOS implementation is based on a free clone developed by Mark Russinovich for Sysinternals in 1998.[27] 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

Further reading

External links

Notes and References

  1. Web site: FlexOS User's Guide . 1986 . www.bitsavers.org . 2020-09-14 . 2018-09-14 . https://web.archive.org/web/20180914132130/http://www.bitsavers.org/pdf/digitalResearch/flexos/1073-2003_FlexOS_Users_Guide_V1.3_Nov86.pdf . dead .
  2. https://archive.org/details/4690OSV6r2UsersGuide/page/n169
  3. Web site: JaTomes Help - OS/2 Commands . 2019-07-20 . 2019-04-14 . https://web.archive.org/web/20190414130029/http://www.jatomes.com/Help/Os2Cmd.php#CHKDSK . dead .
  4. Web site: BitSavers. 134-TENEX JOBZRO.MAC. 1979-09-16. 2020-08-14. 2019-01-27. https://web.archive.org/web/20190127231604/http://bitsavers.org/bits/Foonly/F2/text/DSK:%3cFOONEX%3eJOBZRO.MAC;37.txt. dead.
  5. Web site: Xerox Palo Alto Research Center . Under Tenex .. Hardware Maintenance Procedures .. Recovery from Checkdsk Errors.
  6. Web site: 86-DOS User's Manual - Version 0.3 . 2019-06-09 . https://web.archive.org/web/20190714004434/http://www.patersontech.com/dos/docs/86_Dos_usr_03.pdf . 2019-07-14 . dead .
  7. Book: Wolverton. Van. Running MS-DOS Version 6.22 (20th Anniversary Edition), 6th Revised edition. 2003. Microsoft Press. 0-7356-1812-7.
  8. Web site: MS-DOS and Windows command line chkdsk command. www.computerhope.com.
  9. Web site: When Not to Use MS-DOS 5.0 CHKDSK and UNDELETE Commands. 16 November 2006. Support. Microsoft. 1.1.
  10. Web site: Description of the Windows XP Recovery Console for advanced users. 11 July 2013. 4 September 2014. Support. Microsoft. 8.0.
  11. Book: Managing and Maintaining a Microsoft Windows Server 2003 Environment . Dan . Holm . Orin . Thomas . Microsoft Press . 9780735614376 . 2003 . 11-3: Maintaining Disk Storage Volumes . 11.25 . https://archive.org/details/mcsaselfpacedtra00micr/page/11 .
  12. Web site: What Are the FOUND.000 Folder and FILE0000.CHK File in Windows?. 5 December 2016 .
  13. Web site: Delete File when Path Too Long or Name Ends with Dots or Space.
  14. Web site: An explanation of the new /C and /I Switches that are available to use with Chkdsk.exe . Microsoft Support . Microsoft . 25 January 2019 . https://web.archive.org/web/20141024211818/http://support2.microsoft.com/kb/314835 . 24 October 2014 . 1 December 2007.
  15. Web site: Troubleshooting Disks and File Systems. 3 November 2005. 4 September 2014. Windows XP Professional Resource Kit. Microsoft.
  16. Web site: Redesigning chkdsk and the new NTFS health model. 10 May 2012. Building Windows 8. Microsoft. Bangalore. Kiran. Steven. Sinofsky. 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. 2012-05-12. dead.
  17. Web site: Chen. Ken. NTFS Self-Healing is An Overlooked but Useful Feature in Windows 7. Next of Windows. 4 August 2014.
  18. Web site: Pawar. Amit. Self-healing NTFS in Windows Server 2008 and Windows Vista. Amit Pawar - Infrastructure blog. Microsoft. 13 February 2008.
  19. Web site: Will Scandisk or CHKDSK Cause Computer Data Loss? . Data Recovery Blog . 8 February 2017.
  20. Web site: Disable or Stop Auto CHKDSK During Windows Startup • Raymond.CC . Raymond.CC . 23 February 2008.
  21. Web site: How to Fix a Corrupted Windows NTFS Filesystem With Ubuntu . MakeUseOf . 22 September 2010.
  22. Web site: Kennedy. Randall C.. Critical Windows 7 bug risks derailing product launch. InfoWorld. IDG. 19 February 2015. 5 August 2009.
  23. Web site: Warren. Tom. Windows 7 RTM contains a rather nasty chkdsk bug. Neowin. 19 February 2015. 5 August 2009.
  24. Web site: Bott. Ed. A killer Windows 7 bug? Sorry, no. ZDNet. CBS Interactive. 5 August 2009.
  25. Web site: DR DOS 6.0 User Guide Optimisation and Configuration Tips . 2019-08-13 . https://web.archive.org/web/20190930135943/http://www.4corn.co.uk/archive/docs/DR%20DOS%206.0%20User%20Guide-opt.pdf . 2019-09-30 . dead .
  26. Web site: ibiblio.org FreeDOS Package -- chkdsk (FreeDOS Base). www.ibiblio.org.
  27. Web site: reactos/reactos. GitHub. 3 January 2022.