How to create a Virtual Disk using PowerShell
In a previous post I showed you how to create a storage pool, today I want to show you how to use PowerShell to create a virtual disk in your Storage Pool. To create a virtual disk using Powershell, use the New-VirtualDisk cmdlet with the following syntax:
New-VirtualDisk `
-FriendlyName <String> `
-StoragePoolFriendlyName <String[]> `
-Size <UInt64> `
-ProvisioningType Thin | Fixed `
-PhysicalDiskRedundancy <UInt16>
-StoragePoolFriendyName Parameter #
To obtain the correct designations for the storage pool, use the cmdlet: Get-StoragePool.
Get-StoragePool
-ProvisioningType Parameter #
Use Thin except when using storage spaces that use storage levels or a clustered storage group in that case use Fixed.
-PhysicalDiskRedundancy Parameter #
This value represents how many failed physical disks can tolerate the virtual disk without data loss.
Create the New Virtual Disk #
Run the following PowerShell commands as administrator.
New-VirtualDisk `
-FriendlyName 'NewVirtualDisk' `
-StoragePoolFriendlyName "StoragePool-01" `
-Size 10GB `
-ProvisioningType Thin `
-PhysicalDiskRedundancy 2
Initialize the Virtual Disk #
The following command initializes a Disk object with the GPT partition style
Get-VirtualDisk `
-FriendlyName 'NewVirtualDisk' `
|Initialize-Disk -PartitionStyle GPT `
-PassThru
Partition the Virtual Disk #
The following command creates a new partition on disk 10, using the maximum available space, and assigning the letter E.
New-Partition `
-DiskNumber 10 `
-DriveLetter 'E' `
-UseMaximumSize
Format the Virtual Disk #
The following cmdlet performs a full format of the E volume using the NTFS file system.
Format-Volume `
-DriveLetter 'E' `
-FileSystem NTFS `
-AllocationUnitSize 65536 `
-Confirm:$false `
-Force
Checking #
The following cmdlet returns a list of Virtual Disk objects, across all storage pools.
Get-VirtualDisk
Thanks for reading my post. I hope you find it helpful.
If you want to know more about the New-VirtualDisk cmdlet, check out this link.