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
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
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.
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
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
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
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
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
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
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
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
| 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 |