Il formato VHDX

imageCon Windows Server 2012 è stato introdotto un nuovo formato per i dischi virtuali denominato VHDX che apporta una serie di miglioramenti:

  • Supportano fino a 64 TB (contro i 2 TB dei VHD)
  • Garantiscono una maggior protezione dei dati da fail dovuti a mancanza di corrente
  • Migliorano l’allineamento dei VHD per lavorare su dischi con settori di grandi dimensioni
    • I dischi dinamici e differenziali possono utilizzare block size di dimensioni maggiori
    • E’ stato introdotto un 4-KB logical sector virtual disk che aumenta le performance nelle applicazioni/workloads progettati per settori 4 KB.
  • Consentono il salvataggio di metadati custom che l’utente potrebbe voler memorizzare (versione OS, patch applicate)
  • Consentono il Trim ovvero permette allo storage fisico di recuperare lo spazio non utilizzato

Per la precisione anche i VHD in Windows Server 2012 hanno subito dei miglioramenti come indicato nella Performance Tuning Guidelines for Windows Server 2012, infatti i VHD creati in WS2012 sono ottimizzati per l’allineamento a 4 KB:

“The VHD format was the only virtual hard disk format that was supported by Hyper-V in past releases. In Windows Server 2012, the VHD format has been modified to allow better alignment, which results in significantly better performance on new large sector disks.

Any new VHD that is created on a Windows Server 2012 operating system has the optimal 4 KB alignment. This aligned format is completely compatible with previous Windows Server operating systems. However, the alignment property will be broken for new allocations from parsers that are not 4 KB alignment-aware (such as a VHD parser from a previous version of Windows Server or a non-Microsoft parser).

Any VHD that is moved from a previous release does not automatically get converted to this new improved VHD format.

You can check the alignment property for all the VHDs on the system, and it should be converted to the optimal 4 KB alignment. You create a new VHD with the data from the original VHD by using the Create-from-Source option.

By default, VHDs are exposed with a physical sector size of 512 bytes. This is done to ensure that physical sector size dependent applications are not impacted when the application and VHDs are moved from a previous version of Windows Server to Windows Server 2012.

After you confirm that all VHDs on a host are not impacted by changing the physical sector size to 4 KB, you can set the following registry key to modify all the physical sector sizes of all the VHDs on that host to 4 KB. This helps systems and applications that are 4 KB-aware to issue 4 KB sized I/Os to the VHDs.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\vhdmp\Parameters\ Vhd1PhysicalSectorSize4KB = (REG_DWORD)

A non-zero value will change all VHDs to report 4k physical sector size.

By default, disks with the VHDX format are created with the 4 KB physical sector size to optimize their performance profile regular disks and large sector disks.”

In WS2012 è stato introdotto il supporto per i Native 4 K Disks (avevo parlato di questa problematica nel post Windows 2008 R2: Errore 517 durante il backup). Quindi Hyper-V può memorizzare i virtual disk su questi dischi come riportato nella Performance Tuning Guidelines for Windows Server 2012:

“Hyper‑V in Windows Server 2012 makes it possible to store virtual hard disks. This is done by implementing a software RMW algorithm in the virtual storage stack layer that converts 512-byte access and update requests to corresponding 4 KB accesses and updates.

Because VHD file can only expose themselves as 512-byte logical sector size disks, it is very likely that there will be applications that issue 512-byteI/O requests. In these cases, the RMW layer will satisfy these requests and cause performance degradation. This is also true for a disk that is formatted with VHDX that has a logical sector size of 512 bytes.

It is possible to configure a VHDX file to be exposed as a 4 KB logical sector size disk, and this would be an optimal configuration for performance when the disk is hosted on a 4 KB native physical device. Care should be taken to ensure that the guest and the application that is using the virtual disk are backed by the 4 KB logical sector size. The VHDX formatting will work correctly on a 4 KB logical sector size device.”

Di seguito lo schema del formato dei file VHDX:

image

 

