3

I want to delete the swapfile.sys from my C: partition because it prevents me from shrinking the drive. I set the Paging File option to 'No paging file' in the 'Virtual memory' window for my C partition and restarted but the swapfile.sys is still there. This procedure worked on Win 7 and Win 8.
Defrag won't help.

  1. How can I move the swapfile.sys to the beginning of the partition OR
  2. How can I delete swapfile.sys?

PS: Please don't worn me that is not a good idea to delete this file. I know it isn't. I will put it back. I promise :)

enter image description here enter image description here

GoUkraineGo
  • 2,171

4 Answers4

6

Have you tried to disable the swapfile.sys via registry?

Open regedit.exe, go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management and create a DWORD (32Bit) named SwapfileControl and set it to 0

Is this no longer working in Windows 10?

1
  1. How can I delete swapfile.sys?

You can boot your computer with almost any modern Linux distribution and I'm almost certain you can delete paging file from there.

emrecnl
  • 444
1

Solution for 'How to delete the SwapFile.sys' (won't fix the bug but it will delete the swapfile.sys):

Set the page file to 16MB
Press Apply
Set again the page file option to 'none' Restart
Pagefile.sys will be deleted (but you will get a swapfile.sys of 16MB)

enter image description here

GoUkraineGo
  • 2,171
0

I use PerfectDisk to shrink volumes for migration to SSD.

PLEASE make a system image of your disk as a safety net.

Disable System Restore points. System Restore points are NOT allowed to be defragmented by any product. They must be removed entirely.

Remove the Hibernation file:

powercfg -h off

Remove ALL paging files. This will delete both C:\pagefile.sys and C:\swapfile.sys

Run a Disk Cleanup and use the option to remove all system restore points.

Reboot.

I like to use the Windows Disk Management to have Windows do the first shrink. Then you can use PerfectDisk to further shrink your volume to fit the SSD. Multiple passes may be required.

After you are done, relocate your Page and Swap files to another disk if available. I do not want my SSD getting burned up from these activities.

Open an Admin level elevated CMD prompt and create a symbolic link.

mklink C:\swapfile.sys d:\swapfile.sys

Then create a Page file on your D: physical disk. After a reboot, the Swapfile.Sys will be created on D: as well.

This is tested on Win10, 20H2 latest version.