How do I defragment Windows paging file
Solution 1
If you want your swap file to truly be at the front of the drive use partitioning software, like gparted, to shrink your C: drive and create a partition, d: for example, and place the swap file there. If you are doing this to get better peformance you are better off getting a second, smaller hard drive or ssd, and dedicating it to only the swap file.
Solution 2
A simple solution (which won't move the pagefile to the beginning of the disk) is to disable virtual memory, then reboot and finally re-enable pagefile (this time with a fixed size).
This method will ensure your new pagefile is in one "chunk" on your disk and will also prevent any future fragmentation of the pagefile.
Solution 3
Moving it to the beginning of the disk is relatively pointless nowadays, but for defragmenting it you can use PageDefrag. Note that fragmented files are not an issue on SSDs.
Solution 4
First remove the pagefile entirely. Then defrag your C:-drive with Puran Defrag or similar software. And finally set the pagefile to a fixed size, the recommended size + 2 MB. Use the same size for the minimum and te maximum size, so the pagefile will not defragment anymore.
Solution 5
Smart Defrag come with a lot of additional software. Bloatware. I would recommend Defraggler. It's small and fast and also has boot time defrag option. It display drive map and visualize what's being done (read, write) as it go with defragmentation (normal not boot time). At boot time it give you a textual output. Defraggler is free but has paid version with commercial support if you'd like. I use free one as it just is all I need.
Related videos on Youtube
user2543574
Updated on September 18, 2022Comments
-
user2543574 almost 2 years
Any suggestions how can I make
pagefile.sys
contiguous and move it to the beginning of the disk? Much appreciated.Update:
I use Windows 7 64-bit edition.
-
Dude named Ben over 9 yearsWhat version of Windows?
-
user2543574 over 9 years@DudenamedBen 64-bit Windows 7
-
Tetsujin over 9 yearsbtw, the word you are looking for is contiguous, rather than continuous.
-
Tetsujin over 9 yearsWelcome. . . ;)
-
-
marsh-wiggle over 9 yearsI was till now convinced that the pagefile can't be fragmented.
-
Tetsujin over 9 yearsit can quite easily frag if it's set to system managed size. It shrinks, a file is placed next to it, it grows - fragged.
-
marsh-wiggle over 9 years@Tetsujin off topic to my comment and the question, but does the pagefile get ever shrinked (except when its done manually)?
-
Tetsujin over 9 yearsif it's system managed, yes, as Windows sees fit.
-
Tonny over 9 yearsThe only way to get really better performance is to buy more RAM. And it is probably cheaper too.
-
cybernard over 9 years@Tonny I guess I should have qualified that, the question only asks about the swap file. The only way to get better performance from your swap file. Better performance globally is new CPU,8+gb RAM, motherboard, SSD and etc
-
user2543574 over 9 years@cybernard Thanks! That's really clever! Guess I'll stick to that and create another partition.
-
fixer1234 over 5 yearsWelcome to Super User. For readers unfamiliar with the procedures, can you expand your answer a little to describe how to remove the pagefile, and how to enable it and set the size? Thanks. BTW, just noticed that this pretty much duplicates Kristian's answer. The intention is that each answer provide a substantially different solution than what has already been contributed. So adding some instructions (that were also lacking in Kristian's), would differentiate this answer.
-
usr over 5 yearsUnfortunately, Windows likes to pick up every tiny free space hole. When I do this I get 70000 fragments for a 16GB file. NTFS has horrible allocation algorithms.
-
TiberiumFusion almost 4 yearsPageDefrag cannot operate on NT 6.0 or newer. Additionally, it only runs under x86 editions of Windows.