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

Disk: Does specifying an existing partition letter without a size expand the partition to use the remaining free space on the drive #162

Closed
indyK1ng opened this issue Aug 21, 2018 · 5 comments · Fixed by #164
Assignees
Labels
bug The issue is a bug.

Comments

@indyK1ng
Copy link

This is a question about the existing functionality.

Can we use this to resize a volume to use the remaining free space of a drive in addition to its existing space?

We would like to use this to resize partitions on VMs if the virtual disk has been resized. The wiki documentation says regarding Size: "Specifies the size of new volume. Leave empty to use the remaining free space."

However, reading the code for MSFT_Disk's handling of existing partitions, it looks like if size is not specified it might try to resize the partition to $null because $Size hasn't been set and $null is not equal to $assignedPartition.Size. At this point, behavior is up to if Resize-Partition errors when the -Size parameter is $null.

@johlju johlju added the question The issue is a question. label Aug 22, 2018
@johlju
Copy link
Member

johlju commented Aug 22, 2018

I assume that you don't want to specify the Size property, but want the Size to be "current size of entire disk" (not sure that equals to "remaining free space" above), and together with AllowDestructive should resize the partition?

Feels that the scenario you looking for is not tested among those "AllowDestructive" tests. Closest is this one; https://github.com/PowerShell/StorageDsc/blob/b31dbc236c6c7542f344a3eee5b8aa6b6055d0f4/Tests/Unit/MSFT_Disk.Tests.ps1#L1663-L1722

I think we should add a test for that scenario.

Hoping someone in the community can answer this better.

/cc @PlagueHO

@indyK1ng
Copy link
Author

Not the entire disk - if there's another partition on the disk we don't want to delete it. That's what I mean by "remaining free space", the unpartitioned space remaining on the disk. Other than that, yes I want it to resize the partition with AllowDestructive when no Size is specified to use up any space not in a partition.

I also didn't see any tests that cover this case and, like I said, I'm pretty sure the behavior is at the whim of how Resize-Partition handles Size being $null. I tested it this morning and got an error.

@johlju
Copy link
Member

johlju commented Aug 23, 2018

This sounds like a bug, labeling it as such, and help wanted so that anyone in the community can run with this.

@johlju johlju added bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community. and removed question The issue is a question. labels Aug 23, 2018
@PlagueHO
Copy link
Member

It does indeed look like this is a bug and should be able to be fixed fairly easily by setting $Size to $supportedSize if Size is not set in the resource just before this line (https://github.com/PowerShell/StorageDsc/blob/2f8d3200aa799ea34ebae4c20707aefc27f6225b/Modules/StorageDsc/DSCResources/MSFT_Disk/MSFT_Disk.psm1#L499). I'll try and get a fix through for this tomorrow or the weekend.

@PlagueHO PlagueHO self-assigned this Aug 24, 2018
@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 Aug 24, 2018
@PlagueHO
Copy link
Member

This has required a bit more to it than what I first thought. Hopefully won't be much longer. Needed a lot more new tests to really validate that this isn't going to break anything.

PlagueHO added a commit that referenced this issue Aug 31, 2018
Enable Disk Partition Resize when Size not specified - Fixes #162
@johlju johlju removed the in progress The issue is being actively worked on by someone. label Aug 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants