Microsoft has wonderfull products, and Windows Server 2003 and Windows 2008(R2) are fine examples of it. Before starting with all the disk alignment details, I would like to explain a little bit about the wmic.exe command which can be executed on all normal workstations with Windows XP pro, Vista, Windows 7, Windows 8 and all server versions. These letters are short for "Windows Management Instrumentation Command" but now everyone is calling it just WMI. A lot of people are not familiar with the WMI commands, but a lot of programs are using it "underwater". The scripting guys among us, will know it for sure. This command can retrieve almost any data from a machine, bios or software, as a separate process, it just needs to be available somewhere, and you should know where and how to find it! The WMI APP's have been introduced a long, long time ago, but haven't had the attention from programmers and developers until lately. Now today, we are going to use this wmic command to retrieve the exact disk alignment of a (virtual)machine. Wrong disk alignment is absolutely killing for the performance and it will also decrease the lifetime of a disk, basically because the disk (i/o) reads and writes almost everything twice. For details on that why and how, just Google around a bit. There are lots of articles that explains very how clusters, blocksizes and chunks should be setup, and what wrong disk-alignment actually does with your disk i/o. It is caused by creating disk partitions through the GUI instead of a command line mainly, but external disks, USB sticks and SSD drives have wrong alignment out of the box for several reasons. Less lifetime, will mean quicker (sales) replacement, but other operating systems can prefer other use of the device, so everyone just does it the wrong way! Out of the box, Windows XP, Windows 2003, Vista and VMware ESX3 are doing this the wrong by default. The repaired that for more recent operating systems and Windows 2008 server, Windows 7 & 8 and VMware ESX4 are aligning out of the box the correct way now. Even then a check is preferred as systems are often upgraded or migrated, and their original settings are copied with them. Please keep that in mind. Lets just concentrate in this article on detecting and solving disk aligment problems.


Now, how do list the disk alignment of your (virtual) machine?

On Vmware level the administrator can run the command:  fdisk -lu 
As output there will be a lot of numbers, but the only import thing is the boot number which should be 128. Thats good, anything else is wrong.
To setup a virtual disk with correct alignment follow these steps:
1.            Enter fdisk/dev/sd<x> where <x> is the device suffix. 
2.            Determine if any VMware VMFS partitions already exist. VMware VMFS partitions are identified by a partition system ID of fb. Type d to delete to delete these partitions. 
    Note: This destroys all data currently residing on the VMware VMFS partitions you delete. Ensure you back up this data first if you need it. 
3.            Type n to create a new partition. 
4.            Type p to create a primary partition. 
5.            Type 1 to create partition No. 1. 
6.            Select the defaults to use the complete disk. 
7.            Type t to set the partition’s system ID. 
8.            Type fb to set the partition system ID to fb (VMware VMFS volume). 
9.            Type x to go into expert mode.
10.          Type b to adjust the starting block number. 
11.          Type 1 to choose partition 1. 
12.          Type 128 to set it to 128 (the array’s stripe element size). 
13.          Type w to write label and partition information to disk.
These steps are directly from VMware's white paper "Recommandations for Aligning VMFS partions". Just google it.
It is very usefull, and it descripes clearly all the backgrounds on clusters, sectors chunks and VM's.



No for the VM itself, or your iron hardware,.....
First of all you need to open an (elevated) command prompt on the machine it concerns.
I guess I do not have to explain how you do that, I suppose,...
You can play around whatever you want with wmic as long as you use the "get" command.
Just like todays powershell commands, it does not change anything, just retrieves data and will not harm your system in any way.

You can directly start typing the following command:
wmic partition get Blocksize, StartingOffset, Name, Index
This is the command to retrieve all starting offsets and blocksize of your partitions.
Some additional information. It is possible that you get a small line on your screen,
when you've never used wmic before which says: "Wait while wmic is being installed." Do not worry, this is normal,
can do no harm to your system and it will disappaer on executing your commandline.

The output will be something like:
BlockSize   Index   Name                          StartingOffset
512             0           Disk#0, Partition #0     32256
On multiple parttions, multiple lines will appaer.
The StartingOffset should not be 32256. Why is that? The utmost simple explanation is a little calculation.
The blocksize = 512 and we devide that through the startingoffset 32256 to calculate the number of sectors is uses.
32256 / 512 = 63 for the start sector. This should be a multiple from 8 and therefore 63 is incorrect, it should be 64.
So always look for the number 32256 and you know the disk alignment is wrong. You can also type in MSINFO32.exe on a (run)command-line and look at Components, Storage, and then Disks. Under Partition Starting Offset it will display 32256 bytes if the alignment is wrong.


What has disk alignment to do with performance?
Easy, it can decrease your disk i/o's with almost 50%. The slowest thing in any computer is always the disk, 
and therefore correct alignment will increase your overall performance with 50%! Wurth looking at I would say!


