2

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

Gabriel
  • 2,059
  • 7
  • 32
  • 49
  • Comments are not for extended discussion; this conversation has been [moved to chat](http://chat.stackexchange.com/rooms/30657/discussion-on-question-by-frostyfrog-how-to-disable-swapfile-sys-on-windows-10). – Journeyman Geek Oct 24 '15 at 00:05

4 Answers4

5

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?

magicandre1981
  • 97,301
  • 30
  • 179
  • 245
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
  • 424
  • 1
  • 5
  • 19
  • And then I have to boot in Window in order to shrink the partition. At which point the swap file will be recreated. – Gabriel Oct 23 '15 at 19:30
  • If you set your system to not use paging file, it won't create another. At least that's how it was with Windows 7. I don't think you need Windows to shrink your drive anyway. – emrecnl Oct 23 '15 at 19:32
  • So, you mean Windows is not using at this point the swap file and forgot to delete it? – Gabriel Oct 23 '15 at 19:33
  • Uhm..I don't know if we hit the language barrier here. In your first screenshot, if you click Set button for No Paging File -for each of your drive- then there won't and shouldn't be a page file after you reboot your PC. But again I'm not familiar with Windows 10. – emrecnl Oct 23 '15 at 19:37
  • @emrecnl-I know. This drives me crazy! It is also weird that the pagefile.sys WILL go away. But not the swapfile.sys. But again: Win10 is still early beta (even though Microsoft don't like to admit this). I mean I have seen bugs more substantial than this in Win10 – Gabriel Oct 23 '15 at 19:39
  • Even if you force deleting it by using another operating system I don't think it will cause any problem once you boot Windows -it may create again. This file is not storing any data essential to OS core or how it operates. If it's creating again and that you can't shrink your drive then shrinking it without using Windows is your best option. – emrecnl Oct 23 '15 at 19:45
  • @emrecnl - If the page file is disabled, once the swap file is deleted, it won't be created again. – Ramhound Oct 23 '15 at 20:50
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

Gabriel
  • 2,059
  • 7
  • 32
  • 49
  • swapfile and pagefile.sys are enable and disabled by enabling or disabling the pagefile.sys per the article I linked to. Have you tried to simply, delete, the file yourself? – Ramhound Oct 23 '15 at 20:48
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.

Bruce Gavin
  • 101
  • 1