![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| | |||||||
| |
| 07-13-2007 | #1 (permalink) |
| | Getting the 'cluster size' of your hard disk? Is there an easy way to get the cluster size setting on a hard disk? Couldn't seem to find anything in WMI or in any of the .NET classes... Marco |
| My System Specs |
| 07-13-2007 | #2 (permalink) |
| | Re: Getting the 'cluster size' of your hard disk? On Jul 13, 11:00 pm, Marco Shaw <marco.shaw@_NO_SPAM_gmail.com> wrote: > Is there an easy way to get the cluster size setting on a hard disk? Hmm.... I see a few references to win32_Volume, but the class doesn't exist on my system. |
| My System Specs |
| 07-14-2007 | #3 (permalink) |
| | Re: Getting the 'cluster size' of your hard disk? Marco Shaw wrote: > Is there an easy way to get the cluster size setting on a hard disk? > > Couldn't seem to find anything in WMI or in any of the .NET classes... > Hi Marco, the hard disk has only a sector size. Cluster size is a matter of formatting. Try this: fsutil fsinfo ntfsinfo c: HTH -- Greetings Matthias |
| My System Specs |
| 07-14-2007 | #4 (permalink) |
| | Re: Getting the 'cluster size' of your hard disk? FWIW, I'm able to get at that info. through WMIC which would almost certainly indicate it's available through WMI directly - wmic partition get blocksize -- Dean Wells [MVP / Directory Services] MSEtechnology [[ Please respond to the Newsgroup only regarding posts ]] R e m o v e t h e m a s k t o s e n d e m a i l "Marco Shaw" <marco.shaw@_NO_SPAM_gmail.com> wrote in message news:eRpRoMcxHHA.2040@TK2MSFTNGP03.phx.gbl... > Is there an easy way to get the cluster size setting on a hard disk? > > Couldn't seem to find anything in WMI or in any of the .NET classes... > > Marco |
| My System Specs |
| 07-14-2007 | #5 (permalink) |
| | Re: Getting the 'cluster size' of your hard disk? Dean Wells (MVP) wrote: > FWIW, I'm able to get at that info. through WMIC which would almost > certainly indicate it's available through WMI directly - > > wmic partition get blocksize > Set seems to return the sector size (512 bytes), not the cluster size which is by default 4096 bytes on ntfs formatted drives. -- Greetings Matthias |
| My System Specs |
| 07-14-2007 | #6 (permalink) |
| | Re: Getting the 'cluster size' of your hard disk? Nod, ... looks like you're right. My apologies, I didn't examine the results closely enough (FWIW - a bad use of terminology in my opinion; to me, block is a logical partitioning unit ... c'est la vie.) Thanks Matthias. -- Dean Wells [MVP / Directory Services] MSEtechnology [[ Please respond to the Newsgroup only regarding posts ]] R e m o v e t h e m a s k t o s e n d e m a i l "Matthias Tacke" <Matthias@Tacke.de> wrote in message news:f7amtg$lia$1@news.albasani.net... > Dean Wells (MVP) wrote: >> FWIW, I'm able to get at that info. through WMIC which would almost >> certainly indicate it's available through WMI directly - >> >> wmic partition get blocksize >> > Set seems to return the sector size (512 bytes), not the cluster size > which is by default 4096 bytes on ntfs formatted drives. > > -- > Greetings > Matthias |
| My System Specs |
| 07-14-2007 | #7 (permalink) |
| | Re: Getting the 'cluster size' of your hard disk? For those of us that don't have access to win32_Volume. This is, by no means, a lighting fast solution. WARNING: Depending on the drive's size, this function takes up to five minutes per drive, because it reads chkdsk.exe's output to determine the cluster size. The size is shown in bytes. function Get-ClusterSize ([char[]]$driveLetter = 'c') { $clusterSize = @{} foreach ($drive in $driveLetter) { $drive = $($drive + ':').toUpper() if (test-path $drive) { chkdsk $drive > outPut $line = (select-string each outPut).line remove-item outPut [regex]$rx = '\d+' $size = $rx.Match($line).value $drive = $drive -replace ':' $clusterSize.$drive = $size } else {"Drive $drive was not found"} } $clusterSize | format-table -auto -hide } Get-ClusterSize c, d C 4096 D 4096 If the function is dot sourced you can access a drive's cluster size like: $clusterSize.d 4096 -- Kiron |
| My System Specs |
| 07-14-2007 | #8 (permalink) |
| | Re: Getting the 'cluster size' of your hard disk? Adjusted with Matthias' solution for NTFS drives only: Lighting fast. function Get-ClusterSize ([char[]]$driveLetter = 'c') { $clusterSize = @{} foreach ($drive in $driveLetter) { $drive = $($drive + ':').toUpper() if (test-path $drive) { fsutil fsinfo ntfsinfo $drive > outPut $line = (select-string 'Bytes Per Cluster' outPut).line remove-item outPut [regex]$rx = '\d+' $size = $rx.Match($line).value $drive = $drive -replace ':' $clusterSize.$drive = $size } else {"Drive $drive was not found"} } $clusterSize | format-table -auto -hide } Get-ClusterSize c, d C 4096 D 4096 If the function is dot sourced you can access a drive's cluster size like: $clusterSize.d 4096 -- Kiron |
| My System Specs |
| 07-14-2007 | #9 (permalink) |
| | Re: Getting the 'cluster size' of your hard disk? Kiron wrote: > Adjusted with Matthias' solution for NTFS drives only: > Lighting fast. > > function Get-ClusterSize ([char[]]$driveLetter = 'c') > { > $clusterSize = @{} > foreach ($drive in $driveLetter) > { > $drive = $($drive + ':').toUpper() > if (test-path $drive) > { > fsutil fsinfo ntfsinfo $drive > outPut > $line = (select-string 'Bytes Per Cluster' outPut).line > remove-item outPut > [regex]$rx = '\d+' > $size = $rx.Match($line).value > $drive = $drive -replace ':' > $clusterSize.$drive = $size > } > else {"Drive $drive was not found"} > } > $clusterSize | format-table -auto -hide > } > > Get-ClusterSize c, d > > C 4096 > D 4096 > > If the function is dot sourced you can access a drive's cluster size like: > > $clusterSize.d > 4096 > Hi Kiron, the output of fsutil is locale dependent. My German version has 'Bytes pro Cluster :' so: $line = (select-string 'Byte.*Cluster' outPut).line should be a bit more universal albeit not perfect. -- Greetings Matthias |
| My System Specs |
| 07-14-2007 | #10 (permalink) |
| | Re: Getting the 'cluster size' of your hard disk? Thanks for pointing that out, and for your solution. The good thing is that the script is easy to adjust depending on the locale. Danke ![]() -- Kiron |
| My System Specs |
| Thread Tools | |
| |
| Similar topics to: Getting the 'cluster size' of your hard disk? | ||||
| Thread | Forum | |||
| VPC 2007 - how to shrink the virtual hard disk size | Virtual PC | |||
| RE: increase hard disk size | Virtual PC | |||
| Hard Disk Size Discrepancy | Virtual PC | |||
| Changing size of Virtual PC 2007 hard disk | Virtual PC | |||
| Cluster size question | Vista installation & setup | |||