Owlguru
asked on
Disk Cluster Size
Simple: How do I get the disk cluster size of a partition using WMI (Windows Management Instrumentation)? This is since I'm developing in C# and can't use DeviceIoControl.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Chances are, the only non-default cluster sizes you'll ever find areon hard drives on custom built boxes. Note that includes custom configured commercial boxes.
Experimentation can also be done without writing files. Count the number of files in various size categories (0-512, 513-1k, 1k+1-2k, 2k+1-4k,...), posit a cluster size, then see if the results jibe with reported space available. If they don't, try a different size. Unless a device has a weird cluster size, you'll hit on the right one eventually.
Specifically, cou
My preference would be chkdsk, assuming it's available and gives cluster size under your target OS's. Any variations in OS specific output formatting can be dealt with easily. Granted, though, it's not a very sexy solution.
Experimentation can also be done without writing files. Count the number of files in various size categories (0-512, 513-1k, 1k+1-2k, 2k+1-4k,...), posit a cluster size, then see if the results jibe with reported space available. If they don't, try a different size. Unless a device has a weird cluster size, you'll hit on the right one eventually.
Specifically, cou
My preference would be chkdsk, assuming it's available and gives cluster size under your target OS's. Any variations in OS specific output formatting can be dealt with easily. Granted, though, it's not a very sexy solution.
Ignore the 'Specifically, cou'.
Damned bifocals.
Damned bifocals.
ASKER
Isn't CHKDSK kinda slow? (It takes a while to finish checking the disk) Also, on Windows 2000 or XP, CHKDSK didn't display the cluster size. I like the experimentation method, so I'm gonna use that. I haven't had time to test it yet.
Thanks for everything
Thanks for everything
Yeah, it's slow. BTW, I have it on 2k and xp.
Time for a duh moment. Wouldn't just creating a 1 byte file reduce the avaiable space by one allocation unit? Duh.
Time for a duh moment. Wouldn't just creating a 1 byte file reduce the avaiable space by one allocation unit? Duh.
ASKER
Well, I tried that. Doesn't work. The free space stays the same, causing the app to report a 0 KB cluster size.
ASKER
I think it might be because of WMI not updating the information, but even in drive properties, it doesn't change the free space. Weird.. I think the file is simply stored in the MFT (on the NTFS volume), because it's small enough. I heard somewhere, files under 512 bytes can be stored in the MFT.
ASKER
Never mind it works now. I created a 256.1 KB file, then subtracted the new free space from the old free space and then subtracted a further 256 KB. Is that OK or will I run into trouble on drives with 256 KB cluster sizes? (though I doubt there are any)
ASKER
Never mind it works now. I created a 256.1 KB file, then subtracted the new free space from the old free space and then subtracted a further 256 KB. Is that OK or will I run into trouble on drives with 256 KB cluster sizes? (though I doubt there are any)
ASKER
sorry.. seems refreshing the browser posts a comment again :s
ASKER
anyway I'm gonna grant you the 300 points since you gave me the idea of experimenting.
Well, if you come across an NT4.0 box with an 8-16gig drive with a 16-bit FAT and sector size above 512, you'll get a 256k cluster.
Sounds like a safe bet.
Sounds like a safe bet.
ASKER