28 Ιαν 2010

Defrag & Various system files

What is file fragmentation?
When files are written on the hard drive, they occupy the free space they find. When we start deleting files and new ones being written, don't occupy contiguous free space. So they break into smaller contiguous pieces. This is file fragmentation. File fragmentation is heavier on hard drives without much free space.

Why is fragmentation a bad thing?
The hard drive has moving parts. These parts need time to move from one place on the drive to the other. The more times they have to move the more time it takes to ready our data. Heavy fragmentation means slower hard drive performance.

What happens during defragmentation?
All files occupying non contiguous hard drive space, are moved on the drive in such a way so that they become contiguous and it is faster to read them afterwards.

What issues might we run across during defragmentation?
When defragmenting a partition, it is quite common to not be able to defrag files like the Master File Table (MFT), USN Journal and other system files. Simple defragment utilities (like the one included in Windows) do not address this problem at all. If your MFT or paging file is in fragments, it will continue to be that way even after defragmenting your hard drive. There are some specialized software that can defragment system files, but I will not mention them here. Instead I'll try to present workaround on how to defragment these system files using only the operating system utilities and programs.

How to defragment the paging file?
One easy way to do that is to completely turn off the virtual memory or use another drive/partition to host the paging file. This way the paging file will be deleted. We defrag the drive as usual and after that we turn back on the virtual memory. The new paging file will occupy contiguous hard drive space.

How to defragment the hibernation file?
There is a file called hiberfil.sys and is used when the computer enters hibernation (power saving) mode. To defragment this file, simply turn off hibernation using the command:
powercfg.exe /hibernate off
Defragment your drive and then turn hibernation back on using the command
powercfg.exe /hibernate on

How to defragment the USN Journal?
USN Journal is created and used whenever a program requires it. So it is perfectly safe to completely delete it as it will be recreated properly whenever needed. You can delete it using this command:
fsutil usn deletejournal /D driveletter

How to defragment the MFT ?
I don't know any way of defragmenting the MFT without any 3rd party software and without formatting the hard drive of course ;) By the way, when a hard drive is formatted the MFT occupies contiguous hard drive space. If you really need to defragment The MFT you could try to use and imaging software like CloneZilla.

How to defragment user registry files?
The files NTUSER.DAT under each user profile, can not be defragmented while the user is logged on. To defragment these files, log off the user with the fragmented ntuser.dat file and log on using another user. Defragment the drive and then log the original user back on.

When should we defragment our hard drives?
Defragmentation should be done often, like once a week. This way the files are neatly placed on the hard disk, the free spaces becomes contiguous and it is not easy for the drive to become heavily fragmented, even if it does not have much free space.


... more information will be added as soon as I discover something more.

Socializer Widget By Blogger Yard
SOCIALIZE IT →
FOLLOW US →
SHARE IT →