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

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.
LaserwhitAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

number1prideCommented:
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
LaserwhitAuthor Commented:
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
LaserwhitAuthor Commented:
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
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

peprCommented:
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
peprCommented:
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
noxchoGlobal Support CoordinatorCommented:
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
peprCommented:
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
LaserwhitAuthor Commented:
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
noxchoGlobal Support CoordinatorCommented:
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
LaserwhitAuthor Commented:
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
LaserwhitAuthor Commented:
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
noxchoGlobal Support CoordinatorCommented:
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
LaserwhitAuthor Commented:
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
clockwatcherCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LaserwhitAuthor Commented:
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
LaserwhitAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Python

From novice to tech pro — start learning today.