0

I have two operating systems installed (windows 8 & mint) and I am trying to shrink the original windows partition, but there is the swapfile.sys permanent file in the way. So I was wondering, is it possible to log into the Linux side, then access the swapfile.sys and move it when it is not open?

3 Answers 3

2

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.

1

This is the new pagefile for "Windows Store Apps". I've searched for a way to move it for, but never found a way. You can only stop the creation if you disable the pagefile completely.

5
  • The pagefile has been completely removed and is not imposing on my drive. I am logged in on Linux now, and perusing the Windows partition. If I move/delete the file from this side, will it break Windows?
    – topherg
    Jan 23, 2013 at 11:32
  • When turning off the pagefile and do a reboot, the file should be gone. So I have no idea why you still see it from Linux. Jan 23, 2013 at 19:44
  • So its a cache which is supposed to be deleted. So I can delete it, and when I go into Windows, will it mind that the file is missing, and if it creates a new file, will it be in the same location?
    – topherg
    Jan 23, 2013 at 23:22
  • I have no idea if it will be created again. I think so, because the normal pagefile.sys is created again. Jan 24, 2013 at 4:49
  • ah cool, i'll have a go later, and i'll let you know if its ok or not incase anyone else has a similar issue
    – topherg
    Jan 24, 2013 at 10:58
0

There is also an undocumented registry value which controls where swapfile.sys is stored:

  • Registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management
  • Value name: SwapFile
  • Type: REG_MULTI_SZ

Its value should be a single string with this format: <path> <min_size> <max_size>. For instance, to move the swapfile to d:\swapfile.sys with a minimum size of 100 MB and a maximum size of 600 MB, you set the entry to d:\swapfile.sys 100 600:

reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v "SwapFile" /t REG_MULTI_SZ /d "d:\swapfile.sys 100 600"

The syntax is the same as for the PagingFiles value in the same registry key which controls the locations and sizes of the pagefile.sys files. In theory, setting 0 for both min and max sizes should let Windows manage the size of swapfile.sys automatically like this is the case for the pagefile.sys files. But this does not seem to work, so you have to set the size manually in the registry value. Using 0 for both sizes actually prevents the file from being created.

By default, the minimum size is set to 256 MB and the maximum size is set to 150% of the total RAM or 10% of the hard drive total space (whichever is the minimum). For small drives, minimum size is set to 16 MB instead and maximum size to the same value if disk size is smaller or equal to 16 GB, or 256 MB if disk size is smaller or equal to 32 GB.

Compared to the mklink method, changing the value in the registry should make it possible to preserve the settings between major Windows (10) updates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.