|
kethd
|
 |
« 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.
|