vendredi 30 mars 2012

Tester l'alignement des partitions

Pour des questions de performances, il est impératif que vos partitions soient aligner correctement (http://support.microsoft.com/kb/929491/en).
Mais comment tester cet alignement?

Le script Powershell suivant vous donnera l'information:


$wmiDiskPartition = get-wmiobject -class "Win32_DiskPartition" -namespace "root\CIMV2"
$wmiLogicalDisk = get-wmiobject -class "Win32_LogicalDiskToPartition" -namespace "root\CIMV2"
$MaListe=@()    
foreach ($partition in $wmiDiskPartition){
$MyResult=(($partition.StartingOffset) / 4096)
$d=New-Object PSObject
$d | Add-Member -Name Name -MemberType NoteProperty -Value ($partition.Name)
$Trouve=$False
foreach($part in $wmiLogicalDisk){
if( ((($part.antecedent).split("=")[1]).replace("""","")) -eq (($partition.Name).Replace("Disque n° ","Disk #").Replace("partition n° ","Partition #"))){
$Trouve=$True
$d | Add-Member -Name DriveLetter -MemberType NoteProperty -Value (($part.Dependent.split("=")[1]).replace("""",""))
}
}
if ($Trouve -eq $False){
$d | Add-Member -Name DriveLetter -MemberType NoteProperty -Value "N/A"
}
$d | Add-Member -Name BlockSize -MemberType NoteProperty -Value ($partition.BlockSize)
$d | Add-Member -Name NumberOfBlock -MemberType NoteProperty -Value ($partition.NumberOfBlocks)
$d | Add-Member -Name StartingOffset -MemberType NoteProperty -Value ($partition.StartingOffset)
$d | Add-Member -Name IsAligned -MemberType NoteProperty -Value ([int]$MyResult -eq $MyResult)
$MaListe+=$d
}
$MaListe | ft

1 commentaire:

  1. En réalité, il faut utiliser la commande suivante pour réellement voir les partitions non alignées:

    $MaListe | Where-Object { $_.NumberOfBlock -gt 512 } | ft

    RépondreSupprimer