Solved

chkdsk on XP returns with value 2, what does that mean?

Posted on 2010-08-25
16
737 Views
Last Modified: 2012-05-10
I am writing tests cases for our disk drive solution and our disk is getting into a state that fails chkdsk.  The value returned from chkdsk is a 2.  I know from searching the web that a 2 means the following:
2 - Disk cleanup, such as garbage collection, was performed, or cleanup was not performed because /f was not specified.

I don't want to clean the disk because I need to know what the cleanup that is needed is.  I want to understand if this is something that should have been prevented by the driver and was not.  By the way this is an NTFS partition.  

Is there a utility or something that I can use to see exactly what is causing chkdsk to return a 2?  Here is an output of the chkdsk information and I don't see any indications of an error in it:
C:\hgclones\leptontools\scripts>python
Python 2.6.4 (r264:75708, Oct 26 2009, 07:36:50) [MSC v.1500 64 bit (AMD64)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.system('chkdsk T:')
The type of the file system is NTFS.

WARNING!  F parameter not specified.
Running CHKDSK in read-only mode.

CHKDSK is verifying files (stage 1 of 3)...
48 file records processed.
File verification completed.
0 large file records processed.
0 bad file records processed.
0 EA records processed.
0 reparse records processed.
CHKDSK is verifying indexes (stage 2 of 3)...
129 index entries processed.
Index verification completed.
5 unindexed files processed.
CHKDSK is verifying security descriptors (stage 3 of 3)...
48 security descriptors processed.
Security descriptor verification completed.
11 data files processed.

  78440670 KB total disk space.
   1049604 KB in 3 files.
        12 KB in 13 indexes.
         0 KB in bad sectors.
     68398 KB in use by the system.
     65536 KB occupied by the log file.
  77322656 KB available on disk.

      4096 bytes in each allocation unit.
  19610167 total allocation units on disk.
  19330664 allocation units available on disk.
2
>>>
I did this in python so you could see that indeed it is returning an error code of 2.
0
Comment
Question by:Laserwhit
  • 8
  • 3
  • 3
  • +2
16 Comments
 
LVL 1

Expert Comment

by:number1pride
Comment Utility
Try the command with the /F option.  If i remember the api correctly the chkdsk program throws this error when it cannot determine the disk type (does not seem like the case here) or when is not authorized to fix an error it finds(/f option)
0
 

Author Comment

by:Laserwhit
Comment Utility
I can fix this error with /f, I have done so in the past.  

 don't want to do this because the issue will then be gone and I will still be in the dark as to why it is happening and what it really means.  I need chkdsk to open itself up and tell me what it is seeing.  Why is it giving me a 2 and not a 0?
0
 

Author Comment

by:Laserwhit
Comment Utility
All of this is in context of automation that hammers the disk and in turn checks the disk with chkdsk from time to time.  Usually it returns fine with no issues ( return code=0 ).  But every once in a while it gives me a return code of 2.  I need to know why.  What is chkdsk seeing?
0
 
LVL 28

Expert Comment

by:pepr
Comment Utility
Have a look at http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/chkdsk.mspx?mfr=true

Exit code      Description

0    No errors were found.
1    Errors were found and fixed.
2    Disk cleanup, such as garbage collection, was performed, or cleanup was not performed because /f was not specified.
3    Could not check the disk, errors could not be fixed, or errors were not fixed because /f was not specified.

The situation probably means that you usually have no errors on the disk (hence return 0), but sometimes some error appears and it cannot be fixed because you did not use /f
0
 
LVL 28

Expert Comment

by:pepr
Comment Utility
If I understand it well, then it is rather confusing because "garbage collection, was performed, or cleanup was not performed because /f was not specified."

To translate, the 2 is the error only when you have used /f.  Otherwise, it is probably considered OK -- e.g. garbage collection was performed.
0
 
LVL 46

Expert Comment

by:noxcho
Comment Utility
Strange that your CHKDSK has no references to garbage you refer to. It could be simply trying to fix the free entries marked as used. This happens when the file is not deleted properly so some garbage remains in sectors.
Try to run in cmd - CHKDSK x: without any key and see what it does return. No python. Does it tell anything about entries marked as free?
0
 
LVL 28

Expert Comment

by:pepr
Comment Utility
Possibly, the cleanup would be performed if you typed /f.  Poissibly some operations may (false) detect the need for cleanup because disk blocks may look as lost (?) -- because chkdsk did not lock the disk and there may be some files just being created of whatever (?). Just a wild guess.
0
 

Author Comment

by:Laserwhit
Comment Utility
More Clarification:
The disk is definitely in a state that chkdsk sees as in error because I can run chkdsk over and over again and get the same result, as long as I don't use the /f option.  This means that whether it is doing the garbage collection or not, it seems to find the disk in a bad state.  I would just like to know what that bad state is?

Also the python is only showing the same information that is shown on the command line except that you can see the return value which is 2.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 46

Expert Comment

by:noxcho
Comment Utility
Can you post here the output of the common CHKDSK without /f key? I don't see any error or bad state reported in your original post.
0
 

Author Comment

by:Laserwhit
Comment Utility
The post I gave in the beginning is indeed the output.  I ran the interactive python code given so you can see everything there is.  This indeed is my problem, I don't see any error or bad state reported either and yet I can run chkdsk over and over and get an error code returned.  Any ideas?
0
 

Author Comment

by:Laserwhit
Comment Utility
Maybe this will help, I have added an intermediate variable to show that os.system('chkdsk T:') is actually returning a 2.  In other words chkdsk is returning an error code of 2.  Here is the new example:
Python 2.6.4 (r264:75708, Oct 26 2009, 07:36:50) [MSC v.1500 64 bit (AMD64)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> returnval = os.system('chkdsk T:')
The type of the file system is NTFS.

WARNING!  F parameter not specified.
Running CHKDSK in read-only mode.

CHKDSK is verifying files (stage 1 of 3)...
48 file records processed.
File verification completed.
0 large file records processed.
0 bad file records processed.
0 EA records processed.
0 reparse records processed.
CHKDSK is verifying indexes (stage 2 of 3)...
129 index entries processed.
Index verification completed.
5 unindexed files processed.
CHKDSK is verifying security descriptors (stage 3 of 3)...
48 security descriptors processed.
Security descriptor verification completed.
11 data files processed.

  78440670 KB total disk space.
   1049604 KB in 3 files.
        12 KB in 13 indexes.
         0 KB in bad sectors.
     68398 KB in use by the system.
     65536 KB occupied by the log file.
  77322656 KB available on disk.

      4096 bytes in each allocation unit.
  19610167 total allocation units on disk.
  19330664 allocation units available on disk.
>>> returnval
2
>>>

I hope that helps.  If you just run chkdsk on the command line the return code is not seen, that is why I used the python example.
0
 
LVL 46

Expert Comment

by:noxcho
Comment Utility
Look, Microsoft always change the status of the problem or errors or glitches in its file systems. Call it whatever you like. For example if cross linked file error was considered sever error in XP then in Windows 7 it is not. Because it is considered to be minor problem that does not require check and fix. This is the right explaining to your problem. There is some minor issue with FS but current OS chkdsk.exe cannot fix it because Microsoft told it - that is not an error. If you want to fix it truly get Windows 2000 installation CD and run the CHKDSK from it Recovery Console. Or from old DOS of Windows 98.
0
 

Author Comment

by:Laserwhit
Comment Utility
I can fix the error any time I want to.  I have done so many times.  All I need to do is run chkdsk with the /f option.  I don't want to fix the error.  I want to know what the error is.
0
 
LVL 25

Accepted Solution

by:
clockwatcher earned 500 total points
Comment Utility
Have you tried running it with the /v flag? That flag is supposed to tell you the cleanup messages.  Without the /f, it may not actually get you anything but it's worth a try.  It may tell you what it would clean up had you used /f.

  chkdsk /v T:
0
 

Author Comment

by:Laserwhit
Comment Utility
Wow, this is at least a start.  Embarrassingly straight forward.  The message in the help fooled me into not reading past the /V part about FAT and FAT32 and displaying a full path on the disk.  Hidden from my mental vision was the part about showing the errors on NTFS and indeed here is what it is showing me.  I will accept this as most of what I want.  I can begin working forward with this information in any case:
>>> os.system('chkdsk /V T:')
The type of the file system is NTFS.

WARNING!  F parameter not specified.
Running CHKDSK in read-only mode.

CHKDSK is verifying files (stage 1 of 3)...
48 file records processed.
File verification completed.
0 large file records processed.
0 bad file records processed.
0 EA records processed.
0 reparse records processed.
CHKDSK is verifying indexes (stage 2 of 3)...
132 index entries processed.
Index verification completed.
Detected minor inconsistencies on the drive.  This is not a corruption.
5 unindexed files processed.
CHKDSK is verifying security descriptors (stage 3 of 3)...
48 security descriptors processed.
Cleaning up 1 unused index entries from index $SII of file 9.
Cleaning up 1 unused index entries from index $SDH of file 9.
Cleaning up 1 unused security descriptors.
Security descriptor verification completed.
11 data files processed.

  78440670 KB total disk space.
   1049604 KB in 4 files.
        12 KB in 13 indexes.
         0 KB in bad sectors.
     68398 KB in use by the system.
     65536 KB occupied by the log file.
  77322656 KB available on disk.

      4096 bytes in each allocation unit.
  19610167 total allocation units on disk.
  19330664 allocation units available on disk.
2
>>>

Awesome, thanks.
0
 

Author Closing Comment

by:Laserwhit
Comment Utility
This is exactly what I was looking for except that I could still use more information.  I was hoping someone would find an external utility that would show me more a little more detail but his is still wonderful!
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Suggested Solutions

In this article you will get to know about pros and cons of storage drives HDD, SSD and SSHD.
The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now