antonio
antonio

Reputation: 11120

PowerShell: Create and Initialize a virtual disk with DiscUtils

When using the .NET DiscUtils PowerShell Module, I get the following error:

Import-Module DiscUtils.psd1
New-VirtualDisk hd.vhd -Type VHD-dynamic -Size 500MB
Initialize-VirtualDisk hd.vhd -VolumeManager Bios

Initialize-VirtualDisk : Path specified is not a virtual disk

hd.vhd is valid, and if mounted with other tools, is recognized by Windows Disk Management.

Upvotes: 1

Views: 735

Answers (1)

antonio
antonio

Reputation: 11120

Just found the proper way:

Import-Module DiscUtils.psd1
New-VirtualDisk hd.vhd -Type VHD-dynamic -Size 500MB
New-PSDrive vhd -PSProvider virtualdisk -Root hd.vhd -ReadWrite
Initialize-VirtualDisk vhd: -VolumeManager Bios

One can subsequently partition and format the drive.
To format the first 250MB NTFS:

New-Volume vhd: -Size 250MB -Type WindowsNtfs
Format-Volume vhd:\Volume0 -Filesystem Ntfs -Label "virtdrive"

Upvotes: 1

Related Questions