sudo periodic -daily -weekly -monthly
RacerX said:As for defragging your drive... I'll give my standard warning: Defragging a Mac is the single worse thing you can do. There are very few circumstances where it helps and tons more where it can hurt. Defrag Utilities will defrag a volume at the expense of fragmenting files (which is far far worse than any volume fragmentation). What looks pretty to human eyes can be really screwed up from your system's point of view.
While Apple does not provide a defragmentation tool, they introduced a few HFS+ optimizations in "Panther", two of which play important roles in countering (even undoing) the fragmentation of files that are below a certain size, and are frequently accessed.
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.
Hot File Clustering
This optimization is currently available only on boot volumes. Hot File Clustering is a multi-staged clustering scheme that records "hot" files (except journal files, and ideally quota files) on a volume, and moves them to the "hot space" on the volume (0.5% of the total filesystem size located at the end of the default metadata zone, which itself is at the start of the volume). The files are also defragmented. The various stages in this scheme are DISABLED, IDLE, BUSY, RECORDING, EVALUATION, EVICTION, and ADOPTION. At most 5000 files, and only files less than 10 MB in size are "adopted" under this scheme.
...
...
Defragmentation on HFS+ volumes should not be necessary at all, or worthwhile, in most cases, because the system seems to do a very good job of avoiding/countering fragmentation.
It is risky to defragment anyway: What if there's a power glitch? What if the system crashes? What if the defragmenting tool has a bug? What if you inadvertently reboot? In some cases, you could make the situation worse by defragmenting.
Giaguara said:In terminal
It prompts for your password, and then it will do some of the builtin cleaning scripts and that does essentially guiless what MacJanitor does (a nice freeware app you will like for speeding up and cleaning the system).Code:sudo periodic -daily -weekly -monthly
Ahem... yes it does.elander said:Ahem. No. Defragging does not lead to fragmentation of files, exactly the opposite is true.
Not really, although it might seem as if they did in some cases (more below this paragraph). Defragmentation tools do two things: defragment all files, and move them so that all free space is contiguous. The very process of moving them to "get all blocks to line up nicely" is precisely what creates defragmented files.RacerX said:Ahem... yes it does.
Defrag utilities are known to break up large files to get all the blocks to line up nicely while getting rid of volume fragmentation.
Sorry.
We are talking about HFS+ volume formatting... which is not your everyday hard drive.elander said:Although a physical inspection of the platters in the drive would indeed show that the files had become fragmented, they would actually be read faster than if they weren't. In fact, just about every hard drive today does this automatically. The logic needed is built-in to the controller.
RacerX said:We are talking about HFS+ volume formatting... which is not your everyday hard drive.
Partly true, anything beyond eight extents goes to the extents overflow file. Anyhow, still no explanation as to why defragmentation tools would introduce fragmentation.When you introduce physical fragmentation to files, their entries within the volume catalog grow. The HFS+ specification will only allow those entries to grow to a certain point before moving the rest of the physical addresses to an overflow area.
Pulling ranks?You obviously don't service Macs for a living... that is all I do.
Yep. That really sucks. Happens a lot when things go wrong with defragmentation tools, one of the reasons I never use them.When the catalog becomes corrupt or the entries for the physical addresses stop matching with the actual physical position of the file elements on a disk... lets just say you're in for a REALLY bad day.
Almost in total agreement with my own observations. A good reason to stear clear of defragmentation software. I've seen drives fail for other reasons too, though. Especially Macs in the late eighties and early nineties kept messing up the extents records, when HFS+ came ('97/'98?) a lot of those problems vanished. And don't get me started on DOS/Windows...I have serviced hundreds of Macs and the only ones which have run into these issues fell under two criteria:
- Disks that were more than 95% full (I urge all my clients to never exceed 85% capacity)
- Disks of people who use defragmentation software (regardless of how full the volume was)
It is nice that you do all this reading on all these other sites, but Apple has always had excellent documentation on this stuff (which I believe has been open for public viewing for most of the last 10 years... although part of that time I was part of Apple's development community and I don't know if I had more access than Apple gives the public today).
So why not go to the source?
I don't mind going around on this again if you want , but nothing is going to change the fact that file fragmentation (physical fragmentation of files on a volume) put stress on the volume resources and in extended cases can lead to data loss.
For those of you wondering about some of the more interesting types of problems that can come from this type of stuff, I had one client who's directory structure... exploded. Most of his files ended up on the root level of his hard drive.
Let the system take care of it's self and make sure it has the room to do this. It is the best recommendation I can make for caring for Mac volumes.