How to schedule hard drive defragmentation

theigloo wrote on 3/4/2004, 10:52 AM
One of the absolute worst parts of Windows is the fact that users must manually defragment their hard drives. This is a fundamental short coming of the OS. Computers are supposed to do stuff like that for us.

All of us poor PC suckers are constantly wondering "Is it time yet? Should I check?". We are always in fear of the inevitable decline into fragmentation.

I recently discovered a way to schedule defragmentation and thus forget about it forever. I will never defrag my drives again.

It's pretty easy. Here are the steps (XP + 2000 only - users of other OSes are fools):

Start > All programs > Accessories > System Tools > Scheduled Tasks.

Click "Add Scheduled Task".
Click Next
Browse to C:\WINDOWS\SYSTEM32\defrag.exe.
Choose your preference of daily/weekly... (I chose weekly)
Pick a time (I chose a time when I know I'm way asleep)
Enter User/Pass.
Click the check box that says "open advanced options when wizard is done".

In the Run: box, enter C:\WINDOWS\SYSTEM32\defrag.exe c: -f -v.
The c: is for your hard drive.
The -f forces the defrag to occur, whether windows wants to or not.
The -v is for verbose output (I like it... but you can remove it).


--- BUT WHAT IF YOU HAVE A MULTIPLE HARD DRIVES? ----
No problem. You have two choices. Either repeat the above process for each drive (making sure the jobs won't overlap). Or, more elegantly, you can create a new file somewhere on your hard drive called defrag.bat. Open the file with notepad and put in one line for each hard drive. Like this:

C:\WINDOWS\SYSTEM32\defrag.exe c: -f -v
C:\WINDOWS\SYSTEM32\defrag.exe f: -f -v
C:\WINDOWS\SYSTEM32\defrag.exe e: -f -v

Don't try to defrag your cd-rom :). Then simply schedule your new batch file to be run at your time of choice.

Although this is cool and rewarding, you should still be pissed at Microsoft for not automating this simple, mundane job.

Cheers,
Matt.
www.theigloo.com






Comments

rextilleon wrote on 3/4/2004, 1:23 PM
Good idea Matt but I moved away from the Windows defragmenter because it is so damn slow, particularly on the larger HD's that we seem to be using today. I have a program called Diskeeper---It does everything (scheduling, background defragmentations etc) in about 1/4 of the time that it takes the Windows defragger.
Jsnkc wrote on 3/4/2004, 1:35 PM
Actually Diskeeper made the defragmenter that is in Windows XP, it's probably the same program.
theigloo wrote on 3/4/2004, 1:45 PM

I don't care how long it takes because I'm asleep when it occurs. There are a host of other defrag tools out there but none of them are as cheep as free.

I will agree that there must be better defraggers out there because the Windows defragger does not defrag disks, it only defrags files. In other words, when you are done with a defrag, often you see that all files are contiguous, but there are gaps between them. Next time you capture video, it fills in the gaps but is then obviously framented itself.

I'm going to give the norton defragger a try tonight - will post back with the results.

Matt
johnmeyer wrote on 3/4/2004, 2:52 PM
This all presupposes that defragmentation is necessary. See this recent thread:

Hard disk question
BillyBoy wrote on 3/4/2004, 3:24 PM
Defragmentation IS necessary because of how Windows writes files to the hard drive. Since Vegas only runs under Windows, defragmentation IS indeed necessary if you want a healthy, fast, problem free file system.
craftech wrote on 3/4/2004, 4:22 PM
Defrag Drive C only and fuggeddaboudit.

If you store clips and renderings on other drives just delete them when you are done otherwise you'll be defragging for endless unneccessary hours with no gain. Defragging is over hyped for drives other than your boot drive (which I assume you also keep your programs on.)

I have a 40 GB drive for Drive C and two 120 GB drives for drives D and E.
I only defrag drive C and have not had one "fragging" problem.

John
JackW wrote on 3/4/2004, 4:45 PM
John: having read (and contributed) to that thread, I dug a little further -- back to Microsoft this time. Here's what they say about defragmenting:

"The Defrag.exe command line utility locates and consolidates fragmented boot files, data files, and folders on local volumes.

When you are saving files, the file is not necessarily saved as an entire file or folder in a contiguous space. The files are saved in the first available space on a volume. After a large portion of the volume has been used for file and folder storage, most of the new files are saved in pieces across the volume. When you delete files or folders, the empty spaces left behind fill in randomly as you store new ones."

As I understand this, simply deleting files does not actually defragment the drive. That is, it doesn't consolidate empty spaces on the drive, it merely opens up "holes" that are then filled by the next data coming down the pipe, fragmenting the incoming file.

Defragmentation, on the other hand, consolidates all the pieces of fragmented files and, presumably, leaves large blocks of empty space on the disk, into which entire new files can be placed. Do you read this the same way?

Also, when you chided me about dropping "test results" into the last thread, you raised the question of real-world experiences. Here's one: I haven't defragmented the hard drive for some time, and capture an hour and forty five minutes of video into DVD Workshop. Every time I try to play the video in the Edit window it crashes -- locks up the program and cursor. I close DVEWS, delete the file and defragment the drive, open DVDWS, recapture the file. Plays perfectly, no problems.

I'm hard put not to attribute this behavior to fragmentation of the drive, since no amount of recapturing prior to defragmenting has any effect on the problem.

Also, when PTT from Vegas, I've occasionally had instances of pixelization. This problem has cleared up once the hard drive has been defragmented.

In both cases, my assumption has been that because the video files are broken up at capture -- i.e., fragmented -- the computer, a P4, can't keep up with the demand.

What do you think?

Jack

BillyBoy wrote on 3/4/2004, 5:14 PM
We've gone over this ground in several threads over the years. It boils down to this. When you first format a hard drive or later re-format it what in effect you're doing is setting up sectors or dividing the drive up. Not physically, but in how Windows "sees" the drive so it can read from it and write to it. Windows regardless of version writes files in blocks. The size of the sectors varies depending on which version of Windows you have and the size of your hard drive. All pretty basic so far.

Now the sticky part. Go to Windows Explorer, right click on some of your files. Select Properties. You'll see two entires. The size of the file in bytes and the size the file takes up on the hard drive. The difference is called slack. How much slack you have depends on how big your sectors are and how big the file. Try various sized files to see how much a difference there can be.

The statement you don't have to defrag is only true if you never add new files or delete or charge any. If that's you, stop reading. Of course that's nobody!

So what happens when you add, chage or delete files?

Windows will take the FIRST empty sector REGARDLESS where it is and put some or all of your file there. Repeat that hundreds, maybe thousands of times a day. Result: File fragmentation. Since video files are sizeable its possible your pet project you've been working on for weeks is stored in dozens and dozens of sectors all over your hard drive. Without special software its hopeless to find all the pieces. Only Windows knows where it put all the parts. When s.... happens and we all know s... does happen, some of the parts of file X can get cross-linked or corrupted or otherwise damaged. That means you probably can no longer open that file.

Even If that that don't happen the more fragemented your hard drive gets, the more broken up your files are meaning it takes longer and loger to open files and to a lessor extention save them. This also causes a lot of wear and tear on the hard drive because you're forcing the read/write heads to jump all over the place every time they do a read or write which is EVERY time you open or save a file.

Don't be fooled. Defragging your hard drive is normal, routine and just something you should get in the habit of doing.

In the almost 25 plus years I've used PC's, not once have I lost a hard drive or any data on it. I always defrag. What defragging does is put files back into continous sectors where possible. So if you have huge files that span many sectors once you defrag all the parts follow one another. Result less time to open the file, less chance your drive f.... up in moving the read/write heads all over the place.

How important is your data to you?

Of course the down side is you have to constantly defag because as you use your computer the files will quickly get fragemented again.

When should you defrag?

Don't let any drive get much beyond 5% fragemented. If you get in the habit of defragging routinely it doesn't take anywhere near as long if you wait till its some silly percentage like 80%.

That's my two cents anyway.

johnmeyer wrote on 3/4/2004, 5:48 PM
A few quick points:

1. Fragmentation will NOT cause your computer to crash. JackW, you must have had a corrupt file, and when you re-captured after your defrag, you ended up with a non-corrupt file. The REAL test would have been to defrag, without recapturing, and see if you computer still crashed. My bet is that it would have still crashed.

2. I agree with BillyBoy that deleting files does not cure defragmentation. In fact, as most of you know, that is part of what causes it. However, the reason why I don't think that defragmentation of the drive you use for video is necessary is that video files are HUGE, but there generally aren't many of them. I bet you have over 10,000 files on your main C: drive, but probably less than 10% of that number on your captur drive. As a result, the fragmentation problem -- if indeed it really is a problem -- is far less. For instance, if I have one file, the size of my hard disk, and I delete it, the disk is defragmented. As I get more files, I start to get fragmentation, but if the files are large, the portion of the drive freed up is so great, tha the fragmentation happens very slowly.

Also, remember that the disk head has to seek every single rotation, regardless of fragmentation. Unlike a CD or DVD (which record in a spiral) disks are recorded in concentric rings, so the head has to move to the next "ring" each revolution, whether the disk is fragmented or not. When the disk is heavily fragmented, the head just has to move further. In the old days, this could cause the disk to spin an extra revolution before the head was in position and ready to read. I don't know if this is still the case, but most drives have buffers to help smooth this out.

Finally, if you still really want to do defragmentation on your video drive, at least be smart: Do it after deleting a project, when your drive is about as empty as it is going to get. The defrag will go MUCH faster.
BillyBoy wrote on 3/4/2004, 8:07 PM
What you also need to keep in mind is what you use your computer for. Most people use them for many things, not just video editing. So if you have one or more PC's devoted to just video editing fragementation may not be that big a issue.

However if its general use, like this one I'm writing this message on where there 80,000 plus files, it matters a lot.
TheDingo wrote on 3/4/2004, 8:19 PM
Actually Diskeeper 8 is much more sophisticated than the built-in
Windows defragger. It's a lot faster, can be set to automatically
defrag any drive in the background when it detects that the
drive needs it, and best of all it can do "Boot Time Defragging"
so all of those normally "un-moveable" files can be defragger
BEFORE the Windows GUI boots up.

http://www.diskeeper.com/coverpage.asp

rextilleon wrote on 3/4/2004, 8:43 PM
Executive might have written the Windows defragger (not sure of that) but there is no way the two are comparable---A-B them and find out---I can defragment a 120 gig drive that is approximately 60% fragmented in approximately 30 minutes.