Intro Download and install Frequently Asked Questions Tips and tricks

Homepage







© J.C. Kessels 2009
MyDefrag Forum
August 22, 2014, 12:45:01 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to make gap for pagefile.sys  (Read 5865 times)
kethd
JkDefrag Junior
**
Posts: 8


View Profile
« on: May 06, 2010, 04:23:27 am »

How to make gap for pagefile.sys
How to put pagefile where you want it

context: Windows XP NTFS, MyDefrag v4.2.9

situation:
You understand your Windows OS. You have read all the endless debates about optimizing pagefile.sys various ways. You have decided to use a fixed size pagefile. You want to put it exactly where you want it.

1) How to know where your pagefile is

The old free version of SpaceMonger is great for seeing a map of your files, but it shows only the logical organization.  Sysinternals diskview is a good way to see a physical map of the hard drive, but not very good for showing what is where. You might be able to see pagefile. Sysinternals pagedfrg will quickly show the number of fragments in pagefile.sys but will not tell you where they are. Sysinternals ntfsinfo shows good volume info (which you will want later) but does not show info about individual files. Microsoft nfi.exe and diskedit are supposed to be able to give NTFS file details, but are very obsolete/obscure and I could not locate a public copy of nfi.exe to download that could be trusted and would actually work. (Can you suggest one?)
   The only way I could find to get the exact details of pagefile.sys is to use a current Linux utility liveCD. Parted Magic v4.10 (UBCD 5.0 RC2) works well:
   ntfsinfo -F pagefile.sys -v /dev/sda2
gives the LCN location for each file fragment. (It only works if the partition is NOT mounted.)

The standard AnalyzeOnly MyDefrag script may also show your pagefile fragements. You can edit the script to highlight the pagefile:

VolumeActions
  AppendLogfile("MyDefrag.log","LogAnalyzeOnly")
  SetFileColor(FileName("pagefile.sys"),All,255,255,255)     // white
  Pause()

2) How to make gap for pagefile

Modify a standard script thus:

Title('MakeGap by Vacate')
Description("MakeGap by Vacate")
// Title('Optimize Monthly')
// Description("Optimize Monthly description")
WriteLogfile("MyDefrag.log","LogHeader")
VolumeSelect
  CommandlineVolumes()
//  and Removable(no)
  and Writable(yes)
  and Mounted(yes)
VolumeActions
  AppendLogfile("MyDefrag.log","LogBefore")
  SetFileColor(FileName("page*.*"),All,200,200,200)          // grey
  SetFileColor(FileName("pagefile.sys"),All,255,255,255)     // white
  SetFileColor(FileLocation(AnyPart,(0.13 * 19.5M),(0.20 * 19.5M)),All,0,0,200)    // blue highlight range by LCN
  Pause()
  /* Vacate files at % into the partition. */
  MakeGap(VolumeSize * 0.15, DoNotVacate)
  MakeGap(VolumeSize * 0.18)   // implicitly Vacate the Gap!
  FileSelect
    FileName("JUNK")   // dummy placeholder to trigger MakeGap
  FileActions
  FileEnd
  AppendLogfile("MyDefrag.log","LogAfter")
  Pause()
VolumeEnd
AppendLogfile("MyDefrag.log","LogFooter")

This script is based on a 80GB hard drive partition with 19.5M LCNs. It makes a gap from 15% to 18%, about 2.4GB. You might want to make a gap somewhat bigger than you think you will need, because there may be some unmovable dregs in the gap. You would be wise to first experiment with this script with removable flash drives. It works with NTFS but does not work so well with FAT because the directories won't move. This does not seem to be a problem with NTFS. Is there any solution for FAT?
   You may want to run the script more than once to try to clear out any dregs. I had one unmovable $ATTRIBUTE_LIST. I was able to fix this by moving the associated ordinary file onto a separate removable drive and then moving it back. There was also an unmovable C:\$EXTEND\...$J:$DATA that I don't understand, so I had just that one spot I had to work around.

3) How to put pagefile exactly where you want it

This script works:

VolumeActions
  AppendLogfile("MyDefrag.log","LogBefore")
  SetFileColor(FileName("page*.*"),All,200,200,200)          // grey
  SetFileColor(FileName("pagefile.sys"),All,255,255,255)     // white
  SetFileColor(FileLocation(AnyPart,(0.13 * 19.5M),(0.20 * 19.5M)),All,0,0,200)    // blue range by LCN
  Pause()
  MakeGap(VolumeSize * 0.15, DoNotVacate) // start zone at 15%
  FileSelect
    FileName("pagefile.new")
  FileActions
    SortByName(Ascending)   // this does work
  FileEnd
  AppendLogfile("MyDefrag.log","LogAfter")
  Pause()
VolumeEnd

