VHDX File Creation and Formatting
Prerequisites
Before proceeding, ensure you have the following:
- A VHDX file (e.g., C:\mydisk.vhdx)
- A suitable tool for creating and formatting the VHDX file (e.g., Disk Management or PowerShell)
Test Setup
Follow these steps to create and format a VHDX file:
- Create or attach a VHDX file (e.g., C:\mydisk.vhdx)
- Create or format a partition on the VHDX file
- Do not assign a drive letter or mount point to the partition
Code Example
The following PowerShell example demonstrates how to create and format a VHDX file:
# Create a new VHDX file
New-VHD -Path C:\mydisk.vhdx -SizeBytes 1GB
# Create a new partition on the VHDX file
Initialize-Disk -Number 1 -PassThru | New-Partition -Size 1GB -AssignDriveLetter:$false
# Format the new partition
Set-Partition -Number 1 -UseMaximumSize | Format-Volume -FileSystem NTFS -Confirm:$false
In this article, we covered the process of creating and formatting a VHDX file using PowerShell. We also provided a test setup to follow along with the example.
References
- Book: "Microsoft Windows Server 2016 Inside Out" by Jeffery Hicks, et al.
- Article: "Creating and Attaching a VHDX Disk in Windows Server 2016" by Microsoft Docs
- Online Resource: "New-VHD, Initialize-Disk, New-Partition, Set-Partition, Format-Volume" by Microsoft TechNet