Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSC_Disk: Add support for creating Dev Drive volume #276

Closed
bbonaby opened this issue Sep 19, 2023 · 6 comments · Fixed by #278
Closed

DSC_Disk: Add support for creating Dev Drive volume #276

bbonaby opened this issue Sep 19, 2023 · 6 comments · Fixed by #278
Assignees
Labels
enhancement The issue is an enhancement request.

Comments

@bbonaby
Copy link
Contributor

bbonaby commented Sep 19, 2023

Problem description

Windows has released a new feature called Dev Drive that is currently being used by developers to increase their performance workloads. One
thing that has come up is the need to be able to create a Dev Drive through a DSC configuration. Dev Drives are ReFS drives with special features under the hood. Currently to create a Dev Drive one can use the Format-Volume powershell cmdlet with the -DevDrive flag. The Dev Drive feature is now in GA with 10.0.22621.2338 or later.

The StorageDsc appears to be a good place to add this ability. The Disk resource already has the ability to format volumes among other volume related scenarios like:

  1. Ability to change the volume label
  2. Ability to add a partition style either GPT or MBR to an uninitialized disk.
  3. Ability to change the partition style from GPT to MBR and vice versa.
  4. Ability to rename the volume label.
  5. Ability to resize a partition.
  6. Ability to create a new partition from unallocated space and format a volume into this new partition. Users can use the size parameter to say how much space they want to use or not use the size parameter to use all the space available.
  7. Ability to set a disk online,
  8. Ability to mark a disk from readonly to write.
  9. Ability to clear a disk.

Note: The Disk Dsc currently does not have a parameter for 'Present' and 'Absent', so the configuration is mostly "if x drive letter on y disk matches all the parameters inputted, do nothing. But if a parameter does not match what was inputted update it so matches the inputted parameters".

We just would like to add one more parameter to the disk resource called DevDrive that will allow users to create a Dev Drive volume using the Disk dsc resource. Note: Dev Drive volumes should only be created using 50 Gb of space. The disk resource will need to be aware of this when this new Flag is used.

  1. A flag that when set allows a new partition to be created from unallocated space and a new Dev Drive volume formatted onto this new partition.
  2. A flag that when set, will check if the volume with the drive letter from the disk that the user inputted, is a Dev Drive volume or not. If it is a Dev Drive volume no new Dev Drive related work from this change is needed. This will help with idempotence.
  3. If no unallocated space exists, attempt to safely shrink an existing volume to create enough contiguous unallocated space to create a new partition for the new Dev Drive volume. For this scenario the AllowDestructive flag would be used.
  4. Format an existing drive that holds the drive letter that the user inputted as a parameter to be a Dev Drive volume if drive has enough space to hold a Dev Drive volume. Note: both NTFS and ReFS volumes can be reformatted as Dev Drive volumes assuming they have enough space. However Dev Drive volumes from a storage perspective are just like regular ReFS volumes on a Windows machine. The difference However, is that most of the filter drivers except the antivirus filter will not attach to the volume at boot time by default. This is a low-level concept that most users will never need to interact with but for further reading, see the documentation here for further reading.

prototype in forked branch

example config could be:

