Advertisement

Create a New VHD or VHDX File in Windows 10

How to Create a New VHD or VHDX File in Windows 10

Windows 10 supports virtual drives natively. It is able to recognize and use ISO, VHD and VHDX files. For ISO files, Windows 10 creates a virtual disk drive. For VHD and VHDX files, Windows 10 creates a new drive accessible via the This PC folder in File Explorer. Also, these files can be used in Hyper-V machines. Today we will review various methods that you can use to create a new VHD or VHDX file.

Advertisеment

The Virtual Hard Disk (VHD) file format allows encapsulation of the hard disk into an individual file for use by the operating system as a virtual disk in all the same ways physical hard disks are used. These virtual disks are capable of hosting native file systems (NTFS, FAT, exFAT, and UDFS) while supporting standard disk and file operations. The maximum size of a VHD file is 2,040 GB.

VHDX is a new version of the VHD format which has a much larger storage capacity than the older VHD format. It also provides data corruption protection during power failures and optimizes structural alignments of dynamic and differencing disks to prevent performance degradation on new, large-sector physical disks. It supports for virtual hard disk storage capacity of up to 64 TB.

Windows 10 supports two virtual disk types:

  • Fixed—The VHD image file is pre-allocated on the backing store for the maximum size requested.
  • Expandable—Also known as "dynamic", "dynamically expandable", and "sparse", the VHD image file uses only as much space on the backing store as needed to store the actual data the virtual disk currently contains. When creating this type of virtual disk, the VHD API does not test for free space on the physical disk based on the maximum size requested, therefore it is possible to successfully create a dynamic virtual disk with a maximum size larger than the available physical disk free space.

There are a number of methods you can use to create a new VHD or VHDX file in Windows 10. After that, you can assign it to a virtual machine or mount to the running system.

To Create a New VHD or VHDX File in Windows 10

  1. Press the Win + X keys together the keyboard.
  2. From the menu, select Disk Management.Win+X Menu Disk Management Command
  3. In Disk Management, select Action > Create VHD from the menu.Disk Management Create VHD
  4. Click on the Browse button to specify the desired VHD(X) file location.
  5. Disk Management Create VHD Dialog
  6. Enter a file size you want to create a VHD file of.Disk Management Specify VHD Size
  7. Select the file type (VHD or VHDX).
  8. Select Fixed size or Dynamically expanding according to what works best in your case.
  9. Click OK and you are done.

Voila, you just created a VHD file. The disk will appear in the Disk Management console.Disk Management VHD Is Created

There are alternative options that you can use to create a new VHD file.

Create VHD(X) File using Hyper-V Manager

  1. Open the Hyper-V Manager app (Win + R > type virtmgmt.msc into the Run box).
  2. Select a server on the left.
  3. On the right, click on New under Actions, and select Hard Disk.Hyper V Create VHD
  4. Click Next in the virtual disk wizard dialog.Hyper V New VHD Wizard 1
  5. Select VHD or VHDX for the disk format.Hyper V New VHD Wizard 2
  6. Select Fixed size or Dynamically expanding for the disk type you want.Hyper V New VHD Wizard 3
  7. Next, specify the directory path and the file name for your new VHD file.Hyper V New VHD Wizard 3a
  8. Select Create a new blank virtual hard disk and enter the desired disk size in GB.Hyper V New VHD Wizard 4
  9. Verify that everything is correct, and click on Finish.Hyper V New VHD Wizard 5

You are done.

Now, let's look on how it can be done with PowerShell.

Note: These PowerShell commands work only when the Hyper-V feature is enabled.

Create New VHD(X) File Using PowerShell

  1. Open PowerShell as Administrator.
  2. Execute te following command to create a fixed size VHD file: New-VHD -Path "Full\path\to\vhd\file" -Fixed -SizeBytes <size>.
  3. To create a dynamically expanding VHD, issue the command New-VHD -Path "Full path of .vhd or .vhdx location" -Dynamic -SizeBytes <size>.PowerShell Create VHD
  4. Substitute Full\path\to\vhd\file with the actual full path of the .vhd or .vhdx file where you want to store it.
  5. Substitute <size> with the maximum size (ex: "1GB") you want for the .vhd or .vhdx file. This can be expressed as in MB, GB, or TB.

