Become a MacRumors Supporter for $25/year with no ads, private forums, and more!

Defrag?

mkrishnan

Moderator emeritus
Jan 9, 2004
29,776
12
Grand Rapids, MI, USA
Suppose you have fifty megabytes of files -- say an album you rip. You rip the album and these fifty megabytes of data get loaded in a block on the hard drive, say. Then you delete song six because you hate it. Now you have a fifty megabyte block with a 4 meg hole in the middle, right? The next time you make a new file, if it's bigger than four megabytes, the system puts it after the fifty meg block. But if it's smaller, it shoves it in that hole. Because if it didn't, then you would run out of space very quickly because you were not re-using space from deleted files (and your system is constantly making and deleting files so you wouldn't practically even get to fill the drive once).

The problem with this is that each time there's a new file, the filesystem goes pecking through the space on the disk looking for a good place to put it. Which is time consuming.

In older file systems, you manually defragmented the hard drive -- that is, you ran a program that went and looked for all the fragments of space and the small files and tried to packs all the files down so that all the free space is at the end in one giant block, so that this search is not necessary and disk access is faster.

In more modern file systems like HFS, this is done on the fly for most files. You can read about this here. So for most users, going and running a defrag program won't help much. But if you want, why not? Knock yourself out. ;)
 
Comment

BrianSalts

macrumors regular
Feb 25, 2006
185
0
if i'm not incorrect, doesnt os x defrag your HD on the fly for you?

therefore, i dont think you need to worry about anything :D
 
Comment

ghall

macrumors 68040
Original poster
Jun 27, 2006
3,771
1
Rhode Island
BrianSalts said:
if i'm not incorrect, doesnt os x defrag your HD on the fly for you?

therefore, i dont think you need to worry about anything :D
I don't think so, because I scaned my HD and it had some major defragmentation, and I mean MAJOR!
 
Comment

dpaanlka

macrumors 601
Nov 16, 2004
4,868
6
Illinois
ghall said:
I don't think so, because I scaned my HD and it had some major defragmentation, and I mean MAJOR!

Wouldn't that mean your hard drive was majorly not fragmented, and thus in need of no defragging?
 
Comment

ddekker

macrumors regular
Sep 23, 2006
222
0
Michigan
defrag

just what did you scan you drive with to see it fragmented? Apples journaled file system takes care of it self, the only disk tool you have is "repair permissions" as far as I know

DD
 
Comment

pianoman

macrumors 68000
May 31, 2006
1,962
0
Apple takes care of defragging small files but if you constantly work with things like movie files or even large pictures or large music files you probably should do a defrag.

i don't know the exact file sizes, but a google search should reveal the specifics. defragging, contrary to many OSX users' belief, is not always unnecessary.
 
Comment

Counterfit

macrumors G3
Aug 20, 2003
8,201
0
sitting on your shoulder
pianoman said:
Apple takes care of defragging small files but if you constantly work with things like movie files or even large pictures or large music files you probably should do a defrag.

i don't know the exact file sizes, but a google search should reveal the specifics. defragging, contrary to many OSX users' belief, is not always unnecessary.
The OS automatically defrags commonly used files under 25MB or so (last time I checked anyway).
 
Comment

mad jew

Moderator emeritus
Apr 3, 2004
32,191
5
Adelaide, Australia
No and yes. It needs less defragmenting because of the way HFS allocates space, but it still defrags on the fly.

Third party defrag apps may give the impression that a drive is more fragmented than it actually is because the developers want you to use (and possibly buy) their app. I'm not saying this as a rule, just something to be wary of. :)
 
Comment

Schroedinger

macrumors regular
Feb 12, 2004
241
0
Baltimore, MD
Here's the thing with defragging under OS X, a small group needs to do it and they really need to do it. For example, I have a friend who downloads Hi Def torrents. Torrents are by nature highly fragmented. When watching one of these HD fragmented files, there are lags and delays that disappear once the file is defragmented and all in one place.

I agree however that most users need not worry about it.
 
Comment

mkrishnan

Moderator emeritus
Jan 9, 2004
29,776
12
Grand Rapids, MI, USA
Schroedinger said:
For example, I have a friend who downloads Hi Def torrents. Torrents are by nature highly fragmented.

This is really interesting. I thought that when files are downloaded in general, the data was put in a temp download file until you got the whole file, and then it was re-written into a new file in order to avoid this issue. Like how Safari makes a .download file until a file is completed. So this is not quite right? Are large download files in general susceptible to fragmentation? Or is this specific to Torrent?
 
Comment

disconap

macrumors 68000
Oct 29, 2005
1,800
2
Portland, OR
mkrishnan said:
This is really interesting. I thought that when files are downloaded in general, the data was put in a temp download file until you got the whole file, and then it was re-written into a new file in order to avoid this issue. Like how Safari makes a .download file until a file is completed. So this is not quite right? Are large download files in general susceptible to fragmentation? Or is this specific to Torrent?


Torents are fragmented by nature; you are downloading bits and pieces. When you initially run the torrent (in, say, Azereus), there is a file set aside at the total size in the saved folder, so to the OS, the file is there (and usually identified as complete until you try to run it). The problem is that occasionally you get bad blocks that have to be corrected, cached duplicates, etc. It is rare that a torrent download is the same size as the specified size (in files over 100mb, at any rate). So the allocated space runs over and the bits of file are placed elsewhere.

The part that I don't buy is that OSX needs to defragment files; the way Unix filesystems work is from the tree, not the space, so there is no searching, just a list of places the heads need to go to get the bits of files. I can see, when working with HD files, it just being too much for the drive, but in general defragging is unnecessary (and as was stated before, there is some minor auto-defragging that is part of the OS; this is why most people tell you to shut down your comp the minute you accidentally delete something, as the defragger and the RAM swapping can lead to it being overwritten very, very quickly).
 
Comment

funkychunkz

macrumors 6502a
Jun 1, 2005
501
0
Ottawa, Canada
From http://www.kernelthread.com/mac/apme/fragmentation/

" On-the-fly Defragmentation

When a file is opened on an HFS+ volume, the following conditions are tested:
If the file is less than 20 MB in size
If the file is not already busy
If the file is not read-only
If the file has more than eight extents
If the system has been up for at least three minutes

If all of the above conditions are satisfied, the file is relocated -- it is defragmented on-the-fly. "

This is a great article from a guy who really knows what he's about. If you really want to defrag a mac (defragging involves some risk), I wouldn't personally use idefrag because it's been buggy in the past and uses proprietary algorithms. Drive Genius does a good job, but of all tools Disk Warrior, which rebuilds the catalogue file is speedy and makes a noticable difference.
 
Comment

apfhex

macrumors 68030
Aug 8, 2006
2,670
4
Northern California
pianoman said:
defragging, contrary to many OSX users' belief, is not always unnecessary.
Not always, but I don't think most users need bother with it.

disconap said:
The part that I don't buy is that OSX needs to defragment files; the way Unix filesystems work is from the tree, not the space, so there is no searching, just a list of places the heads need to go to get the bits of files. I can see, when working with HD files, it just being too much for the drive, but in general defragging is unnecessary (and as was stated before, there is some minor auto-defragging that is part of the OS; this is why most people tell you to shut down your comp the minute you accidentally delete something, as the defragger and the RAM swapping can lead to it being overwritten very, very quickly).
 
Comment
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.