MCSA Notes 70-740 P5

Configure virtual Disks

We have the possibility to create virtual disks as vhd or vhdx files. The older vhd files supports only a maximum size of 2TB and are not dynamically expandable. They support older Systems and Generation1 VMS. As a prefered option we choose vhdx which supports much more size and can be dynamically expanded. After creating a vhdx file it’s automatically mounted. We just have to initalize¬† and format the disk.

Let’s use fsutil and create a dummy file of 200 MB to see how the disk dynamically expand.

fsutil file createnew D:\myfile.txt 200000000

After creating the dummy file we can see that the vhdx file expands ūüėČ

This vhd or vhdx files can be easily mounted, dismounted and used as a portable storage container file.

Now let’s go over to Powershell and check which commands are being used to do the same without GUI.

#Check if Hyper-V Cmdlets are installed

Get-WindowsFeature *hyper-v*

# Install hyper-v powershell cmdlets

Install-WindowsFeature -Name Hyper-V -IncludeManagementTools

To use the cmdlets a restart is required!

#View VHD related cmdlets

Get-Command -Module Hyper-V -Name *vhd*

# Create a new dynamic vhdx file with a maximum size of 10GB

New-VHD -Path V:\Disks\data2.vhdx -SizeBytes 10GB -Dynamic

# Mount vhdx file

Mount-VHD -Path V:\Disks\data2.vhdx

# Initialize, partition, and format it

Initialize-Disk -Number 4 -PartitionStyle GPT -PassThru | New-Partition -UseMaximumSize -AssignDriveLetter | Format-Volume -FileSystem NTFS

#Generate Random Files

1..5000 | %{ ($_ *  (Get-Random -Max (100))) > "d:\file$_.txt" }

# unmount it

Dismount-VHD -Path V:\Disks\data2.vhdx

#View disk information

Get-VHD -Path V:\Disks\data2.vhdx


Ersten Kommentar schreiben


Deine E-Mail-Adresse wird nicht veröffentlicht.