Win10-Initial-Setup-Script icon indicating copy to clipboard operation
Win10-Initial-Setup-Script copied to clipboard

1903 (insider build 18312) reserved storage

Open Disassembler0 opened this issue 6 years ago • 6 comments

https://blogs.windows.com/windowsexperience/2019/01/09/announcing-windows-10-insider-preview-build-18312/

https://blogs.technet.microsoft.com/filecab/2019/01/07/windows-10-and-reserved-storage/

Starting with the next major update we’re making a few changes to how Windows 10 manages disk space. Through reserved storage, some disk space will be set aside to be used by updates, apps, temporary files, and system caches. Our goal is to improve the day-to-day function of your PC by ensuring critical OS functions always have access to disk space.

...we anticipate that reserved storage will start at about 7GB...

Find if this can be disabled or reduced. It's a NTFS feature, so it might not be that easy :/

Disassembler0 avatar Jan 10 '19 21:01 Disassembler0

CMD: reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager" /v "ShippedWithReserves" /t REG_DWORD /d "0" /f

PS: Set-ItemProperty -LiteralPath "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager" -Name "ShippedWithReserves" -Value 0 -Type DWord -ErrorAction SilentlyContinue

Ainatar avatar Jan 13 '19 14:01 Ainatar

this does not work. I have a cleanly installed Windows 10 1903, free space of 20GB on the system disk and still can't disable the reserved space.

develtom avatar May 24 '19 19:05 develtom

This worked for me:

Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager" -Name "BaseHardReserveSize" -Value 0 -Type QWord -ErrorAction SilentlyContinue
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager" -Name "BaseSoftReserveSize" -Value 0 -Type QWord -ErrorAction SilentlyContinue
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager" -Name "HardReserveAdjustment" -Value 0 -Type QWord -ErrorAction SilentlyContinue
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager" -Name "MinDiskSize" -Value 0 -Type QWord -ErrorAction SilentlyContinue
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager" -Name "ShippedWithReserves" -Value 0 -Type DWord -ErrorAction SilentlyContinue

After that I have clicked on Clean now in Storage settings and the reserved space disappeared from the listing.

However I have no idea:

  1. If it really deallocated the space or if it just hid it from UI
  2. What some of those values under ReserveManager registry key mean
  3. How to run the cleanup from script or how to achieve the same result as the cleanup does
  4. If it is safely reversible simply by setting the original values

I have tried to reset it using the original values via

Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager" -Name "BaseHardReserveSize" -Value 5368709120 -Type QWord -ErrorAction SilentlyContinue
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager" -Name "BaseSoftReserveSize" -Value 1610612736 -Type QWord -ErrorAction SilentlyContinue
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager" -Name "HardReserveAdjustment" -Value 522039296 -Type QWord -ErrorAction SilentlyContinue
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager" -Name "MinDiskSize" -Value 21474836480 -Type QWord -ErrorAction SilentlyContinue
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager" -Name "ShippedWithReserves" -Value 1 -Type DWord -ErrorAction SilentlyContinue

and after reboot my reserved storage shows 110 MB. I can only assume that it will eventually grow when the space is needed, but I haven't confirmed that either.

Disassembler0 avatar May 25 '19 09:05 Disassembler0

Super this works. I have back 7GB available. Thank you very much

develtom avatar May 25 '19 11:05 develtom

Some small update for fellow researchers. The reserve is indeed a NTFS feature. In can be seen in overall statistics via

fsutil fsInfo ntfsInfo C:

It can be queried to see the individual "buckets"

fsutil storageReserve query C:

where

  • 1 = Hard
  • 2 = Soft
  • 3 = UpdateScratch

And it can be queried for individual file listing

fsutil storageReserve findByID C: *

There doesn't seem to be any subcommands for direct manipulation of reserves via fsutil.

The Storage Sense which triggers the resize does quite a lot. So far I have been able to completely rule out involvement of cleanmgr.exe which is executed by it and I have string suspicion that the resize is triggered by some code in C:\Windows\System32\SettingsHandlers_StorageSense.dll or one of libraries which it loads. I'll poke around a bit more later.

Disassembler0 avatar May 25 '19 17:05 Disassembler0

The registry keys are read by StorSvc service in following order:

  1. PassedPolicy
  2. ActiveScenario
  3. BaseHardReserveSize
  4. BaseSoftReserveSize
  5. HardReserveAdjustment
  6. PostUpgradeFreeSpace (doesn't exist in default state)
  7. UserFreeSpaceMarker (doesn't exist in default state)

This service uses library C:\Windows\WinSxS\amd64_microsoft-windows-servicingstack_31bf3856ad364e35_10.0.18362.110_none_5f52ccdc58d07895\ReserveManager.dll which exposes following entry points:

  • ForcePrepareTIForReserveInitialization
  • ForceUntagFilesAndDeleteReserves
  • GetUpdateReserveManager
  • GetUpdateReserveManagerCBS
  • InitializeReservesAndUpdatePolicy
  • PrepareMachineForAuditMode
  • PrepareMachineForSysprepCleanup
  • ValidateMachineForSysprep

Looks like I'm on the right track. Also looks like this won't be possible without P/Invoke :(

Disassembler0 avatar May 25 '19 19:05 Disassembler0