Le parti che compongono un VHDX sono strutture che, come detto precedentemente supportano, large allocation e sono 1 MB aligned. Nel dettaglio tali strutture sono:

  • L’Header region che identifica la posizione della altre region (log, BAT e metadata table). E’ composta da due header, ma che non sono mai contemporaneamente attive per aumentare la resilienza ed evitare la corruzione.
  • L’Intent log è un buffer circolare in cui vengono scritte le modifiche alle metastrutture del VHDX prima di essere scritte nella locazione finale. In questo modo nel caso si verifichi un’interruzione di corrente durate la scrittura alla successiva riapertura le modifiche saranno riapplicate dal log permettendo al VHDX di ritornare in uno stato consistente. Il log non mantiene le modifiche del payload blocks, quindi no protegge i dati in essi contenuti
  • La Data region che è composta dalla BAT che contiene i puntatori ai user data blocks e ai sector bitmap block. Nel VHD invece i sector bitmaps sono aggregati nei loro blocks invece di essere posizionati in testa ad ogni payload block.
  • La Metadata region che contiene una tabella di puntatori ai user-defined metadata e ai virtual hard disk file metadata (block size, physical sector size e logical sector size)

I requisiti per l’utilizzo dei VHDX sono:

  • Sistema operativo Windows Server 2012/Windows 8 o superiore
  • Ruolo Hyper‑V
  • Per poter utilizzare la funzionalità di trim occorre:
    • Hardware Trim-capable, ovvero in grado di inviare le unmap notifications che Hyper-V in WS 2012 è in grado di gestire.
    • I VHDX devono essere connessi come virtual SCSI devices  o come directly attached physical disks (detti anche pass-through disks) o come natively attached VHDX-based virtual disks.

Per ulteriori approfondimenti sulla funzionalità di Trim si veda quanto riportato nella Performance Tuning Guidelines for Windows Server 2012:

“Virtual hard disk files exist as files on a storage volume, and they share available space with other files. Because the size of these files tends to be large, the space that they consume can grow quickly. Demand for more physical storage affects the IT hardware budget, so it’s important to optimize the use of physical storage as much as possible.

Currently, when applications delete content within a virtual hard disk, which effectively abandons the content’s storage space, the Windows storage stack in the guest operating system and the Hyper-V host have limitations that prevent this information from being communicated to the virtual hard disk and the physical storage device. This prevents the Hyper-V storage stack from optimizing the space usage by the VHDX-based virtual disk files. It also prevents the underlying storage device from reclaiming the space that was previously occupied by the deleted data.

In Windows Server 2012, Hyper-V supports unmap notifications, which allow VHDX files to be more efficient in representing that data within it. This results in smaller files size, and it allows the underlying physical storage device to reclaim unused space.

Only Hyper-V-specific SCSI, Enlightened IDE and virtual Fibre Channel controllers allow the unmap command from the guest to reach the host virtual storage stack. Hyper-V-specific SCSI is also used for pass-through disks. On the virtual hard disks, only virtual disks formatted as VHDX support unmap commands from the guest.

For these reasons, we recommend that you use VHDX files attached to a SCSI controller when not using regular pass through or virtual Fibre Channel disks.

Conclusioni

Nel caso in cui si migrino le VM su WS2012 da sistemi precedenti è consigliabile convertire i VHD al nuovo formato VHDX come indicato nella Performance Tuning Guidelines for Windows Server 2012:

“When you upgrade to Windows Server 2012, we recommend that you convert all VHD files to the VHDX format due to these benefits. The only scenario where it would make sense to keep the files in the VHD format is when a virtual machine has the potential to be moved to a previous release of the Windows Server operating system that supports Hyper-V.”

E’ possibile convertire i VHD in VHDX tramite la console Hyper-Manager tramite la funzionalità “Edit Disk…” (a riguardo si veda Converting a VHD to a VHDX).

L’unico caso in cui può avere un senso non migrare il formato da VHD a VHDX è quello in cui si prevedere di spostare le VM su versioni precedenti di Hyper-V (come ad esempio WS2008 R2). Per un prova sul campo dei benefici ottenuti nella migrazione da VHD a VHDX grazie al supporto large sector disks e ai 4 KB logical sector si veda Why you want to be using VHDX in Hyper-V whenever possible and why it’s important to know your baselines.

Se desiderate provare le funzionalità di WS2012 R2 vi ricordo che su TechNet Evaluation Center è possibile scaricare la versione di valutazione di Windows Server 2012 R2, mentre il 17-18-19 dicembre a Catania si terranno una serie di IT Camp su WS2012 R2, System Center 2012 R2 e W8.1.