Also, you can use the DiskPart tool to create a new VHD(X) file in Windows 10. Here's how.

Create New VHD or VHDX File with DiskPart

  1. Press Win + R shortcut keys on the keyboard to open the Run dialog.
  2. Type diskpart into the Run box and hit the Enter key. Confirm the UAC prompt.Windows 10 Run Diskpart
  3. Type the following command: create vdisk file="Full\path\to\vhd\file" maximum=<size> type=fixed. This will create a new fixed size VHD.
  4. To create a dynamically expanding VHD/VHDX file, execute the command: create vdisk file="Full\path\to\vhd\file" maximum=<size> type=expandable.DiskPart Create VHD
  5. Substitute Full\path\to\vhd\file with the actual full path of the .vhd or .vhdx file for where you want to store it at.
  6. Substitute <size> with the maximum size you want for the .vhd or .vhdx file in megabytes. E.g. 1024 for 1GB.

You are done.

Regardless of the method you used to create a VHD file, you need to create a file system on it in order to store some data on it, e.g. install an operating system or just copy some files. Here is how it can be done.

To Create File System on VHD or VHDX File,

  1. Press the Win + X keys together on the keyboard. See the list of shortcuts with the Win key available in Windows 10.
  2. From the menu, select Disk Management.Win+X Menu Disk Management Command
  3. If you do not see you VHD in the list, then select Action > Attach VHD from the menu.Disk Management Attach VHD 1
  4. Browse for you VHD file and click OK. Do not check the "read only" option.Disk Management Attach VHD 2
  5. The VHD file will appear as a new drive in the list.
  6. Right-click the attached VHD file, and select Initialize Disk from the context menu.Disk Management Attach VHD 3
  7. Select MBR or GPT for the partition style and click OK.Disk Management Attach VHD 4
  8. Right-click the unallocated space on your virtual drive and select New Simple Volume...Disk Management Attach VHD 5
  9. Select the partition size, file system, and specify the volume label for the new partition.Disk Management Attach VHD 6Disk Management Attach VHD 7Disk Management Attach VHD 8
  10. Now your VHD file is ready for regular tasks.

Alternatively, you can create the file system for your drive with DiskPart.

Create File System on VHD or VHDX File with DiskPart

  1. Press Win + R shortcut keys on the keyboard to open the Run dialog.
  2. Type diskpart into the Run box and hit the Enter key. Confirm the UAC prompt.
  3. In the diskpart prompt, type and run the command select vdisk file="Full path of .vhd or .vhdx location".DiskPart Attach VHD 1
  4. Type and run the command attach vdisk.DiskPart Attach VHD 2
  5. Create a new partition on the VHD using the following command: create partition primary.DiskPart Attach VHD 3
  6. Format the partition using the command format fs=FILE_SYSTEM_NAME label="disk label of your choice" quick.DiskPart Attach VHD 4
  7. Substitute FILE_SYSTEM_NAME with either FAT, FAT32, or NTFS. NTFS is strongly recommended.
  8. Replace "disk label of your choice" with some meaningful name, e.g. "my first VHD".
  9. To make the partition you have created on VHD visible in File Explorer, issue the command assign. Windows will assign any available drive letter automatically to the partition.
  10. Instead, you can execute the command assign letter=<Drive letter> (e.g. assign letter=Z) to make Windows assign a specific drive letter to the partition on your VHD.DiskPart Attach VHD 5

You are done. The drive is now visible in File Explorer and is ready for use.DiskPart Attach VHD 6

That's it!

 

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Advertisеment

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

Leave a Reply

Your email address will not be published.

css.php
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.