Home > VMware > VMFS and VM guest disk alignment, puts fingers in his ears, la la la

VMFS and VM guest disk alignment, puts fingers in his ears, la la la

To understand Guest OS blocks / VMFS / Array alignment read Duncan Epping’s post but in simple terms clusters or blocks that span more than one chunk, require two chunks to be read instead of one.
The bottom line is misaligned OS blocks and VMFS’s will negativity impact performance, how much of a performance impact there will be depends on the storage and the I/O pattern of the VM.

http://www.yellow-bricks.com/2010/04/08/aligning-your-vms-virtual-harddisks/

VMFS alignment:

VMFS’s are always aligned if they are created using the VI client, resist the temptation to use vmkfstools to create them. To check the VMFS alignment connect to the ESX console and ensure blocks start at 128 using the fdisk command:
fdisk –lu

Guest OS alignment:

Checking the guest disk alignment is opening a can of worms, nine times out of ten you will find misaligned disks for Windows 2003 or earlier versions. Windows Server 2008 and later should align disks correctly automatically. http://frankdenneman.nl/2009/05/windows-2008-disk-alignment/

Once you have identified misaligned disks, you need to work out if you’re going to do something about it, to fix the alignment.

Recommend aligning VM disks in the following circumstances:

• VM Templates, OS and Data partitions should always be aligned.
• VM’s partitions that will have higher I/O like File Servers, SQL db’s or Exchange Datastores.

Recommend against aligning VM disks in the following circumstances:

• VM system disks for VM’s that have been P2V’d unless there is a good reason, it’s not worth the effort involved. Better still migrate the applications and data to cleanly created VM’s.
• Alignment of all VM disks for the sake of it, it’s not worth the effort involved.

How to check VM alignment

To check a VM, run this from the command prompt, any partition with an offset of 1048576 is aligned unless it is under 4GB, otherwise it will be 65536.

wmic partition get Index, Name, StartingOffset

Or you can use this script, it will list of the VM’s in the vCenter that you connect to and produce a csv defining which VM’s have aligned disks and which don’t.

Add-PSSnapIn VMware.VimAutomation.Core
# Connect to vCenter
$VC = Connect-VIServer (Read-Host “Enter vCenter server”)
$myCol = @()
$vms = get-vm | where {$_.PowerState -eq “PoweredOn” -and `
$_.Guest.OSFullName -match “Microsoft Windows*” } | Sort Name
foreach($vm in $vms){
$wmi = get-wmiobject -class “Win32_DiskPartition” `
-namespace “root\CIMV2” -ComputerName $vm

foreach ($objItem in $wmi){
$Details = “” | Select-Object VMName, Partition, Status
if ($objItem.StartingOffset -eq “1048576”){
$Details.VMName = $objItem.SystemName
$Details.Partition = $objItem.Name
$Details.Status = “Partition aligned”
}
else{
$Details.VMName = $objItem.SystemName
$Details.Partition = $objItem.Name
$Details.Status = “Partition NOT aligned”
}
$myCol += $Details
}
}
$myCol | Export-Csv -NoTypeInformation “C:\temp\PartitionAlignment.csv”
#$myCol | Export-Clixml “C:\temp\PartitionAlignment.xml”

Both Waste finder and GParted can also help us to find and resolve misalignment.
Refer here: http://read.virtualizeplanet.com/?p=8

Vizioncore has a product VOptimizer that can do the job too.
http://vizioncore.com/products/vOptimizerPro/

Manually Fixing Guest OS disk alignment

http://support.microsoft.com/kb/929491

Present new disks to a VM then use diskpart to format and align the disk, run these at the command prompt.

diskpart
list disk
select disk x
attributes disk clear readonly
online disk
create partition primary
assign letter=x
format fs=ntfs unit=64K label=”scripted” nowait

Diskpart Script

For this example, a diskpart script is used to create a primary partition on the last disk of the VM.
Insert the commands in a simple text document (script.txt) and issue the command: diskpart /s script.txt
Here’s what the script.txt looks like:

select disk 4
create partition primary
assign letter=G
format fs=ntfs unit=64K label=”scripted” nowait

Long story short, ensure you align VM templates and data disks when you add them to VM’s, understand which VM disks are aligned/unaligned and consider misalignment’s impact on your environment.

Advertisements
Categories: VMware
  1. No comments yet.
  1. January 2, 2011 at 10:39 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: