How do I defragment Windows paging file

19,610

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.

Share:
19,610

Related videos on Youtube

user2543574
Author by

user2543574

Updated on September 18, 2022

Comments

  • user2543574
    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
      Dude named Ben over 9 years
      What version of Windows?
    • user2543574
      user2543574 over 9 years
      @DudenamedBen 64-bit Windows 7
    • Tetsujin
      Tetsujin over 9 years
      btw, the word you are looking for is contiguous, rather than continuous.
    • Tetsujin
      Tetsujin over 9 years
      Welcome. . . ;)
  • marsh-wiggle
    marsh-wiggle over 9 years
    I was till now convinced that the pagefile can't be fragmented.
  • Tetsujin
    Tetsujin over 9 years
    it 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
    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
    Tetsujin over 9 years
    if it's system managed, yes, as Windows sees fit.
  • Tonny
    Tonny over 9 years
    The only way to get really better performance is to buy more RAM. And it is probably cheaper too.
  • cybernard
    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
    user2543574 over 9 years
    @cybernard Thanks! That's really clever! Guess I'll stick to that and create another partition.
  • fixer1234
    fixer1234 over 5 years
    Welcome 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
    usr over 5 years
    Unfortunately, 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
    TiberiumFusion almost 4 years
    PageDefrag cannot operate on NT 6.0 or newer. Additionally, it only runs under x86 editions of Windows.