In order to use this script, first use the standard Windows control panel to set the system Virtual Memory size to the fixed number you choose (I used 1850MB). If you make this setting bigger, it will happen right away.  If you make this setting smaller, it will not happen until you restart.
   Even though you have cleared a gap for pagefile, Windows will probably not put it there. Sysinternals pagedfrg will defragement pagefile, but won't put it where you want it. You need the script above to put pagefile in the right place. But the script will not work on pagefile while it is in use. So you will have to use a tool like Parted Magic to rename pagefile.sys to pagefile.new. Reboot into Windows. Run the script above to put pagefile at 15%, or wherever you want it.  But meanwhile Windows will make a new pagefile.sys. If you have bad luck it will put some of it in your cleared gap.  You might need to turn off VM and restart to be able to re-clear the gap.  Then run the above script to put pagefile.new exactly where you want it.  Turn VM back on.  Boot Parted Magic, rename any extra pagefile.sys to pagefile.old, rename pagefile.new to pagefile.sys.  Reboot into Windows.  Run AnalyzeOnly and admire your success.
   Get a good night's rest and start thinking about how to optimize the rest of the files.

Note:
If you are a MyDefrag expert, you could probably start with the last script, and just try to put pagefile directly where you want it, without making a gap first. You might have enough success to just stop there. But us newbies would want to see a clear gap first so we know what is going on, and don't end up with a wrap-around-fragmented pagefile that we don't understand...
   You have one easy opportunity when you first install Windows and the drive is mostly empty to setup VM to use a big fixed unfragmented pagefile.sys located towards the front of the partition. Later there is too much clutter and there is no easy answer.
   It is amazing that something so simple is so hard to do.  You probably want to make pagefile plenty big, because you don't want to have to do this more than once.  The power of MyDefrag scripts is wonderful, but they are tricky so you will want to experiment first on removable flash drives.
   Do you know how to set XP to rename pagefiles while rebooting so Linux does not have to be used?  Tell us how.
Logged
jonib
JkDefrag Hero
*****
Posts: 822


View Profile
« Reply #1 on: May 06, 2010, 05:10:25 am »

There was also an unmovable C:\$EXTEND\...$J:$DATA that I don't understand, so I had just that one spot I had to work around.
You can read about this file here: How do I defragment "C:\$Extend\$UsnJrnl:$J:$DATA"?
Quote
Do you know how to set XP to rename pagefiles while rebooting so Linux does not have to be used?  Tell us how.
I believe you should be able to disable the pagefile.sys, and then create a new file with the right size and name it pagefile.sys, then place it where you want it with MyDefrag, now activate the pagefile in Windows and it should use the existing file. I haven't done this in a while so no guarantees.

jonib
Logged

kethd
JkDefrag Junior
**
Posts: 8


View Profile
« Reply #2 on: May 06, 2010, 01:49:13 pm »

Thanks for the tip about:
Quote
How do I defragment "C:\$Extend\$UsnJrnl:$J:$DATA"?    
   DeleteJournal
Delete the Update Sequence Number (USN) change journal. The journal is stored in a huge file called "$Extend\$UsnJrnl:$J:$DATA" in the root of a volume, and is invisible to (most) applications...

I did actually try creating a new pagefile by hand.  It sounds easy.  It should be easy.  But I was nervous about getting the file associations messed up, and nervous about working with such an important system file.  I tried Sysinternals contig.  I even tried "dd for Windows" in desperation.  But there are issues with getting the file exactly the right size.  The safe thing seems to be to make the file a little bigger than you need, but what effect does that have?  And on my XP test system, after I made the new files, every time I right-clicked on them in Explorer to work with them, the cpu locked up at 100%!  I finally figured out that this was because the files were completely empty, all zeroes, so they were just "virtual" files that take no space.  This sounds wonderful, but was working out badly for me.  I could use dd to put in random data anywhere and the problem seemed to clear up.  (Does anyone know why right-click in Explorer was hanging on these all-zero files? Maybe one of my right-click add-ons?  How to troubleshoot? Small files were OK. 12MB files would hang for about one second.  1GB-ish large files would seem to hang forever.)  After all that bad luck it just seemed simpler and safer to let the system make the pagefile so I knew it was exactly the right size with the right file attributes.  Would be nice if MyDefrag had a special command to make a pagefile.new, just the right size and put it exactly where you want it.  Would be nice if the standard MyDefrag log, or the debug log, reported on the number of pagefile.sys fragments and their location. (Would someone please write a simple little free program to tell the location and fragmentation details of a NTFS file in Windows -- should be easy?)

The new MyDefrag FileLocation command is nice, but confusing that it requires LCN. We have VolumeSize in bytes and VolumeSizeG.  We need VolumeSizeLCN too! Would it just equal VolumeSize divided by BytesPerCluster?
Logged
jeroen
Administrator
JkDefrag Hero
*****
Posts: 7220



View Profile WWW
« Reply #3 on: May 06, 2010, 02:15:04 pm »

I have never tried it myself, but I hear that MyDefrag can defragment/place the pagefile like any other file, if you boot your computer from a cdrom. No need for complicated makegap procedures, just standard basic MyDefrag scripting.
Logged
Darlis
JkDefrag Hero
*****
Posts: 1767


View Profile WWW
« Reply #4 on: May 06, 2010, 04:27:59 pm »

The new MyDefrag FileLocation command is nice, but confusing that it requires LCN. We have VolumeSize in bytes and VolumeSizeG.  We need VolumeSizeLCN too! Would it just equal VolumeSize divided by BytesPerCluster?
You can translate Bytes in LCN by dividing them by BytesPerCluster: 1MB / BytesPerCluster = 256 LCN (If your cluster size is 4096 Bytes)
Logged

Need help creating a script? Try MyDefrag Script Creator.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!