Solved Is it possible to move swapfile.sys to a different volume?

Hairy Scot

Power User
VIP Member
Power User
Messages
220
Acting on the assumption that the extended start up times I am experiencing (almost 5 minutes from entering pin or password until START screen appears) might be due to disk fragmentation I decided to defrag my Windows drive.
Of course a major obstacle in that exercise is the pagefile so I decided to set up a page partition on the disk that I use for online backups and file history since that disk is lightly used.
All well and good but then I spot SWAPFILE.SYS which apparently always gets on to the Windows drive no matter where the pagefile is located.
How can I move that file to another location?
 

My Computer

System One

  • OS
    Windows 8.1 Pro X64
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Gigabyte Technology Co., Ltd. GA-B75M-D2V
    CPU
    Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz, 3601 Mhz, 4 Core(s)
    Motherboard
    Gigabyte Technology Co., Ltd. GA-B75M-D2V
    Memory
    8 GB DDR3 1600MHZ
    Graphics Card(s)
    GE Force GT 610
    Sound Card
    Onboard Realtek High Def
    Monitor(s) Displays
    Dell U2913WMP
    Screen Resolution
    2560x1080
    Hard Drives
    Western Digital WD10EZEX-00RKKA0 1TB
    Seagate ST2000DL003-9VT166 2TB
    Seagate ST31000528AS 1TB
Found the answer:-

Virtual Memory Paging File - Change

You can moveswapfile.sys by disabling paging file and then creating a symbolic link at C:\swapfile.sys (assuming C: is your system drive). Whole procedure can be performed in Windows environment. The following steps will disable swapfile.sys (tested on Windows 8 and Windows 8.1 Preview):

  1. Disable page files on all drives (through Control Panel -> System and Security -> System -> Advanced system setting -> Advanced -> Performance Options -> Advanced -> Virtual memory).
  2. Restart your computer.
  3. swapfile.sys should be gone now. If it's still present, it may be deleted manually.
Afterwards enter following command in command line (requires administrative privileges):
mklink C:\swapfile.sys "<NEW LOCATION>:\swapfile.sys"
If new location path doesn't contain spaces, quotes can be omitted. Note that in Windows PowerShell (which is promoted in Windows 8.1) mklink command is not accessible. You should call regular command line by typing cmd and then proceed in the same window.
After that you can enable pagefile and newly created swapfile.sys will be located wherever the symbolic link points to. The symbolic link itself occupies minimal possible disk space.
 
Last edited by a moderator:

My Computer

System One

  • OS
    Windows 8.1 Pro X64
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Gigabyte Technology Co., Ltd. GA-B75M-D2V
    CPU
    Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz, 3601 Mhz, 4 Core(s)
    Motherboard
    Gigabyte Technology Co., Ltd. GA-B75M-D2V
    Memory
    8 GB DDR3 1600MHZ
    Graphics Card(s)
    GE Force GT 610
    Sound Card
    Onboard Realtek High Def
    Monitor(s) Displays
    Dell U2913WMP
    Screen Resolution
    2560x1080
    Hard Drives
    Western Digital WD10EZEX-00RKKA0 1TB
    Seagate ST2000DL003-9VT166 2TB
    Seagate ST31000528AS 1TB
Found the answer:-
...
After that you can enable pagefile and newly created swapfile.sys will be located wherever the symbolic link points to. The symbolic link itself occupies minimal possible disk space.

I can confirm that this method works. I was suspicious because the link points to a page about moving pagefile.sys, not swapfile.sys. It is a mystery to me why forbidding pagefile.sys on all drives also caused swapfile.sys to disappear; but it did. The symbolic link worked.

Now my pagefile.sys and swapfile.sys lie on a small partition separate from the C: drive (but still on SSD). (I just thought it was silly to be including these files in backups.)
 

My Computer

System One

  • OS
    Windows 8.1
    Computer type
    PC/Desktop
    System Manufacturer/Model
    HP P7-1439
    CPU
    AMD A10-5700 (APU)
    Motherboard
    MSI Jasmine
    Memory
    8GB
    Graphics Card(s)
    AMD Radeon 7660D (with APU)
    Browser
    Firefox, etc.
    Antivirus
    Windows Defender
Old post but this warning is not out-dated.

Do NOT do this to Windows 10/11.
Once you create this Symbolic link, windows will not be able to re-activate the Pagefile until that symbolic link has been destroyed. Even after you destroy that Symbolic link, from this point forward, when you try to move the pagefile off of the C drive onto a secondary SSD... windows will now create a SECOND Pagefile.sys file. There will be a x:\Pagefile.sys on your secondary drive... and Windows will notify the user with a msgbox that says "Windows had to create a second pagefile..." and suddenly you will notice that you also have c:\pagefile.sys.