<#
    .DESCRIPTION
        For this scenario we want to create two 60 Gb Dev Drive volumes. We know that disk 2 has 3 existing
        NTFS volumes and we prefer not to remove them. At most we only want the disk DSC resource to shrink any
        of them should there not be enough space for any of the Dev Drive volumes to be created. We also know that the
        the 3 existing volumes are 100Gb, 200Gb and 300Gb in size and disk 2 is 600 Gb in size. Since all the space
        is being used by the existing volumes, The Disk Dsc resource will resize the existing volumes to create
        space for our new Dev Drive volumes. An example of what could happen is the Disk resource could resize the
        300Gb volume to 240Gb for the first Dev Drive volume and then resize the 240Gb volume again to 180Gb for the second.
        Thats just one combination, the disk Dsc resource uses the Get-PartitionSupportedSize cmdlet to know which volume
        can be be resized to a safe size to create enough unallocated space for the Dev Drive volume to be created. Note:
        ReFS volumes cannot be resized, so if the existing volumes were all ReFS volumes, the Disk Dsc resource would not be able
        to resize any volumes and would instead throw an exception.

        This configuration below will wait for disk 2 to become available, and then create two new 60 Gb Dev Drive volumes,
        'E' and 'F'. The volumes will be formatted as ReFS volumes and labeled 'Dev Drive 1' and 'Dev Drive 2' respectively.
        Note: setting 'AllowDestructive' to $true will not cause the disk to be cleared, as the flag is only used when there
        is a need to resize an existing partition. It is used as confirmation that you agree to the resizing which will
        create the necessary space for the Dev Drive volume. This flag is **NOT** needed if you already know there is enough
        unallocated space on the disk to create the Dev Drive volume. If this flag is not used and there is not enough space
        to create the Dev Drive volume an error will be thrown and the Dev Drive will not be created. Its important to be very
        careful not to add the 'ClearDisk' flag while using the 'AllowDestructive' flag, as this will cause the disk to be cleared,
        and all data lost on the disk (even existing volumes).
#>
Configuration Disk_CreateDevDriveOnDiskWithExistingPartitions
{
    Import-DSCResource -ModuleName StorageDsc

    Node localhost
    {
        WaitForDisk Disk2
        {
            DiskId = '5E1E50A401000000001517FFFF0AEB84' # Disk 2
            DiskIdType = 'UniqueId'
            RetryIntervalSec = 60
            RetryCount = 60
        }

        # Will create a Dev Drive volume of 60 Gb called Dev Drive 1.
        Disk DevDrive1
        {
            DiskId = '5E1E50A401000000001517FFFF0AEB84'
            DiskIdType = 'UniqueId'
            DriveLetter = 'E'
            FSFormat = 'ReFS'
            FSLabel = 'DevDrive 1'
            DevDrive = $true
            AllowDestructive = $true
            Size = 60Gb
            DependsOn = '[WaitForDisk]Disk2'
        }

        # Will create a Dev Drive volume of 60 Gb called Dev Drive 2.
        Disk DevDrive2
        {
            DiskId = '5E1E50A401000000001517FFFF0AEB84'
            DiskIdType = 'UniqueId'
            DriveLetter = 'F'
            FSFormat = 'ReFS'
            FSLabel = 'DevDrive 2'
            DevDrive = $true
            AllowDestructive = $true
            Size = 60Gb
            DependsOn = '[Disk]DevDrive1'
        }
    }
}

Verbose logs

nothing here

DSC configuration

nothing here

Suggested solution

nothing here

Operating system the target node is running

nothing here

PowerShell version and build the target node is running

nothing here

StorageDsc version

nothing here
@bbonaby
Copy link
Contributor Author

bbonaby commented Sep 19, 2023

FYI @PlagueHO

@PlagueHO PlagueHO added enhancement The issue is an enhancement request. in progress The issue is being actively worked on by someone. labels Sep 20, 2023
@PlagueHO
Copy link
Member

Looks good! Thanks @bbonaby !

@bbonaby
Copy link
Contributor Author

bbonaby commented Sep 22, 2023

@PlagueHO FYI PR is out, added tests and examples to confirm unit test functionality. The Dev Drive feature isn't available in Windows server 2019 and as far as I know won't be in Server 2022 either at least for now. I'll have the virtual hard disk PR out hopefully today as well.

@bbonaby
Copy link
Contributor Author

bbonaby commented Oct 19, 2023

updated the issue statement to better reflect what's in the PR today.

@johlju johlju removed the in progress The issue is being actively worked on by someone. label Oct 27, 2023
@johlju
Copy link
Member

johlju commented Oct 28, 2023

@johlju
Copy link
Member

johlju commented Oct 28, 2023

Created a new issue to track it #280.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is an enhancement request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants