Friday, January 10, 2014

How to optimize Windows 7 for an SSD drive




As some of you may know, an SSD drive has a limited lifespan of around 100-1000 written terabytes (here's an interesting link that shows some statistics on SSD lifespans). Therefore it is best practice to minimize the amount of data written daily onto it, especially if it's a system disk.

Here I will show how to move the most data intensive system folders to another drive, and to tweak the system to write less onto your SSD operating system drive, under Windows 7.

It is important to note that if you care about the lifespan of your SSD drive, it is always a good idea to have an additional drive in your configuration (another (less valuable) SSD or another HDD drive) to store your user files and to minimize the load on the main SSD drive.

First we start by moving the default pagefile to your other drive's partition by going into Start > right click on Computer > Properties > Advanced System Settings > Advanced (tab) > Under "Performance" click on Settings > Advanced (tab) >  Click on "Change" under Virtual Memory. This will open a new window called "virtual memory" where "Automatically manage paging file size for all drives" will be checked. Uncheck the box near that sentence and click on your system partition shown in the list of all partitions. Now click on "No Paging File" radio button and click on "Set". This will remove the pagefile from your system partition. Now, some people who have 16GB RAM or more in their machine leave Windows running without a pagefile, but I do not recommend it because some problems may happen, such as when explorer.exe suddenly bloats to over 15GB of RAM.
Now click on a different partition (located on your other drive) and click on "System managed size" radio button, and click on "Set" to enable it. Click OK and restart your system. Once you boot back, you will see that your system partition has more free space than before, on the account of us moving the pagefile to another partition.

Next we should disable Hibernation, which also create a temp file on your system partition (which CANNOT be moved) called hiberfil.sys. We do this by going into command prompt in elevated mode and running:

powercfg.exe /hibernate off

This will immediately disable hibernation and erase the hiberfil.sys file. If you must put the computer to sleep - use sleep mode if your motherboard supports it correctly, or simply turn off your machine. Your SSD is fast enough to boot real quick with no need for sleep mode.

Next - we move on to the system's temp folder, user's temp folder and temporary internet files.

First off, we should create a main temp folder on the secondary hard drive. Let's call it MainTemp. Inside it - create a folder for the system's temp files, let's call it SysTemp. Now for the user's temp files - UserTemp.

To change the system's and user's default temp folder location go into Start > right click on Computer > Properties > Advanced System Settings > Advanced (tab) > Environment Variables...
Here you will see two fields that show User Variables and System Variables. User variables will usually only cover TMP and TEMP entries, which you should both change to the path you crated on that other drive to the user's temp folder that we called UserTemp.
In the system variables, scroll down to the same TEMP and TMP entries, and change their paths both to the new folder we've created on the other drive, called SysTemp.
So if the other drive's partition is D, then the user's TMP and TEMP should point to D:\MainTemp\UserTemp
And the system's TMP and TEMP should point to D:\MainTemp\SysTemp.

After restarting, these changes should be enacted.

Now, we move on to the Temporary Internet Files.

With Internet Explorer it's quite easy to change the temp folder location.
First we should add another folder under our MainTemp folder on the secondary drive, let's call it IETemp.

Then, go into IE, click on the Alt button on the keyboard, this will bring up the menus. Click on Tools, Internet Options, under Browsing History click on Settings, click on Move Folder and navigate to the newly created temp folder on that other drive. Click on OK, it will ask you to save new location and reboot, click on Yes, and the computer will reboot.

Google Chrome however does not let the user easily change the location of the temp folder.
Let's again create a new temp folder for Chrome on our secondary drive, let's call it ChromeTemp under Maintemp.

What we have to do is create a shortcut to Chrome on the desktop (if it's not already there), and right click it and choose Properties. This will bring up a window with the shortcut settings. In the "Target" field we have to add a command that will point Chrome to the new temp folder we created earlier.
The existing path is something like this:

"C:\Program Files\Google\Chrome\Application\chrome.exe"

We want to change it to:

"C:\Program Files\Google\Chrome\Application\chrome.e­xe" --disk-cache-dir="D:\MainTemp\ChromeTemp"

Click OK to save the new shortcut changes.

So now using this new shortcut - Chrome will store all the temporary files on the secondary drive.

Hopefully these tweaks should free up more space on your SSD and let it live longer.