[SOLVED] windows 2016 Optimize-Volume ReTrim

Vasilisc

Well-Known Member
Jun 29, 2017
34
3
48
45
vasilisc.com
The Proxmox VE 6.3 (Hyper-converged Infrastructure) cluster has a virtual machine running MS Windows 2016.

Characteristics of this virtual machine

bootdisk: scsi0
ostype: win10
scsi0: rbd:vm-126-disk-0,discard=on,size=256G
scsi1: rbd:vm-126-disk-1,discard=on,size=1000G
scsihw: virtio-scsi-pci

Get-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\FileSystem" -Name DisableDeleteNotification

DisableDeleteNotification : 0
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\FileSystem
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control
PSChildName : FileSystem
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry

I try to call the cmdlet in PowerShell

Optimize-Volume -DriveLetter D -ReTrim –Verbose

Error output.

Optimize-Volume : Failed
Activity ID: {60aab7f7-4345-447d-b0fa-e5b1e2ad9126}
+ Optimize-Volume -DriveLetter D -ReTrim –Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (StorageWMI:ROOT/Microsoft/...age/MSFT_Volume) [Optimize-Volume], CimException
+ FullyQualifiedErrorId : StorageWMI 4,Optimize-Volume

There are no problems with Linux operating systems! Help solve the problem on MS Windows.
Please do not suggest zeroing the disk through utilities like sdelete. This is a long and not entirely correct solution to the problem.
 
hi,

could you try like the following in powershell:
Code:
defrag D:\
optimize-volume -driveletter D -verbose

can you run the optimize-volume snippet on C:\ ? does it work then?
 
The operation failed for any disk.

optimize-volume : Failed
Activity ID: {31b1601a-28a7-4bad-b626-e4f921f576c2}
+ optimize-volume -driveletter C -verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (StorageWMI:ROOT/Microsoft/...age/MSFT_Volume) [Optimize-Volume], CimException
+ FullyQualifiedErrorId : StorageWMI 4,Optimize-Volume

For virtual disks, Windows 2016 uses drivers from Microsoft and does not allow installing drivers from VirtIO, since it believes that the correct ones are installed. Perhaps this is the problem?
 
Which type of disk do you use for the VM?
Iirc discard requires the type SCSI and also need to be enabled per disk.
 
Hm. That looks all right to me.
The only thing you could try is using the SSD emulation. Typically ssds have trim support. Maybe windows ties that to a media type.
Also have you stopped the VM after making the changes? (powered of, no reboot!)
 
Hm. That looks all right to me.
The only thing you could try is using the SSD emulation. Typically ssds have trim support. Maybe windows ties that to a media type.
Also have you stopped the VM after making the changes? (powered of, no reboot!)
Added parameter "ssd = 1" for disk "D:"

ostype: win10
scsi0: rbd:vm-126-disk-0,discard=on,size=256G
scsi1: rbd:vm-126-disk-1,discard=on,size=1000G,ssd=1
scsihw: virtio-scsi-pci

----
optimize-volume : Failed
Activity ID: {47274a55-4be8-417c-bb34-d1b84f37dad9}
+ optimize-volume -driveletter D -verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (StorageWMI:ROOT/Microsoft/...age/MSFT_Volume) [Optimize-Volume], CimException
+ FullyQualifiedErrorId : StorageWMI 4,Optimize-Volume
 
Try specifying the actions that should be performed.
For instance -retrim or -defrag
More:
https://docs.microsoft.com/en-us/powershell/module/storage/optimize-volume?view=win10-ps
Optimize-Volume : Failed
Activity ID: {e58f170d-e3db-45e2-9bdd-d440ba479344}
+ Optimize-Volume -DriveLetter D -ReTrim -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (StorageWMI:ROOT/Microsoft/...age/MSFT_Volume) [Optimize-Volume], CimException
+ FullyQualifiedErrorId : StorageWMI 4,Optimize-Volume

-----------------------

Optimize-Volume : Failed
Activity ID: {291181a1-26e3-431c-9c5d-e2f90cdef659}
+ Optimize-Volume -DriveLetter D -Defrag -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (StorageWMI:ROOT/Microsoft/...age/MSFT_Volume) [Optimize-Volume], CimException
+ FullyQualifiedErrorId : StorageWMI 4,Optimize-Volume

