VuULF Dot Com Geek, Tweak and Game

1Dec/080

Optimizing Your Swapfile – Step 2

Step 2 - Defragmenting Your Target Drive

In order to get the swapfile to perform better, we will need to defragment your target hard drive. Defragmenting basically means that you are taking data that is spread out in small chunks over your hard drive, a putting them into a single chunk on only one place on your hard drive. Windows Vista does a pretty good job of keeping your hard drive defragmented automatically, but I have found that you will still end up will a lot of fragmented files, especially if you don't leave your system on 24/7. While I prefer to use a professional defragmentation software called Diskeeper, for this article I want to keep things free. You could use the trail version of Diskeeper, however I tend to place a small utility on client systems called JkDefrag. Now before you run off and download JkDefrag, I would also like to mention a little piece of software that goes hand in hand with JkDefrag called JkDefragGUI. This program will automatically download the latest version of JkDefrag as well as some other support files from SysInternals and from Lars Hederer. Here is a direct link to the JkDefragGUI download file: http://www.emro.nl/freeware/download.php?f=JkDefragGUI103.zip.

After your have downloaded the software and unzipped it, simply run the program called JkDefragGUI.exe. Luckily this program is smart enough to know that it needs Administrative rights so we don't need to go through the hassle of setting that up. However, for some reason, Emiel Wieldraaijer, the author of the JkDefrag script, doesn't automatically detect if you are using Windows Vista, and the software will tell you that it couldn't find Mark Russinovich' program called PageDefrag, and asks if you would like to download the file. PageDefrag is not compatible with Windows Vista, so you want to say no (Note to Emiel - you should have your AutoIT script detect Vista and ignore downloading PageDefrag if it encounters Vista - use the macro @OSVersion to detect which will allow you to save the end Vista user the download of Vista incompatible PageDefrag). Now you should have a clean looking GUI with a whole bunch of tabs and options available. You can close this program for now, I just wanted you to have a look at the software and get the support files that will be needed later. For now, let's start cleaning up that hard drive.

First off, If your computer is running smooth and clean, without any hiccups, you will want to completely disable System Restore, thus removing all of the files. This step is optional, but it will allow you to free up some space and give you a more thorough defrag. While I do suggest doing this step, it is completely up to you. System Restore keeps snapshots of your system at various points. If your system doesn't work for some reason, you can rely on the System Restore points to go back to a point where the system was working OK. Still, this eats up a lot of space and becomes very fragmented over time. Simply disabling the System Restore function temporarily will delete the files it has stored, and thereby eliminate those fragmented files. This is a perfectly acceptible thing to do, however, if you do this step, and some fluke thing happens to your system and you cannot use System Restore to recover it, I take no responsibility whatsoever for your action - you must make the decision whether to turn this function on or off, I have nothing to do with that decision.

That said, in order to turn off the System Restore Function, click Start, right click Computer and click Properties. On the window that pops up, on the pane on the left you will see a link to System Protection. Click that link and click Continue on the UAC panel. You will end up with a window that looks like the one below.

System Restore Window
System Restore Window

For every hard drive that you have check marked, remove the check mark by clicking it. You should be prompted with the following window, to which you should respond by clicking Turn Off System Restore.

Turn Off System Restore
Turn Off System Restore

If you want to save yourself the hassle of reopening the System Restore window, and also serve yourself a reminder to turn System Restore back on when we are finished defragmenting, hit Apply on the System Restore window and the window will stay on the screen, otherwise hit OK to turn it off, but remember how to get it open again as referenced above.

Normally, I would suggest to eliminate a lot of other junk on your system using CCleaner or the Windows file cleaner, but CCleaner tends to be too aggressive for some users, and the Windows version takes a long time to complete. While it would cut down defrag time a bit, and give you more free space on your hard drive, it isn't really necessary for this tutorial, so I will leave that to your own discretion. I wouldn't bother at this point. Besides, JkDefragGUI has a nice little feature which will allow you to get rid of some of the useless stuff anyway, which we will now do.

Open up the JkDefragGUI.exe program. When opened, click on the Cleaner tab and you will be shown various options that you may or may not want to clean from your system. I would suggest not removing cookies, especially if you rely on IE to store passwords for websites you vist often. Also the recent folder is best used at your own discretion. I tend to dump it, but I don't really use recent items anyway, so the choice there is yours. You should have something that looks like this when you are finished.

JkDefragGUI Clean Function
JkDefragGUI Clean Function

