-
Notifications
You must be signed in to change notification settings - Fork 52
Disk
Parameter | Attribute | DataType | Description | Allowed Values |
---|---|---|---|---|
DriveLetter | Key | String | Specifies the identifier for which disk to modify. | |
DiskId | Required | String | Specifies the disk identifier for the disk to modify. | |
DiskIdType | Write | String | Specifies the identifier type the DiskId contains. Defaults to Number. | Number, UniqueId, Guid |
Size | Write | Uint64 | Specifies the size of new volume. Leave empty to use the remaining free space. | |
FSLabel | Write | String | Define volume label if required. | |
AllocationUnitSize | Write | Uint32 | Specifies the allocation unit size to use when formatting the volume. | |
FSFormat | Write | String | Specifies the file system format of the new volume. | NTFS, ReFS |
AllowDestructive | Write | Boolean | Specifies if potentially destructive operations may occur. | |
ClearDisk | Write | Boolean | Specifies if the disks partition schema should be removed entirely, even if data and oem partitions are present. Only possible with AllowDestructive enabled. |
The resource is used to initialize, format and mount the partition/volume as a drive letter. The disk to add the partition/volume to is selected by specifying the DiskId and optionally DiskIdType. The DiskId value can be a Disk Number, Unique Id or Guid.
Important: The Disk Number is not a reliable method of selecting a disk because it has been shown to change between reboots in some environments. It is recommended to use the Unique Id if possible.
The Disk Number, Unique Id and Guid can be identified for a disk by using the PowerShell command:
Get-Disk | Select-Object -Property FriendlyName,DiskNumber,UniqueId,Guid
Note: The Guid for a disk is only assigned once the partition table for the disk has been created (e.g. the disk has been initialized). Therefore to use this method of disk selection the disk must have been initialized by some other method.
This configuration will wait for disk 2 to become available, and then make the disk available as two new formatted volumes, 'G' and 'J', with 'J' using all available space after 'G' has been created. It also creates a new ReFS formated volume on disk 3 attached as drive letter 'S'.
Configuration Example
{
Import-DSCResource -ModuleName StorageDsc
Node localhost
{
WaitForDisk Disk2
{
DiskId = 2
RetryIntervalSec = 60
RetryCount = 60
}
Disk GVolume
{
DiskId = 2
DriveLetter = 'G'
Size = 10GB
DependsOn = '[WaitForDisk]Disk2'
}
Disk JVolume
{
DiskId = 2
DriveLetter = 'J'
FSLabel = 'Data'
DependsOn = '[Disk]GVolume'
}
WaitForDisk Disk3
{
DiskId = 3
RetryIntervalSec = 60
RetryCount = 60
}
Disk SVolume
{
DiskId = 3
DriveLetter = 'S'
Size = 100GB
FSFormat = 'ReFS'
AllocationUnitSize = 64KB
DependsOn = '[WaitForDisk]Disk3'
}
}
}
This configuration will wait for disk 2 with Unique Id '5E1E50A401000000001517FFFF0AEB84' to become available, and then make the disk available as two new formatted volumes, 'G' and 'J', with 'J' using all available space after 'G' has been created. It also creates a new ReFS formated volume on disk 3 with Unique Id '5E1E50A4010000000029AB39450AC9A5' attached as drive letter 'S'.
Configuration Example
{
Import-DSCResource -ModuleName StorageDsc
Node localhost
{
WaitForDisk Disk2
{
DiskId = '5E1E50A401000000001517FFFF0AEB84' # Disk 2
DiskIdType = 'UniqueId'
RetryIntervalSec = 60
RetryCount = 60
}
Disk GVolume
{
DiskId = '5E1E50A401000000001517FFFF0AEB84' # Disk 2
DiskIdType = 'UniqueId'
DriveLetter = 'G'
Size = 10GB
DependsOn = '[WaitForDisk]Disk2'
}
Disk JVolume
{
DiskId = '5E1E50A401000000001517FFFF0AEB84' # Disk 2
DiskIdType = 'UniqueId'
DriveLetter = 'J'
FSLabel = 'Data'
DependsOn = '[Disk]GVolume'
}
WaitForDisk Disk3
{
DiskId = '5E1E50A4010000000029AB39450AC9A5' # Disk 3
DiskIdType = 'UniqueId'
RetryIntervalSec = 60
RetryCount = 60
}
Disk SVolume
{
DiskId = '5E1E50A4010000000029AB39450AC9A5' # Disk 3
DiskIdType = 'UniqueId'
DriveLetter = 'S'
Size = 100GB
FSFormat = 'ReFS'
AllocationUnitSize = 64KB
DependsOn = '[WaitForDisk]Disk3'
}
}
}