Wednesday, November 30, 2005

Say no to Defragmentation!

Before you say, "Is this guy nuts?", listen to me. I know this goes against all that you've ever heard about how to keep your PC fast. The first point is always defragment regularly. I've had my home pc for 4 years, and not once have I defragmented my drive. And it runs as fast as it did the day it came. Of course, I went through the rest of the disciplines like keeping your services under check and regularly scanning for viruses and other evil things. But I've never defragmented my home PC. Okay I'm lying... only twice in two years. But that's still impressive right?

So I'll begin my how-to with giving the reasons for fragmentation. Fragmentation comes in two flavours. External fragmentation, and internal fragmentation. External fragmentation is when files in a folder on the disk are spread across the entire disk instead of being close together so that when they are accessed in quick succession, like photographs, or program files, the hard disk doesn't have to go around hunting for them. Internal fragmentation is when a single file itself is spread across the gigabytes of space available on your hard disk. Now, the internal kind is generally more evil and contributes most to slowing your computer down. One generally does read entire files from the disk, unlike entire contents of a directory. When you defragment, you are collecting these pieces and putting them back together in one place.

So obviously, to never have to defragment means that one doesn't allow files to get fragmented in the first place. The magic word here is partitions. Your hard disk can be configured so that it shows up under "My Computer" as separate partitions. Making partitions is a one time effort. Its the how many and of what size questions which matter.

What I've done is subdivided my storage requirements into the following categories:
1. Operating System
2. Programs/Applications
3. Swap & Temp.
4. Data
5. Music
6. Mail


So yes, my hard disk does have 6 partitions on it. The way to go about this is to format your hard disk. There are ways around this, but generally formatting is the best option. You just have to do this once, and you'll thank me for the performance gain that you see. So when you format, delete all existing partitions, and create a brand new partition for installing Windows. You should normally keep around 5 GB for this. Leave the rest of the disc unpartitioned.

Once Windows is installed, right click "My Computer" go to "Manage" and select "Disk Management" in the tree view. Here is where you create the rest of the partitions. I'm listing possible sizes for 40GB and 80GB hard disks:

40GB:
1. Windows 5GB
2. Programs 10GB
3. Swap and Temp (3 times your RAM + 1GB)
4. Data 5GB
5. Music 10GB
6. Mail Rest of space.

80GB:
1. Windows 5GB
2. Programs 20GB
3. Swap and Temp (3 times your RAM + 2GB)
4. Data 15GB
5. Music 25GB
6. Mail Rest of space

You can adjust for other hard disk sizes. Also note that you can customize this further. I normally keep my installation files on the same partition as my Programs partition. You can create a new partition just for that. Also, the mail partition is necessary if you use IMAP or POP3 mail. You don't need that partiton for webmail.

The next thing to do is to tell your computer where to store your virtual memory file. The default is the same partiton as your windows partition. You should change this to your Swap partition. To do this, go to "My Computer Properties", "Advanced" tab, and click on the "Settings" button in the "Performance" box. In the dialog that pops up go to the "Advanced" tab again, and click on the "Change" button at the bottom. In the list select your windows drive, and set the radio button to "No Paging File". Then select the "Swap and Temp" drive and set the "Custom Settings" radio button and set "Initial Size" to the same amount as your RAM and the Maximum Size to twice your RAM. If you have less than 256MB RAM, set the radio button to "System Managed Size" instead.

Next, you have to tell windows to store your temporary files in the swap partition. In the "Advanced" tab on the "My Computer Properties" dialog box, click on the "Environment Variables" button, and change the TEMP variable's value to a folder called "temp" on your Swap and Temp partition.

Next change the location of your "My Documents" folder to a folder called "Data" on your Data partition.

Next install all your other software in the "Program Files" folder in your Programs partition. Then you are done.

Some things to remember:
1. BACKUP your data before formatting your hard disk.
2. Don't do this if you think you're not proficient enough, or don't have enough experience. Get someone else to do it for you.
3. Always install programs on the Programs partition's "Program Files" not your Windows partition's "Program Files" folder.
4. Directions given are for Windows XP. You'll have to look up ways for other ways of windows yourself.
5. BACKUP your data before formatting your hard disk.

That's it. Your computer will run fast for ages. Run the windows defragmenter once a year on all your partitions. That should be enough.

Comment if I've left any loopholes, or if you face some problems other than lost data. I'll be glad to help out.

Ciao.

2 comments:

Anonymous said...

Doesn't Windows XP limit the number of primary partition sthat can be created to 4?

Saurabh Gaur

Storm said...

Of these only windows, programs and swap need to be primary partitions. The other three are placed as logical partitions on an extended partition.