After you have made all of your selections, you should click Run. Do note, that on Windows Vista you should select the All Users variety of file deletion, as some of the system accounts and UAC may place files in administrative folders. You should also optimize the registry and empty the prefetch folder. Optimizing the registry will, essentially, compact it. When Registry Optimizer is running your computer may act as if it is crashed: DON'T PANIC! Let it do it's thing and all will be well. Emptying the prefetch folder will get rid of information that Windows stores to make your programs start faster. This will rebuild over time, and it is a good idea to dump it once in a while to get rid of the bloat; once every three months or so is usually a good measure. After a few minutes of cleaning, you will be back at the Clean Tab on JkDefragGUI. Once that is finished, it is time to start messing around with the swapfile itself.

In order to get the best performance from your hard drive, you want to place the swapfile at the front end of your disk. To do this we will want to offload the swapfile to the slower hard drive temporarily while we defragment. To do this, open the System window again (Start, right click My Computer, click Properties). This time we want to click the Advanced System Settings link in the left pane. This will bring up a System Properties window on the Advanced tab. We will want to click the Settings button located in the Performance pane, as shown below.

System Properties Window
System Properties Window

Having done this, you will now have a Performance Options window, where you will want to click on the Advanced tab. Under the Virtual Memory pane (another name for the swapfile, which is additionally known as a pagefile), you will want to click the Change button. In this window, we have a few things to do. First, find your slower hard drive in the list and click it. There should not be a swapfile on your slower drive, hopefully, however if your slower drive is the one that has the swapfile, ignore this section and skip past to where we defrag. For anyone who has the swapfile located on their faster hard drive, you need to select the slower drive. Click the Custom Size radio button and then set the size to 2048 (that's two gigabytes) in both the Initial Size and Maximum Size text entry boxes, and then click Set. A quick note here; Windows may recommend a larger swapfile for you, using that size for the Initial and Maximum size is fine, but really, 2 Gigs is more than enough for almost everyone reading this article. Now, we need to remove the swapfile on your faster hard drive. To do this, select that drive in the list and click the No Paging File radio button and then Set. If you get a warning window regarding sizing your swapfile, click Yes and continue on, as we have a swapfile set on the alternate drive. Click OK on all of the open windows and you will be prompted to reboot. Do so. I will wait here for you. No, really. Go ahead and reboot.

Yay! You're back! You may notice your system is actuing a little bit sluggish. That is because the swapfile is now located on the slower hard drive, and accessing it isn't as zippy as on the first drive. Another note, because I know it will be asked, is that when Windows boots, it places files in the prefetch folder. Why did we clear the prefetch before the system rebooted? Basically, the prefetch folder will now have only the essential system services and programs required to start up stored in it, and it will be defragmented for quickest response, without having to wade through all of the other stuff.

Now let's defragment. Open JkDefragGUI.exe. On the General tab we will want to select the hard drive from the pulldown menu which corrensponds to your fastest hard drive. We will also want to make sure that the Action pulldown is set to Analyze, Defragment and Fast Optimization. Finally, we will want to make sure we have enough free space at the beginning of the hard drive for the swapfile. Since we want at least two gigs, leaving it at 1 percent is probably fine. Just do the basic math. If your hard drive is 200 gigabytes then 1 percent will be 2 gigabytes. For those with less than 200 gigs you will want to allocate at least 2 percent, or perhaps even more if you are using a very fast smaller hard drive. If you are at, say, 80 gigabytes, set the percentage to 3 percent which will give you 2.5 gigs of free space at the beginning of the hard drive. Basically, this is what you should see.

JkDefragGUI Ready to Defrag
JkDefragGUI Ready to Defrag

Now you will want to click Run. You will see the JkDefrag window open and you will finally be defragginng your fastest hard drive. Remember, though, while defrag is a good thing, like beer and wine, too much of a good thing is detrimental. Defrag stresses your components and you should only do a full defrag at most once every month or longer, or purchase software that will keep your hard drive fragment free automatically and safely, like Diskeeper. At any rate, you should see something like the following image pop up while you are defragmenting. Now you can go grab a coffee and sit back and read a book for the next little while; this will take some time to complete.

JkDefrag in Action
JkDefrag in Action

Done now? Great! As you saw, JkDefrag will alert you when it is finished. Now you can quit all of the Jk programs, including the JkDefragGUI, and we can set up your swapfile on the fastest hard drive, and you can feel confident that you are getting the most performance out of your swapfile.

Now onto the finale, STEP 3.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.