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

xDisk: PartitionStyle parameter is non-configurable #137

Closed
DelectableMechanisations opened this issue Jan 6, 2018 · 3 comments · Fixed by #170
Closed

xDisk: PartitionStyle parameter is non-configurable #137

DelectableMechanisations opened this issue Jan 6, 2018 · 3 comments · Fixed by #170
Assignees
Labels
enhancement The issue is an enhancement request.

Comments

@DelectableMechanisations

I'm having some trouble with the xDisk DSC Resource.

To give you some background I have written a DSC Bootloader script that dynamically generates a DSC Configuration Data file (.psd1) and, among other things, adds the server's disks into this.
Here is the relevant sample portion of my Configuration Data file:

@{
    AllNodes = @(
        @{
            NodeName = 'TS2016-DEV01'
            
            Storage = @(
                @{
                    #Current Disk Size: 49.51GB (Disk Number 0)
                    #-------------------------------------------
                    DiskId             = 'SCSI\DISK&VEN_VMWARE&PROD_VIRTUAL_DISK\5&1982005&0&000000:TS2016-dev01'
                    DiskIdType         = 'UniqueId'
                    DriveLetter        = 'C'
                    FSLabel            = 'TS2016-DEV01-C-SystemOS'
                    AllocationUnitSize =  4096
                    FSFormat           = 'NTFS'
                }
                
                @{
                    #Current Disk Size: 10GB (Disk Number 1)
                    #-----------------------------------------
                    DiskId             = 'SCSI\DISK&VEN_VMWARE&PROD_VIRTUAL_DISK\5&1982005&0&000100:TS2016-dev01'
                    DiskIdType         = 'UniqueId'
                    DriveLetter        = 'H'
                    FSLabel            = 'TS2016-DEV01-H-TempDB'
                    AllocationUnitSize =  65536                            #Alternate Values: 65536
                    FSFormat           = 'NTFS'                           #Alternate Values: REFS
                }
                
                @{
                    #Current Disk Size: 11GB (Disk Number 2)
                    #-----------------------------------------
                    DiskId             = 'SCSI\DISK&VEN_VMWARE&PROD_VIRTUAL_DISK\000000:TS2016-dev01'
                    DiskIdType         = 'UniqueId'
                    DriveLetter        = 'E'
                    FSLabel            = 'TS2016-DEV01-E-SQLData'
                    AllocationUnitSize =  65536                            #Alternate Values: 65536
                    FSFormat           = 'NTFS'                           #Alternate Values: REFS
                }
            )
        }
    )
}

For completeness here is the portion of the DSC Composite resource that deals with this block of data:

    if ($Disks.Count -ge 1) {
        foreach ($Disk in $Disks) {

            #Replace any non-alphanumeric characters with a '_' (e.g. - or .)
            $DiskIdString = "$($Disk.DriveLetter + '_' + $Disk.FSLabel)" -Replace "\W",'_'

            #Provision each disk specified in the input.
            xDisk "DiskProvision_$($DiskIdString)" {
                DriveLetter        = $Disk.DriveLetter
                DiskId             = $Disk.DiskId
                DiskIdType         = $Disk.DiskIdType
                FSLabel            = $Disk.FSLabel
                AllocationUnitSize = $Disk.AllocationUnitSize
                FSFormat           = $Disk.FSFormat
                DependsOn          = '[cCdDriveLetter]CDDriveLetter'
            }
        }
    }

Running 'Test-DscConfiguration' returns $false on the C: drive (but works fine for all other disks).
Checking the Verbose output reveals that it is because it is configured with MBR instead of GPT.
[[xDisk]DiskProvision_C_TS2016_DEV01_C_SystemOS::[cBaseStorage]CCCStorage] Test-TargetResource: Disk with UniqueId 'SCSI\DISK&VEN_VMWARE&PROD_VIRTUAL_DISK\5&1982005&0&000000:TS2016-dev01' is initialized with 'MBR' partition style. GPT required.

Reviewing the code for this resource I can see that 'Test-TargetResource' is hardcoded to return $false if the partition style is not GPT.

    if ($disk.PartitionStyle -ne 'GPT')
    {
        Write-Verbose -Message ( @(
                "$($MyInvocation.MyCommand): "
                $($localizedData.DiskNotGPTMessage -f $DiskIdType, $DiskId, $Disk.PartitionStyle)
            ) -join '' )

        return $false
    } # if

Are there any plans to update this in the future so that it works with both GPT and MBR?

I have made my own version of this resource (cDisk) with a dedicated 'PartitionStyle' parameter that I'm happy to share.

OS: Windows Server 2016 and PowerShell v5
DSC Resource: xStorage (dev branch)

P.S. Not related to my issue but you people are doing a great job keeping all the DSC Resources up to date. I've been tinkering with DSC for about 18 months now and the quality of coding I saw back then to what I'm seeing now is just so much higher.
The resources have a more modular design, there's a 'Get-Help' section on most of the functions and most of the DSC properties now have descriptions.

Keep up the good work people!

@PlagueHO PlagueHO added enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community. labels Jan 6, 2018
@PlagueHO
Copy link
Member

PlagueHO commented Jan 6, 2018

Hi @DelectableMechanisations - thank you so much for the kind compliments! The community is definitely working really hard to bring the quality up of all modules in the DSC Resource kit. It makes me happy to know it is noticed 😁

Anyway, on to the MBR: actually I had noticed this too sometime back, but for some reason never added the feature. But if you've got code and would be happy to contribute it to the resource kit then we're more than happy to accept it - the more help the better! This would be a great feature to get implemented.

@tom-dudley
Copy link

@DelectableMechanisations Do you mind if I make a PR on your behalf to get this useful addition merged?

@rukas
Copy link

rukas commented Aug 10, 2018

It would be great if this gets merged. Would totally help my use case!

@PlagueHO PlagueHO added in progress The issue is being actively worked on by someone. and removed help wanted The issue is up for grabs for anyone in the community. labels Sep 7, 2018
@PlagueHO PlagueHO self-assigned this Sep 7, 2018
PlagueHO added a commit that referenced this issue Sep 20, 2018
Added PartitionStyle Parameter to Disk - Fixes #137
@johlju johlju removed the in progress The issue is being actively worked on by someone. label Sep 20, 2018
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.

5 participants