VirtualHardDisk: New resource proposal #277
Labels
enhancement
The issue is an enhancement request.
in progress
The issue is being actively worked on by someone.
resource proposal
The issue is proposing a new resource in the resource module.
Resource proposal
Currently there is no way to create a standalone virtual disk in PowerShell on Windows client machines outside of using the New-VHD cmdlet. The problem with New-VHD is that its needs the Hyper-V feature enabled in Windows. For machines without this feature enabled like freshly installed Windows client boxes, this feature isn't enabled by default and enabling it would require a reboot. We should be able to create a virtual disk just like using the legacy disk management tool using DSC without this requirement.
Another way to create a virtual disk in PowerShell is to use the New-VirtualDisk cmdlet. However, this attempts to create a virtual disk in a storage pool and a requirement for storage pools is that two or more separate disks other than the disk Windows is installed on needs to be available. Another issue is that the disks in question have to have their 'Can-pool' flag set to true, which isn't always the case, and a destructive operation may be required to achieve this.
I suggest we create a DSC that utilizes a generic way that does not utilize these methods. Here are some requirements I believe the initial Vhd resource should have:
a. The full path to the virtual hard disk file
b. The disk format of the virtual disk [vhd or vhdx]
c. The disk type of the virtual disk [fixed or dynamic]
d. The disk size for the virtual hard disk
a. Attaching the has the same parameters as 'a' through 'd' above.
b. Windows client now has a new win32 flag that will allow a virtual disk attached with the AttachVirtualDisk api to be reattached at boot time. see ATTACH_VIRTUAL_DISK_FLAG_AT_BOOT
I believe utilizing the win32 api's CreateVirtualDisk and AttachVirtualDisk is simple for this job. We can have a new virtual disk powershell function and an Add function to attach them. Inside both we would just use imported C# using the add-type cmdlet. The C# code would just have the win32 imported functions, structs and enums needed to achieve this. I've prototyped this in this forked branch
The Purpose of the resource would be to ensure that a virtual disk with parameters from 'a' to 'd' is created. We don't need to add a detach methods because that can be done via DSC_MountImage. The difference here is that the virtual disk is created and mounted at the same time, with the added benefit of allowing for the auto attach capability.
example of how the resource would work:
Proposed properties
Special considerations or limitations
Something to consider is that if the virtual disk file is dismounted from the system and moved to a different location. The DSC would likely create a new one. This is the nature of the virtual disk being a file that is portable.
The text was updated successfully, but these errors were encountered: