Hello LU Yajun, I am Henry and I want to help you with this issue.
The error "There is not enough space available on the disk(s) to complete this operation" when shrinking C: in Windows Server 2019 usually happens because of unmovable files at the end of the volume (pagefile.sys, hiberfil.sys, shadow copies, MFT records), not because of actual free space shortage.
Here are the steps you can take to resolve this issue:
1. Disable System Restore and Shadow Copies (Temporarily):
These can create unmovable files.
- Disable System Restore:
- Right-click on "This PC" > "Properties" > "System protection".
- Select your C: drive and click "Configure".
- Select "Disable system protection" and click "Apply" and "OK".
- Disable Volume Shadow Copies:
- Open an elevated Command Prompt.
- Type
vssadmin list shadowsto see if there are any shadow copies. - To delete them, type
vssadmin delete shadows /for=C: /all. - You can also disable the "Volume Shadow Copy" service in
services.msctemporarily, but disabling System Protection usually handles this.
2. Disable Hibernation (if enabled):
The hiberfil.sys file is also unmovable. Virtual machines typically don't use hibernation, but it's worth checking.
- Open an elevated Command Prompt.
- Type
powercfg.exe /hibernate offand press Enter.
3. Configure the Paging File (Virtual Memory)
The page file (pagefile.sys) is a common culprit.
- Move or Temporarily Disable:
- Right-click on "This PC" > "Properties" > "Advanced system settings".
- Under "Performance", click "Settings...".
- Go to the "Advanced" tab and click "Change..." under "Virtual memory".
- Uncheck "Automatically manage paging file size for all drives".
- Select your C: drive.
- You can either select "No paging file" (and click "Set"), or ideally, move it to another drive if you have one (e.g., your D: drive) by selecting D: and setting a custom size, then setting C: to "No paging file".
- Click "Set" and "OK". You will be prompted to restart. Restart your VM..
4. Perform a Disk Defragmentation/Optimization:
While modern SSDs don't need defragmentation, an "optimization" can help consolidate files. Even for HDDs, this can help move files.
- Open "Defragment and Optimize Drives" (search for it in the Start Menu).
- Select your C: drive and click "Optimize".
5. Clean Up Disk:
Remove temporary files that might be contributing to fragmentation.
- Right-click C: drive > "Properties" > "Disk Cleanup".
- Click "Clean up system files" and select everything you're comfortable deleting.
After performing these steps (especially steps 1-3 and a restart):
- Try shrinking the volume again using Disk Management.
Important Note after Shrinking:
Once you've successfully shrunk the C: drive and created unallocated space, remember to re-enable System Restore, re-configure your paging file back to "System managed size" on C: drive (or your preferred setting), and re-enable hibernation if you use it.
I hope this information is helpful.