You cannot undo this rubbish once you've done it... not without jumping though a bunch of hoops!
Simply deleting the symbolic link will allow the Windows Pagefile to be re-enable again, however the Admin will get this warning message and from this point forward, you will not be able to move the pagefile off of the C drive without Windows creating this extra pagefile on the C drive.

*I still haven't figured out how to undo this!
*I should probably point out that once this problem started, this problem completely removes your ability to disable the Pagefile from all disks. Regardless of whether or not completely disabling the pagefile is a good idea, sometimes we need to be able to disable it temporarily or simply because we want our pagefile on a secondary SSD. Either way, this problem wont allow the admin to disable the pagefile and if the admin tries to move the pagefile to another disk (d:\pagefile.sys) the result will be that they now have 2 files named Pagefile.sys.

What's my plan for fixing this?
• Well basically I'm out of ideas at this point, so I've cloned the disk over to an available/bootable disk.
• Then I'll probably just begin a fresh install of Win11pro.
*Why not try a Repair Install? Because I've seen it where a repair install wont fix certain issues and I already know that Symbolic links are actually a feature of the NTFS file system. It's not actually a Windows feature. So it is likely that this problem will persist past a Repair Install, making it a large waste of time.


Windows message informing user about needing to create a temporary paging file:
Screenshot 2024-02-12 180838.png


Despite the Pagefile being completely disabled, a C:\Pagefile.sys and C:\Swapfile.sys will still exist on the C drive. If you attempt to delete this file, Windows will inform you that the file is in use (pagefile still active). This has actually broken my Windows 11 install.

Screenshot 2024-02-13 030136.png



This next pic shows that even though NONE of my drives have a pagefile active, still Windows shows that a pagefile is active (this is the pagefile.sys that is sitting on my C drive which cannot be deleted or moved). So even though pagefile is disabled, it' is still paging.
Screenshot 2024-02-13 181231.png
 
Last edited:

My Computer

System One

  • OS
    Win10 21H1
    Computer type
    Laptop
    System Manufacturer/Model
    Asus
    CPU
    Ryzen 4900HS
    Motherboard
    Asus proprietary
    Graphics Card(s)
    RTX2060 Max-Q
    Browser
    Firefox
    Antivirus
    What?
Worth updating, why not? after all is knowledge for others too.
Acting on the assumption that the extended start up times I am experiencing (almost 5 minutes from entering pin or password until START screen appears) might be due to disk fragmentation I decided to defrag my Windows drive.
Of course a major obstacle in that exercise is the pagefile so I decided to set up a page partition on the disk that I use for online backups and file history since that disk is lightly used.
All well and good but then I spot SWAPFILE.SYS which apparently always gets on to the Windows drive no matter where the pagefile is located.
How can I move that file to another location?
First, forget about the swapfile.sys, you will go almost nuts trying to get rid of it, or the issues that come after somehow removing it. This is a SEPARATE file needed for universal apps. This means there is not just one unique-one-and-only swap file used by Windows.

Second, if we focused on what the original issue seems to be (speed after entering pin or password), you should look at the following:
1. Mechanical drive vs SSD (it matters a lot)
2. Startup items being executed (there are plenty of places, don't rely only on "startup items" list on the task manager, I suggest using Autoruns to find out what's being executed, you can disable them as needed.
3. Task Scheduler, check what actions are triggered and executed on system unlock, when starting up, starting a session, etc. You may be surprised.
4. Yes, remove bloatware as needed
5. Add RAM if possible
6. Play with different virtual memory settings, and consider reinstalling Windows, or a diff version (I don't mean 8, 10, 11, I mean a diff windows 8 ISO, there are other flavors, and stock... the one coming originally with some devices is different, this is the case of the Surface coming with Windows 8 and other devices).
Old post but this warning is not out-dated.

[...]

*I still haven't figured out how to undo this!
*I should probably point out that ...
Nice info. I don't have all the details right now at the top of my brain, but I suggest being careful when you change these settings, as not all the results are definitive. This means you can change something, revert, and being unable to go back to previous states, or just end up lost in unpredictable results.

Many times with Windows (but specially 10 while not exclusively), I've faced the boring task of changing the virtual memory settings and restart only to find out Windows did something else, as it won't always do what you tell the OS to do. This means you can do something and think "oh, this didn't work", but it was actually Windows failing to obey.

Other than that, virtual memory can be set off, on automatic, or exclusively on one drive. I've had great luck storing virtual memory on a secondary drive, but I also faced some problems with certain hardware forcing me to just leave it on automatic on the same OS drive.

Additionally, you may want to try third party apps that change your virtual memory settings, sorry I don't remember right now exact names, but some tweakers do this.
 

My Computer

System One

  • OS
    Windows 8.1 / Windows 10
Back
Top