-
Notifications
You must be signed in to change notification settings - Fork 52
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
Azure VM Data Disk Max Partition Size is Different to Actual Size #181
Comments
@PlagueHO I stumbled upon this because my customer is seeing this issue. We are using -AllowDestructive, which means a neverending clear disk -> create partition loop since the size is different. It is not due to the size of the volume though - we are getting this issue with various sizes. |
Hi @nyanhp - What we probably need to check next is if this is an issue with the underlying CIM information - which I think underpins the PS cmdlets here. If it is in the CIM then we'll need to raise this issue with the Windows Server team. E.g. the fact that when using UseMaximumSize you don't actually get a partition with the PartitionSupportedSize.SizeMax seems wrong to me, but I might be implying something that isn't the case. $null = Clear-Disk -Number 2 -RemoveData -Confirm:$false
$null = Initialize-Disk -Number 2 -PartitionStyle GPT
$partition = New-Partition -DiskNumber 2 -UseMaximumSize
('Actual Partition Size: {0}' -f (Get-Partition -DiskNumber 2 -PartitionNumber 2).Size)
('Supported Partition Size: {0}' -f (Get-PartitionSupportedSize -DiskNumber 2 -PartitionNumber ($partition.PartitionNumber)).SizeMax) What you could probably do though is set a static partition size when using the resource. This will prevent the UseMaximumSize and hopefully will result in this not happening. Have you tried this and did it work? |
Hi @PlagueHO I went another route... I need to run a few more tests with different file system formats and so on, but in my environment, the following alteration to Test-DscResource looked good: # Check the partition size
if ($partition -and -not ($PSBoundParameters.ContainsKey('Size')))
{
$supportedSize = ($partition | Get-PartitionSupportedSize)
$Size = if ($partition.Size - $supportedSize.SizeMax -lt 1MB) {$partition.Size} else {$supportedSize.SizeMax}
} I am unsure how this will behave for larger volumes, which I cannot really test. The diff between $Partition.Size and SizeMax varied with values between 0.8 and 0.98 MiB for my tested sizes of 20, 200, 500 and 1000 GiB. The difference in my lab environment's vhdx files was always 0.98 MiB. To be honest, it just looks like the offset is not taken into consideration when generating the supported size. In my scenario a fixed size is not desirable. We do not want to waste space if the size is too small or run into errors because it is too big. In the end, an issue might make more sense. There definitely is something wrong, but that goes deeper than my knowledge. The MSFT_Partition class documents the following: I have no clue why there is a difference, but I assume it has to do with "adding the size of any free extents" and the way UseMaximumSize will calculate the maximum partition size. The Resize method of the Partition class requires a valid partition size and will fail if the size is too small or too big. |
Wow! Great info @nyanhp - I reckon we might need to look into using your work around. I'll also reach out to the Windows Server team via the MVP PGI and see if they can enlighten us (or if I've been misusing/misunderstanding the behavior). Although, you might have better contacts over there 😁 But in the mean time we should look at the risks in using your work around. |
Doh! Wrong URL posted in one of the other issues! So ignore ^ |
@PlagueHO you would be surprised how little impact we premier field engineers have vs the MVP community, but I'll try to find out nevertheless. In the meantime I will create a PR with the workaround. |
@PlagueHO , it is the offset. I can't believe that I forgot about that. I will need to invest some time to properly calculate the result for Test-TargetResource and test the behavior. The default offset should be 1MB, the resource does not allow specifying Alignment and Offset which makes this a bit easier. |
Sorry for the spam, but I experimented some more. It is the alignment (multiple of PhysicalSectorSize) of the partition that is used in the calculations, at least in some form. I have yet to find out how Offset and Alignment are related here. $sectorsize = (Get-Disk -Number 1).PhysicalSectorSize
foreach ($off in 1..100)
{
$null = Clear-Disk -Number 1 -RemoveData -Confirm:$false
$null = Initialize-Disk -Number 1 -PartitionStyle GPT
$reservedpartition = get-partition -number 1 -DiskNumber 1
$junkpartition = New-Partition -DiskNumber 1 -Size 5gb -Offset ($reservedpartition.offset + $reservedpartition.size + $($off *1mb)) -Alignment ($sectorsize * $off)
$partition = New-Partition -DiskNumber 1 -UseMaximumSize -Offset ($junkpartition.offset + $junkpartition.size + $($off *1mb)) -Alignment ($sectorsize * $off)
'Offset: {0}, Alignment = {1}' -f ($junkpartition.offset + $junkpartition.size + $($off *1mb)), ($sectorsize * $off)
'Actual Partition Size: {0}' -f $partition.Size
'Supported Partition Size: {0}' -f ($partition | Get-PartitionSupportedSize).SizeMax
'Diff: {0:n2}MB' -f ((($partition | Get-PartitionSupportedSize).SizeMax - $partition.Size) / 1mb)
} I created an issue on UserVoice, let's see how that goes: https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/36967870-get-partitionsupportedsize-and-msft-partition-clas |
When should we expect to see this fix released? |
Hi @johnwc - it will go out in the next DSC Resource Kit release, which is due in about 5 weeks time. It is a week after the next community call (which is on 23 October IIRC). So the release is likely right at the end of Oct. |
@PlagueHO Thanks for the update. Do y'all publish preview releases? |
@johnwc - not yet, but it is coming soon. We're in the process of migrating these modules over to the DSCCommunity.org, and when we do we'll adopt "per resource" release cadence, allowing maintainers to do preview releases etc. |
Disk: Fix Partition MaxSize discrepency - Fixes #181
Details of the scenario you tried and the problem that is occurring
Using Disk resource to create a partition on an empty data disk using all free space reports that the size of the partition is smaller than it maximum size:
I was using a 1023 GB data disk, so it is possible that this is a behavior with specific disk sizes.
Verbose logs showing the problem
The problem can be replicated outside of DSC, so is not specifically caused by the Disk resource but the behavior of
Get-PartitionSupportedSize
,New-Partition -UseMaximumSize
andGet-Partition
.For example:
Suggested solution to the issue
The DSC configuration that is used to reproduce the issue (as detailed as possible)
The operating system the target node is running
Version and build of PowerShell the target node is running
Version of the DSC module that was used ('dev' if using current dev branch)
4.3.0.0
The text was updated successfully, but these errors were encountered: