Windows Vista Forums

Getting the 'cluster size' of your hard disk?
  1. #1


    Marco Shaw Guest

    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 SpecsSystem Spec

  2. #2


    Hal Rottenberg Guest

    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 SpecsSystem Spec

  3. #3


    Matthias Tacke Guest

    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 SpecsSystem Spec

  4. #4


    Dean Wells \(MVP\) Guest

    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 SpecsSystem Spec

  5. #5


    Matthias Tacke Guest

    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 SpecsSystem Spec

  6. #6


    Dean Wells \(MVP\) Guest

    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 SpecsSystem Spec

  7. #7


    Kiron Guest

    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 SpecsSystem Spec

  8. #8


    Kiron Guest

    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 SpecsSystem Spec

  9. #9


    Matthias Tacke Guest

    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 SpecsSystem Spec

  10. #10


    Kiron Guest

    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 SpecsSystem Spec

Page 1 of 2 12 LastLast
Getting the 'cluster size' of your hard disk? problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
VPC 2007 - how to shrink the virtual hard disk size Alan T Virtual PC 4 22 Oct 2009
RE: increase hard disk size Jesper Virtual PC 7 12 Feb 2009
Hard Disk Size Discrepancy Crimsom Virtual PC 8 24 Nov 2008
Changing size of Virtual PC 2007 hard disk kselman Virtual PC 8 13 Aug 2008
Cluster size question Andy Dean Vista installation & setup 3 05 Dec 2006