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

Disks not shrinking #43

Closed
RickItum opened this issue Jul 16, 2021 · 12 comments
Closed

Disks not shrinking #43

RickItum opened this issue Jul 16, 2021 · 12 comments

Comments

@RickItum
Copy link

The script is not shrinking out disks.
When running the script 1 time there is no output bit the disk is mounted.
After running the script again we get output like:
Attached : False
BlockSize : 33554432
DevicePath :
FileSize : 15573450752
ImagePath : U:\Containers\diskname.VHDX
LogicalSectorSize : 512
Number :
Size : 15728640000
StorageType : 3
PSComputerName :

after this the disk is still mounted and the disk did not shrunk.

@JimMoyle
Copy link
Contributor

How did you run the script and from where?

@RickItum
Copy link
Author

I ran the script on the local server as administrator via powershell using the following command:
Invoke-FslShrinkDisk.ps1 -Path U:\Containers\diskname.VHDX

@JimMoyle
Copy link
Contributor

I'd advise running it from a remote machine, you'll pin the CPU on the server if you run it from there. Could you try running it remotely from a Win10 machine?

@RickItum
Copy link
Author

I just checked with a remote system, the results are the same.

@JimMoyle
Copy link
Contributor

JimMoyle commented Jul 21, 2021 via email

@4oo4
Copy link

4oo4 commented Aug 16, 2021

Hi @JimMoyle, we are having a similar issue with this script, running locally on a Server 2016 server. What's interesting is that when I run the diskpart commands manually outside of the script, I get the expected results. However when I run the script I do not get any errors, but the disk size remains the same. The only difference I can think of is that when I'm doing it manually, I'm assigning the VHDX a drive letter when it's mounted, and explicitly selecting the volume of the vdisk in diskpart, before running the compact command.

From what I can tell the disk does not appear to be mounted after the script exits. I also verified that this isn't a permissions issue on the VHDX file or containing folder.

Happy to help if you need additional info.

Thanks

EDIT:

Not sure if this helps but I also notice that I get "cannot get partition information" in my log file.

"Name","StartTime","EndTime","ElapsedTime(s)","DiskState","OriginalSizeGB","FinalSizeGB","SpaceSavedGB","FullName"
"Profile_username.vhdx","12:09:44 PM","12:10:14 PM","30.6","Cannot get partition information","10.32","10.32","0","D:\userprofile\FSLogixContainers\test\username_S-1-5-21-000000000-0000000000-0000000000-0000\Profile_username.vhdx"

@4oo4
Copy link

4oo4 commented Aug 16, 2021

So I think what is happening in my case is that the script is failing silently because Mount-DiskImage doesn't always return a disk number like the script expects. So that means the DiskState variable isn't being set properly, and that also affects other cmdlets like Optimize-OneDisk, which in turn calls Invoke-Diskpart.

PS C:\Scripts> $path = "D:\userprofile\fslogixcontainers\test\username_S-1-5-21-000000000-0000000000-0000000000-0000\Profile_username.vhdx"
PS C:\scripts> $mountedDisk = Mount-DiskImage -ImagePath $Path -PassThru
PS C:\scripts> $mounteddisk


Attached          : False
BlockSize         : 33554432
DevicePath        :
FileSize          : 7084179456
ImagePath         : D:\userprofile\fslogixcontainers\test\username_S-1-5-21-000000000-0000000000-0000000000-0000\Profile_username.vhdx
LogicalSectorSize : 512
Number            :
Size              : 32212254720
StorageType       : 3
PSComputerName    :

@JimMoyle
Copy link
Contributor

@4oo4 I did some trouble shooting with @RickItum and on the servers where the problem was occurring. The powershell integration with the windows disk subsystem wasn't working.

Outside of the script on an elevated command prompt none of the following commands worked:

Get-Disk
Get-PhysicalDisk
Get-Volume
Get-Partition

Can you check if this is the same symptom you are seeing? If so let me know here. Also please let me know if you fix it.

Jim

@JimMoyle
Copy link
Contributor

from @RickItum

This turned out to be the “Microsoft Storage Spaces SMP” (smphost) service that was disabled.

After changing this to manual all the PowerShell commands work fine again, as well as the script!

We cross referenced this with the other environment, this service was disabled as well.

@4oo4
Copy link

4oo4 commented Aug 17, 2021

@JimMoyle

From what I can tell all those cmdlets appear to be working:

PS C:\Windows\system32> get-disk

Number Friendly Name Serial Number                    HealthStatus         OperationalStatus      Total Size Partition
                                                                                                             Style
------ ------------- -------------                    ------------         -----------------      ---------- ----------
2      Msft Virtu...                                  Healthy              Online                      30 GB MBR
0      VMware Vir...                                  Healthy              Online                      50 GB MBR
1      VMware Vir...                                  Healthy              Online                    1.95 TB GPT

PS C:\Windows\system32> get-physicaldisk

FriendlyName        SerialNumber CanPool OperationalStatus HealthStatus Usage          Size
------------        ------------ ------- ----------------- ------------ -----          ----
VMware Virtual disk              False   OK                Healthy      Auto-Select   50 GB
VMware Virtual disk              False   OK                Healthy      Auto-Select 1.95 TB
Msft Virtual Disk                False   OK                Healthy      Auto-Select   30 GB


PS C:\Windows\system32> get-volume

DriveLetter FileSystemLabel  FileSystem DriveType HealthStatus OperationalStatus SizeRemaining     Size
----------- ---------------  ---------- --------- ------------ ----------------- -------------     ----
D           Data             NTFS       Fixed     Healthy      OK                     474.1 GB  1.95 TB
Z                                       CD-ROM    Healthy      Unknown                     0 B      0 B
A                                       Removable Healthy      Unknown                     0 B      0 B
            System Reserved  NTFS       Fixed     Healthy      OK                    162.89 MB   500 MB
C                            NTFS       Fixed     Healthy      OK                     24.43 GB 49.51 GB
E           Profile-abennett NTFS       Fixed     Healthy      OK                     24.88 GB    30 GB


PS C:\Windows\system32> get-partition


   DiskPath: \\?\scsi#disk&ven_msft&prod_virtual_disk#2&1f4adffe&0&000002#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}

PartitionNumber  DriveLetter Offset                                        Size Type
---------------  ----------- ------                                        ---- ----
1                E           1048576                                      30 GB IFS


   DiskPath: \\?\scsi#disk&ven_vmware&prod_virtual_disk#5&1982005&0&000000#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}

PartitionNumber  DriveLetter Offset                                        Size Type
---------------  ----------- ------                                        ---- ----
1                            1048576                                     500 MB IFS
2                C           525336576                                 49.51 GB IFS


   DiskPath: \\?\scsi#disk&ven_vmware&prod_virtual_disk#5&1982005&0&000100#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}

PartitionNumber  DriveLetter Offset                                        Size Type
---------------  ----------- ------                                        ---- ----
1                            17408                                       128 MB Reserved
2                D           135266304                                  1.95 TB Basic


PS C:\Windows\system32>

@JimMoyle
Copy link
Contributor

Looks like a different issue then. Can you email me some times you are available to the email acct. associated with this github account and I'll have a look. I'm on UK time btw.

Jim

@4oo4
Copy link

4oo4 commented Aug 17, 2021

Thanks @JimMoyle, I will do some more investigating and shoot you an email. This may be something to do with Server 2016, when I run the same Mount-DiskImage commands on a Server 2019 server it returns the disk number as expected. Though, I'm going to compare these two servers to see if anything else is different, since we did have success with using this script on a Server 2016 server in the past.

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

No branches or pull requests

3 participants