----------------------

Optimize-Volume : Failed
Activity ID: {453068da-f6d6-4a7f-a9d0-1dbd5669322b}
+ Optimize-Volume -DriveLetter D -Analyze -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (StorageWMI:ROOT/Microsoft/...age/MSFT_Volume) [Optimize-Volume], CimException
+ FullyQualifiedErrorId : StorageWMI 4,Optimize-Volume
 
Are you running from an administrative powershell session?
I find this very odd?!
 
Are you running from an administrative powershell session?
I find this very odd?!
PowerShell launched with administrator privileges

PS C:\Windows\system32> ([Security.Principal.WindowsIdentity]::GetCurrent().Groups.IsWellKnown('BuiltinAdministratorsSid
') -eq $true)
True

PS C:\Windows\system32> Optimize-Volume -DriveLetter D -ReTrim -Verbose
Optimize-Volume : Failed
Activity ID: {d87d2861-32d2-47ef-87de-8bc4195e8481}
+ Optimize-Volume -DriveLetter D -ReTrim -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (StorageWMI:ROOT/Microsoft/...age/MSFT_Volume) [Optimize-Volume], CimExcep
tion
+ FullyQualifiedErrorId : StorageWMI 4,Optimize-Volume
 
can you post:
Code:
diskpart> list disk
diskpart> list volume

to see the health status of the disk?
 
can you post:
Code:
diskpart> list disk
diskpart> list volume

to see the health status of the disk?
C:\Windows\system32>chcp 437
Active code page: 437

C:\Windows\system32>diskpart

Microsoft DiskPart version 10.0.14393.0

Copyright (C) 1999-2013 Microsoft Corporation.
On computer: OSKREPORT

DISKPART> list disk

Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 256 GB 0 B
Disk 1 Online 1000 GB 0 B *

DISKPART> list volume

Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- --------
Volume 0 reserved NTFS Partition 500 MB Healthy System
Volume 1 C NTFS Partition 255 GB Healthy Boot
Volume 2 D new volume NTFS Partition 999 GB Healthy

DISKPART>
 
Hello @Vasilisc

I just tried to optimize disk on Windows Server 2016 and and Windows 10 its works well on my side. However, could you please post the Windows VM config and the output of pveversion -v


EDIT: I added tow Disks one is 1TB and the second one is 20GB also the optimize works fine
 
Last edited:
Thank you all for your help and feedback. It’s my fault, but I don’t understand what I did wrong many years ago when installing the operating system.
For testing purposes, I installed MS Windows 2019 and MS Windows 2016.
During installation, I pointed to the VirtIO 190 drivers. There are no problems with
Optimize-Volume -DriveLetter C -ReTrim –Verbose

Windows 2019 test virtual machine configuration

name: Win2019test
ostype: win10
scsi0: rbd:vm-113-disk-0,discard=on,size=64G
scsihw: virtio-scsi-pci

Windows 2016 test virtual machine configuration

name: Win2016test
ostype: win10
scsi0: rbd:vm-116-disk-0,discard=on,size=64G
scsihw: virtio-scsi-pci

I don't know what I did wrong and why my old Windows 2016 VMs are having problems.

name: OSKReport
ostype: win10
scsi0: rbd:vm-126-disk-0,discard=on,size=256G
scsi1: rbd:vm-126-disk-1,discard=on,size=1000G,ssd=1
scsihw: virtio-scsi-pci

In this virtual machine (VMID 126), updated the driver for the "Red Hat VirtIO SCSI pass-through controller" device to version 190. Didn't solve the problem!

proxmox-ve: 6.3-1 (running kernel: 5.4.78-2-pve)
pve-manager: 6.3-3 (running version: 6.3-3/eee5f901)
pve-kernel-5.4: 6.3-3
pve-kernel-helper: 6.3-3
pve-kernel-5.4.78-2-pve: 5.4.78-2
pve-kernel-5.4.73-1-pve: 5.4.73-1
ceph: 14.2.16-pve1
ceph-fuse: 14.2.16-pve1
corosync: 3.0.4-pve1
criu: 3.11-3
glusterfs-client: 5.5-3
ifupdown: 0.8.35+pve1
ksm-control-daemon: 1.3-1
libjs-extjs: 6.0.1-10
libknet1: 1.16-pve1
libproxmox-acme-perl: 1.0.7
libproxmox-backup-qemu0: 1.0.2-1
libpve-access-control: 6.1-3
libpve-apiclient-perl: 3.1-3
libpve-common-perl: 6.3-2
libpve-guest-common-perl: 3.1-3
libpve-http-server-perl: 3.1-1
libpve-storage-perl: 6.3-3
libqb0: 1.0.5-1
libspice-server1: 0.14.2-4~pve6+1
lvm2: 2.03.02-pve4
lxc-pve: 4.0.3-1
lxcfs: 4.0.3-pve3
novnc-pve: 1.1.0-1
openvswitch-switch: 2.12.0-1
proxmox-backup-client: 1.0.6-1
proxmox-mini-journalreader: 1.1-1
proxmox-widget-toolkit: 2.4-3
pve-cluster: 6.2-1
pve-container: 3.3-2
pve-docs: 6.3-1
pve-edk2-firmware: 2.20200531-1
pve-firewall: 4.1-3
pve-firmware: 3.1-3
pve-ha-manager: 3.1-1
pve-i18n: 2.2-2
pve-qemu-kvm: 5.1.0-7
pve-xtermjs: 4.7.0-3
qemu-server: 6.3-2
smartmontools: 7.1-pve2
spiceterm: 3.1-1
vncterm: 1.6-2
zfsutils-linux: 0.8.5-pve1
 
Last edited:
In the problematic Windows 2016, I was hoping to see that it does not consider the virtual hard disk type as Thin Provisioning. But this is not the case!

Code:
Get-Disk -Number 0 | select -Property ProvisioningType
ProvisioningType
----------------
Thin

Code:
Optimize-Volume -DriveLetter C -ReTrim -Verbose
Optimize-Volume : Failed
Activity ID: {84ca3724-8d00-4e84-8576-22466c506294}
+ Optimize-Volume -DriveLetter C -ReTrim -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (StorageWMI:ROOT/Microsoft/...age/MSFT_Volume) [Optimize-Volume], CimException
+ FullyQualifiedErrorId : StorageWMI 4,Optimize-Volume

Help with any ideas.
 
Could you update pve-qemu-kvm package to 5.1.0-8 then try again?
proxmox-ve: 6.3-1 (running kernel: 5.4.78-2-pve)
pve-manager: 6.3-3 (running version: 6.3-3/eee5f901)
pve-kernel-5.4: 6.3-3
pve-kernel-helper: 6.3-3
pve-kernel-5.4.78-2-pve: 5.4.78-2
pve-kernel-5.4.73-1-pve: 5.4.73-1
ceph: 14.2.16-pve1
ceph-fuse: 14.2.16-pve1
corosync: 3.0.4-pve1
criu: 3.11-3
glusterfs-client: 5.5-3
ifupdown: 0.8.35+pve1
ksm-control-daemon: 1.3-1
libjs-extjs: 6.0.1-10
libknet1: 1.16-pve1
libproxmox-acme-perl: 1.0.7
libproxmox-backup-qemu0: 1.0.2-1
libpve-access-control: 6.1-3
libpve-apiclient-perl: 3.1-3
libpve-common-perl: 6.3-2
libpve-guest-common-perl: 3.1-4
libpve-http-server-perl: 3.1-1
libpve-storage-perl: 6.3-4
libqb0: 1.0.5-1
libspice-server1: 0.14.2-4~pve6+1
lvm2: 2.03.02-pve4
lxc-pve: 4.0.3-1
lxcfs: 4.0.6-pve1
novnc-pve: 1.1.0-1
openvswitch-switch: 2.12.0-1
proxmox-backup-client: 1.0.6-1
proxmox-mini-journalreader: 1.1-1
proxmox-widget-toolkit: 2.4-3
pve-cluster: 6.2-1
pve-container: 3.3-2
pve-docs: 6.3-1
pve-edk2-firmware: 2.20200531-1
pve-firewall: 4.1-3
pve-firmware: 3.1-3
pve-ha-manager: 3.1-1
pve-i18n: 2.2-2
pve-qemu-kvm: 5.1.0-8
pve-xtermjs: 4.7.0-3
qemu-server: 6.3-3
smartmontools: 7.1-pve2
spiceterm: 3.1-1
vncterm: 1.6-2
zfsutils-linux: 0.8.5-pve1

Code:
Get-Disk
Number Friendly Name Serial Number HealthStatus OperationalStatus Total Size Partition
Style
------ ------------- ------------- ------------ ----------------- ---------- ----------
0 QEMU QEMU HARDDISK Healthy Online 256 GB MBR
1 QEMU QEMU HARDDISK Healthy Online 1000 GB GPT

Code:
Get-Volume
ObjectId : {1}\\OSKREPORT\root/Microsoft/Windows/Storage/Providers_v2\WSP_Volume.ObjectId="{68e62c97-cb95-11e8-a1f5-806e6f6e6963}:VO:\\?\Volume{0342
3410-0000-0000-0000-100000000000}\"
PassThroughClass :
PassThroughIds :
PassThroughNamespace :
PassThroughServer :
UniqueId : \\?\Volume{03423410-0000-0000-0000-100000000000}\
AllocationUnitSize : 4096
DedupMode : NotAvailable
DriveLetter :
DriveType : Fixed
FileSystem : NTFS
FileSystemLabel : System reserved
FileSystemType : NTFS
HealthStatus : Healthy
OperationalStatus : OK
Path : \\?\Volume{03423410-0000-0000-0000-100000000000}\
Size : 524283904
SizeRemaining : 142512128
PSComputerName :


ObjectId : {1}\\OSKREPORT\root/Microsoft/Windows/Storage/Providers_v2\WSP_Volume.ObjectId="{68e62c97-cb95-11e8-a1f5-806e6f6e6963}:VO:\\?\Volume{0342
3410-0000-0000-0000-501f00000000}\"
PassThroughClass :
PassThroughIds :
PassThroughNamespace :
PassThroughServer :
UniqueId : \\?\Volume{03423410-0000-0000-0000-501f00000000}\
AllocationUnitSize : 4096
DedupMode : NotAvailable
DriveLetter : C
DriveType : Fixed
FileSystem : NTFS
FileSystemLabel :
FileSystemType : NTFS
HealthStatus : Healthy
OperationalStatus : OK
Path : \\?\Volume{03423410-0000-0000-0000-501f00000000}\
Size : 274351517696
SizeRemaining : 244233396224
PSComputerName :


