As part of a Storage I/O review, discussions whether our disks are properly aligned came back up.
The specific Knowledge Base article that I was pointed to is :
How to diagnose misaligned I/O on Windows hosts
It is a recently published NetApp article; as its publish date is 2013.02.27.
Though a short article, there is a lot in it.
There are two areas that I will like to cover in this posting; those areas are StartingOffset and Partition Style.
Depending on the Version of Windows (OS Version) , Partition Style, and your LUN size, your gold standard for “Starting offset” appears to vary a bit.
Here are the Numbers published by NetApp:
- For Windows MBR, this number should be 32256, 31.5kb offset is used when the LUN is created with the Windows LUN type (31.5 * 1024 = 32256).
- For Windows GPT, this number should be 65535 bytes for LUNs smaller than 4GB or 1048576 bytes for LUNs that are 4GB or larger.
- For Windows 2008+, this number should be 65535 bytes for LUNs smaller than 4GB or 1048576 bytes for LUNs that are 4GB or larger
- Windows MBR, 32556
- Windows GPT, disk size < 4 GB, then 65535 : else disk size >= 4GB, then 1048576
There are a couple of procedures you can employ to determine your Starting Offset:
- Windows Management Interface (WMI)
wmic partition get BlockSize, StartingOffset, Name
- In our case, it reads 6.1.7601 –> 6.1 is MS Windows 2008 R2 ( http://en.wikipedia.org/wiki/Windows_NT_6.1 )
- 6.1.7601 –> Windows 2008-R2 SP1 ( http://en.wikipedia.org/wiki/Windows_7 )
- On the disk we are most interested in, Disk 4, our Starting Offset is 1048576. That number matches up with NetApp guidance.
Microsoft supports a couple of partition styles, MBR and GPT.
- MBR — Legacy partition
- GPT – new partition
There a couple of ways to determine your partition style:
- GUI – Disk Management
- DiskPart / list disk
Partition Style – Detect via Disk Management
Here are the steps:
- Launch “Computer Management”
- On the left panel, transverse to “Storage” \ “Disk Management”
- The list of available disks are displayed on the right panel
- On the right panel, select the disk you are interested in — make sure you select the physical disk, and not logical disk
- Right click on your selected physical disk, and select “Properties” from the drop-down menu
- Notice that the name of the window that shows up will very based on whether this is a local disk, a SAN disk and the Disk Vendor
- Proceed to the “Volumes” tab
Here is what shows up for us:
Partition Style – Via DiskPart / listdisk
Here are the steps:
- Launch OS Shell
- Start diskpart interactively (diskpart)
- Issue “List Disk“
To determine which disks are GPT, follow the GPT column.
If a disk has the asterisk symbol, then it is GPT. Else, it is not…
The two checks we performed conclusively affirm that our “Disk 4” is in fact MBR. How could this be:
So went back and looked at our scripts:
select disk 4 create partition primary align=1024 assign letter=V format fs=ntfs unit=64k label="Disk - Temp" quick
The script looks good:
- I know I got in it from an online source
- Googled for it, and found a semblance @ Disk Partition Alignment Best Practices for SQL Server
Googled some more and found out what is wrong:
- The Create partition syntax does not allow us to directly set the Partition Style
To correct your script for the future, have it resemble something along the likes of:
select disk 4 clean convert gpt offline disk online disk attribute disk clear readonly create partition primary align = 1024 assign letter=V format fs=ntfs unit=64k label="Disk - Temp" quick
Please show and demonstrate extraordinary care when preparing to issue the script above:
- Make sure you have selected the right disk (Select disk 4)
- Notice the use of “clean” — It destroys the disk
- Convert gpt –> Converts the partition to gpt; the default is mbr
- Notice the use of “attribute disk clear readonly”; It says to the disk remove the armor you place on formatted and in-use disk
- If your disk is more than 2 TB, then you can only use 2GB of it
- There are many limitations with legacy MBR – Those limitations are covered in “Understanding the 2 TB Limit in Windows Storage”
- MBR disks have a maximum of four partition table entries
- “The GPT disk partition format is well defined and fully self-identifying. Data critical to platform operation is located in partitions and not in unpartitioned or “hidden” sectors. GPT disks use primary and backup partition tables for redundancy and CRC32 fields for improved partition data structure integrity. The GPT partition format uses version number and size fields for future expansion”
Is there a performance penalty with choosing either MBR or GPT as your Partition Style. Googled for help, and there does not appear to be.
Please keep in mind that the partition style does not affect the way your data is written out, it has more to do with your partition table.
And, Microsoft will not let you get away with a wrong choice (ie MBR) for disks bigger than 2TB.
- How to diagnose misaligned I/O on Windows hosts
- How to check filesystem alignment on Windows Dynamic Disks
- Windows and GPT FAQ
- Understanding the 2 TB Limit in Windows Storage
References – GPT ( Processing)
- Change a Master Boot Record Disk into a GUID Partition Table Disk
- Pro SQL Server 2008 – Failover Clustering (Allan Hirt)
- Adding new GPT and MBR disks to Windows Server 2008 Systems http://www.techotopia.com/index.php/Adding_New_GPT_and_MBR_Disks_to_Windows_Server_2008_Systems
- How to use diskpart to format a drive to GPT
- How to convert MBR Disk to GPT Disk?
- Installing and Managing Hard Disks
References – Vendor
References – Vendor – NetApp:
- How to check filesystem alignment on Windows dynamic disks
- Use of GPT partition tables on Windows can cause data misalignment (Bug ID: 177471)