How to solve your disk alignment:
There are 2 options, creating a new disk and align it by hand and using a tool. The most save option is to create a new partition and to move your data. Remember that moving data from a parttion that has a boot record, can cause starting problems. Open an elevated command prompt and start diskpart, and then press ENTER. Type list disk and press Enter. Type select disk x and press enter, where x is the disk to be used. To create a new partition type create partition primary align=1024 followed by Enter. Type exit, and then press ENTER. After this you can format the parttion and give it a drive letter the way you usually do through Disk Management. Keep in mind to use the correct cluster size. Depending on the targettype it will be somewhere between 512 bytes and 64KB, but neither of these setting will lead to a wrong alignment configuration.  


Using a tool to correct disk aligment:
I initiated this article because I often use this tool. It is handy and easy to use, as long as keep a couple of things in mind. There a several tools that can do the same, like the voptimizer from Quest software, or the VMware converter tools, but my tool choice for this is the Paragon Alignment Tool (PAT). How good any tool can be, always make sure you have a backup of the disks/partitions that you want to change the disk alignment of. It is always better to be, and work on the safe site. In addition to this, execute a checkdisk command before start using this tool. Lost or un-recoverable sectors will absolutely cause troubles and data coruption will happen. 


Install the tool on your system, give in the serial/license number and the tool will start with checking all the attached disks, including attached (external) (USB) drives. www.Oostdam.Info - The paragon Alignment tool - picture 1

By default, all disks that can be optimized will be checked, so do not forget to uncheck your OS disk. Re-alignment of your systemdisk will often change your MBR (Master Boot Records) sectors and your machine will not startup anymore. Be carefull for that. The way to go for changing your disk alignment on your boot disk, is to create a new disk with the same size, correctly formatted, besides it, and use some kind of "ghost" tool to to copy the data. Thats the only way I'm absolutely sure it works.  

The GUI colors are easy, green disk and the alignment is good, yellow disk and the tool can correct it for you, red disk and the tool cannot help you. Red disks will be displayed when it is formatted as a Linux, Mac or Unix partition. Use other tools for that.

An indicating of the time remaining is also shown at the left button, so you can do something else in the meantime.

www.Oostdam.Info - The paragon Alignment tool - picture 2
It can happen that you find a message like this on your screen.
In that case, most likely you did not execute the preferred checkdisk command I mentioned at the start, but on older systems it can be a simple resource problem as well.

I did some testing with ignoring the errors, and allthough the tool ended with a "Disk not Aligned"; after booting the system, the StartingOffset was correct and fast, with all my data in a correct state. So.... Do not worry, certainly not if you previously made that backup!

In most cases the tool ends with a green text "Disk Aligned", and the disk can be browsed again through the explorer. On starting the re-alignment, the tool will exclusively claim the partition and remove it from explorer while processing. Please do check the assigned driveletters and previous shares if there where any. It is likely that there gone and you have to set that up again. A little extra work, but it will give you a much better performance.

Please never turn of the power or disconnect the USB cable while the tool is processing a disk. The disk will become useless and your data will be gone. In some cases I saw that the drive letters and shares on it, disappeared from the disk on re-alignment, check that after the reboot and assign the drive letters and shares again.


These actions seems all heavy and dangerous, but with some practice and some normal thinking, it isn't dangerous at all. The performance will increase heavely, and you will never find the guy that installed the system in the beginning.


Hope this information helped you on the way, and if you don't want to buy the tool?
Walk by my desk,... I have the Paragon tool installed by default.


-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Ben OostdamBen Oostdam has been working with Windows systems since 1993. Worked for several companies as a system administrator, and is currently a Senior Support Engineer for a large company in the Netherlands.

Disclaimer: The information contained in this website/article is for general information purposes only. The information is provided as is, by Ben Oostdam and while we endeavour to keep the information up to date and correct, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the website or the information, products, services, or related graphics contained on the website for any purpose. Any reliance you place on such information is therefore strictly at your own risk. In no event will we be liable for any loss or damage including without limitation, indirect or consequential loss or damage, or any loss or damage whatsoever arising from loss of data or profits arising out of, or in connection with, the use of this website. Through this website you are sometimes able to link to other websites which are not under my control. I have no control over the nature, content and availability of those sites. The inclusion of any links does not necessarily imply a recommendation or endorse the views expressed within them. Every effort is made to keep the website up and running smoothly. However, I take no responsibility for, and will not be liable for, the website being temporarily unavailable due to technical issues beyond our control. All entries in these articles, are my individual opinion, or from co-writers and they don't necessary reflect the opinion of my employer.




 

Tuesday the 16th, July 2019. All rights reserved.. // Oostdam WebDesign