ObjectId : {1}\\OSKREPORT\root/Microsoft/Windows/Storage/Providers_v2\WSP_Volume.ObjectId="{68e62c97-cb95-11e8-a1f5-806e6f6e6963}:VO:\\?\Volume{e6a8
5340-ee5e-49d6-b8e7-23e1739f4c43}\"
PassThroughClass :
PassThroughIds :
PassThroughNamespace :
PassThroughServer :
UniqueId : \\?\Volume{e6a85340-ee5e-49d6-b8e7-23e1739f4c43}\
AllocationUnitSize : 4096
DedupMode : NotAvailable
DriveLetter : D
DriveType : Fixed
FileSystem : NTFS
FileSystemLabel : BigData
FileSystemType : NTFS
HealthStatus : Healthy
OperationalStatus : OK
Path : \\?\Volume{e6a85340-ee5e-49d6-b8e7-23e1739f4c43}\
Size : 1073605505024
SizeRemaining : 1072575287296
PSComputerName :

Code:
Optimize-Volume -DriveLetter C -ReTrim -Verbose
Optimize-Volume : Failed
Activity ID: {bf42f0cc-90e0-4bc5-8d5c-b8afa1d9d611}
+ Optimize-Volume -DriveLetter C -ReTrim -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (StorageWMI:ROOT/Microsoft/...age/MSFT_Volume) [Optimize-Volume], CimException
+ FullyQualifiedErrorId : StorageWMI 4,Optimize-Volume
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!