Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MacNoobGuy

macrumors 6502
Original poster
Apr 18, 2012
497
0
hey guys, i've noticed OSX has been running slow recently even though i've got 8GB of RAM. can anyone tell me how i can defrag OSX so it's not so slow? what maintenance apps are there for me to use, preferably ones made by Apple?

thanks!
 

GGJstudios

macrumors Westmere
May 16, 2008
44,539
941
hey guys, i've noticed OSX has been running slow recently even though i've got 8GB of RAM. can anyone tell me how i can defrag OSX so it's not so slow? what maintenance apps are there for me to use, preferably ones made by Apple?

thanks!

With very few exceptions, you don't need to defrag on Mac OS X, except possibly when partitioning a drive.
About disk optimization with Mac OS X
You probably won't need to optimize at all if you use Mac OS X.

If you're having performance issues, this may help:
You don't need "cleaner" or "maintenance" apps to keep your Mac running well, and some of these apps can do more harm than good. Most only remove files/folders or unused languages or architectures, which does nothing more than free up some drive space, with the risk of deleting something important in the process. These apps will not make your Mac run faster or more efficiently, since having stuff stored on a drive does not impact performance, unless you're running out of drive space. In fact, deleting some caches can hurt performance, rather than help it, since more system resources are used and performance suffers while each cache is being rebuilt. Many of these tasks should only be done selectively to troubleshoot specific problems, not en masse as routine maintenance. OS X does a good job of taking care of itself, without the need for 3rd party software. Among other things, it has its own maintenance scripts that run silently in the background on a daily, weekly and monthly basis, without user intervention.
 

Gregg2

macrumors 604
May 22, 2008
7,170
1,161
Milwaukee, WI
AFAIK, Apple does not have a defrag program. I use TechTool Pro, on rare occasions, even though I know it's not necessary. But TTP does show that fragmentation does occur.
 

pmau

macrumors 68000
Nov 9, 2010
1,569
854
It's a great myth that you DON'T need defragmentation tools on the mac.

http://en.wikipedia.org/wiki/File_system_fragmentation#cite_note-osx-intern-11

"The HFS Plus file system transparently defragments files that are less than 20 MiB in size and are broken into 8 or more fragments, when the file is being opened."

HFS+ avoids fragmenting small files, but it has no idea how files are layed out on disk in relation to each other.

If you run iDefrag, for example, you can re-arrange files in a way that

/Applications
/System/Library
/Librray

appear in order on the physical disk.

That can greatly improve performance, because if you frequently update applcations, their contents are spread out acroess the disk.

Ofcourse with SSD the whole argument is not that relevant anymore.
But it's completly false that HFS+ actively optimizes its layout to improve performance.

Yes, I know it has a "hot files" cache that is mainly used to speedup booting.
It records all files accessed during boot and moves them to a special region on disk.

But this is far from any active reorganisation of filesystem structures.

The maintenance scripts mentioned are only used to cleanup logfiles and caches and can be examined by anyone who can read shell scripts.

They are based on normal BSD housekeeping scripts you find on all Unix based systems.
 

Fishrrman

macrumors Penryn
Feb 20, 2009
28,241
12,388
pmau, thanks for that post.

I've been a Mac user for many many years (since before many reading this were born).

Defragmenting an older drive is one of the most proactive things that a user can do to improve performance and restore speed. It is as necessary for OS X as it is for any other OS.

The original poster asked about defragging, "how is it done?"

There are two ways I know:

First way:
- you will need the defragging app AND an external boot source (for an external boot source, the BEST thing to have is a bootable "clone" of your internal drive created with either CarbonCopyCloner or SuperDuper)
- once you have the items above, boot from your external drive (you cannot defrag and optimize a drive while you are booted from it)
- now that you're booted up externally, launch your defrag app and "aim it" at the target drive (Important - do a "fresh cloned backup" of the target drive first)

Second way:
This is slower, and it may not "optimize" files as fully as will a standalone defrag app, but it's still workable.
- As above, you need an external "clone" of your internal drive
- Do a fresh clone as above, so that your backup is an up-to-date copy of the internal
- Now, boot from the backup
- Once up and running, use Disk Utility to ERASE your internal drive (yes, re-initialize it)
- Now, immediately "clone back" the contents of your external back to the internal

During the re-copying, files will be copied over contiguously. Whereas before the re-clone you had files scattered all over the sectors of the drive, with thousands of "open spaces" between them, after the re-clone you will have all your files "together" at the "head end" of the drive, with a large "open space" behind them.
 

benwiggy

macrumors 68020
Jun 15, 2012
2,371
179
Well, it's a great myth that defragmenting improves performance significantly, even if it does free up spaces and move stuff around. :D Also, if you have an older hard drive, defragging the whole thing, and/or erasing and restoring, may prove a major strain on the drive that can shorten its life.

As said, with SSDs now as standard, this whole argument is dying a death. The pros and cons have been discussed many time here before.

I suspect that whatever performance issues you may be experiencing, fragmentation isn't the major cause.

• Check the Console utility to see if any log messages provide a clue to any problems.
• Create a new user account and test the performance there. If things are better, then the cause is something in your original user account. Return there, and investigate caches, launching third-party software, and preference files.
 
Last edited:

Thraun

macrumors regular
Dec 18, 2008
159
41
Abbotsford, BC
OS X runs a lot of maintenance scripts, defragging, etc. when you do shut down and bootup processes. Really the only people that will notice issues like that is if you never shut down your computer. Just putting it to sleep will do none of that.

I use a program called Onyx (free download, Google it) that forces the computer to do cleaning and maintenance, but even with a 7-year-old iMac I never have to use it.
 

MacNoobGuy

macrumors 6502
Original poster
Apr 18, 2012
497
0
OS X runs a lot of maintenance scripts, defragging, etc. when you do shut down and bootup processes. Really the only people that will notice issues like that is if you never shut down your computer. Just putting it to sleep will do none of that.

does anyone know if this is true or not?
 

Dalton63841

macrumors 65816
Nov 27, 2010
1,449
8
SEMO, USA
does anyone know if this is true or not?

Yes it is true, but not just shutdown and bootup. If you use Onyx, you will notice that it labels scripts as "daily", "weekly", and "monthly". Those are not Onyx scripts. They are BUILT IN scripts scheduled to run by the OS itself. Onyx just allows them to be run on-demand.

EDIT: btw anyone claiming that Mac needs to be defragged doesn't understand the concept behind a journaled filesystem.
 
Last edited:

GGJstudios

macrumors Westmere
May 16, 2008
44,539
941
OS X runs a lot of maintenance scripts, defragging, etc. when you do shut down and bootup processes. Really the only people that will notice issues like that is if you never shut down your computer. Just putting it to sleep will do none of that.
Actually, you have it backwards. OS X has daily, weekly and monthly maintenance scripts that are scheduled to run in early morning hours. If your Mac is always shut down during those times, the scripts will never run. If your Mac is asleep during those times, the scripts will automatically run when your Mac is awake. The scripts are not triggered by shut down, boot up or restarts.
EDIT: btw anyone claiming that Mac needs to be defragged doesn't understand the concept behind a journaled filesystem.
That is false. Most Mac users never need to defrag. A few may need to when partitioning drives, or in some other isolated cases, but the average Mac user never needs to defrag, as clearly stated by Apple.
 

inscrewtable

macrumors 68000
Oct 9, 2010
1,656
402
hey guys, i've noticed OSX has been running slow recently even though i've got 8GB of RAM. can anyone tell me how i can defrag OSX so it's not so slow? what maintenance apps are there for me to use, preferably ones made by Apple?

thanks!

From my experience defragging mac os x is unnecessary, however a good little used way to defrag is to use superduper to make a bootable clone of your mac (which is a good idea anyway) then you can clone your bootable clone back to your HDD. In the process of copying it back it will also be defragged.

This is free to do because you only need to pay for SD if you want to switch on the smart update feature which you do not need to do in the case of defragmenting.
 

GGJstudios

macrumors Westmere
May 16, 2008
44,539
941
From my experience defragging mac os x is unnecessary, however a good little used way to defrag is to use superduper to make a bootable clone of your mac (which is a good idea anyway) then you can clone your bootable clone back to your HDD. In the process of copying it back it will also be defragged.

This is free to do because you only need to pay for SD if you want to switch on the smart update feature which you do not need to do in the case of defragmenting.

You can do the same thing with CCC, which also clones the OS X Recovery Partition, which SD won't.
 

inodes

macrumors newbie
Jan 31, 2011
17
0
It's true that fragmentation occurs in OS X as it does in Windows, and therefore it's very easy to conclude that fragmentation must occur under both operating systems.

But the way both files are written negates the need to do it as often.

During the course of my career I've worked as both a Windows and Unix system Admin, covering all versions of Windows and Unixes such as Ultrix, BSD, Solaris, HP-UX, Linux and of course at home - OS X.

Boiling it down, Windows with NTFS or FAT has one major issue. It writes to the disk practically at the first place the head can write (in an effort to keep writes together) and has a terrible method for block allocation, not seeking out spaces of disk where the file can be written out in whole. It effectively "fills the gaps" between files, which is caused by and causes additional fragmentation.
When looking at it using a defrag program, it often looks neat and bunched up. And it's why even a month after a defrag, files appear to be still bunched up close to the spindle.

A month of solid use on a Windows system will show a measurable percentage of fragmentation, particular more so the larger the files are.

Fairly obvious even for the non technical. Rather than write as close to the last write as possible, even a random writing method would be better as it would cause much larger spaces to occur across the disk, and therefore much more chance of a space large enough to write a file.

NTFS is slightly smarter than FAT in that on write, it will attempt to find a space which is a good fit for the file, but this isn't very good for files which are growing at the time of write.

Bottom line is that Windows is quick to write to disk, but not terrible concerned with being proactive with allocation (FAT), or terrible at it in practice (NTFS). Fragmentation was never really a concern of these filesystems.

To be blunt - but honest, even the Commodore Amiga had a better method for writing out files back in the late 80's.

Most of the Unix filesystems (ZFS, UFS, ext4) have two major tricks up their sleeve. Firstly the writes are often proactively located in large spaces (i.e. not written close to last write), which in turn caused less fragmentation (because often the whole file can sit within the gap, or possibly only fragments into two chunks). Secondly, they often have delayed allocation which allows all the pending writes to be combined and written out together, rather than patch work them wherever there is space (like NTFS/FAT) - (there will usually be a Sync system call which will flush writes out to disk to commit them to the disk).
This is ideal for things such a long text logs or large chunks of data which are being created *now* but not yet needed immediately to disk.

It's fairly easy in practice to see the Unix style OS's beside the Windows FAT/NTFS and shake your head. Even in a month with less activity, the Windows filesystems will become far more fragmented than some of my even more thoroughly used Unix systems will be in a couple of years.

Back home on my desktop, I've never seen my OS X be more than about 1% fragmented. And even then, never seriously.

Fragmenting in OS X (and any Unix for that matter), is nowhere near as necessary as in Windows - where it's practically compulsory.
 
Last edited:

Fishrrman

macrumors Penryn
Feb 20, 2009
28,241
12,388
"ost Mac users never need to defrag."

My speculation only:
One of the reasons Apple tells folks they don't need to defrag, is because they expect their customer base to continually "migrate upwards" hardware-wise, discarding older computers as they become sluggish, but more importantly, "outdated by software" as Apple leaves its 3-4-year-old OS's behind.

It's as much as "sales pitch" (for future sales, that is) as it is anything else.

One other thought about fragmentation.
Fragmentation, per se, is not just about files, but also about the "free space" _between_ the files.

Examine ANY Mac volume with an OS on it, that has been in use for a while using an app that can reveal such things -- and you'll be startled by how much "free space fragmentation" there is, along with fragmented files.

I'm sure those who say "Mac drives don't need defragging" have seen as much -- but won't comment on it...
 

GGJstudios

macrumors Westmere
May 16, 2008
44,539
941
"ost Mac users never need to defrag."

My speculation only:
One of the reasons Apple tells folks they don't need to defrag, is because they expect their customer base to continually "migrate upwards" hardware-wise, discarding older computers as they become sluggish, but more importantly, "outdated by software" as Apple leaves its 3-4-year-old OS's behind.

It's as much as "sales pitch" (for future sales, that is) as it is anything else.

One other thought about fragmentation.
Fragmentation, per se, is not just about files, but also about the "free space" _between_ the files.

Examine ANY Mac volume with an OS on it, that has been in use for a while using an app that can reveal such things -- and you'll be startled by how much "free space fragmentation" there is, along with fragmented files.

I'm sure those who say "Mac drives don't need defragging" have seen as much -- but won't comment on it...
I've been using the same MacBook Pro for over five years. I use it extensively for everything from web surfing, email, playing multimedia, ripping and encoding, remote desktop applications, etc. I have never defragged the drive, never done a clean reinstall, never had to restore from a backup, never used third-party apps for "maintenance" or "cleaning", other than using Monolingual a couple times to remove some languages. I'm typically on the computer 12 to 16 hours a day, every day. More than many users, I would certainly recognize it if there was some degradation in performance. My MBP still performs as well as it did when I took it out of the box for the first time. In addition to that, I have provided support for countless numbers of Mac users over the years, who have experienced the same thing with their Macs.

Some people insist on fiddling with their Macs, rather than using them for what they were intended for. If someone wants to do that, that's perfectly fine. But to suggest that most or all that users should do the same is misleading. The vast majority of performance issues reported in this forum and elsewhere have nothing to do with fragmentation of the drive. Far more frequently it has to do with a single process or app that is causing problems.
 

nightlong

macrumors 6502a
Jun 16, 2012
851
164
Australia
What about repairing permissions. I was told long ago to do that now and then, and always before and after doing updates related to the OS or that require restarts.

It seems, from the script reporting the process that it is repairing things, but with different systems I have noticed this:

With Tiger, when permissions were repaired, they didn't appear next time.

With Snow Leopard, there was always a huge list, and despite it saying things were repaired, they appeared next time. I phoned Apple support once about this and sent them a screenshot. They said don't worry about it.

With ML, the list doesn't repeat.

So ... What do you think about doing this?
 

GGJstudios

macrumors Westmere
May 16, 2008
44,539
941
What about repairing permissions.

Some people repair, or recommend repairing permissions for situations where it isn't appropriate. Repairing permissions only addresses very specific issues. It is not a "cure all" or a general performance enhancer, and doesn't need to be done on a regular basis. It also doesn't address permissions problems with your files or 3rd party apps.
Disk Utility repairs the permissions for files installed by the Mac OS X Installer, Software Update, or an Apple software installer. It doesn’t repair permissions for your documents, your home folder, and third-party applications. You can verify or repair permissions only on a disk with Mac OS X installed.
Does Disk Utility check permissions on all files? Files that aren't installed as part of an Apple-originated installer package are not listed in a receipt and therefore are not checked. For example, if you install an application using a non-Apple installer application, or by copying it from a disk image, network volume, or other disk instead of installing it via Installer, a receipt file isn't created. This is expected. Some applications are designed to be installed in one of those ways. Also, certain files whose permissions can be changed during normal usage without affecting their function are intentionally not checked.
If repairing permissions results in error messages, some of these messages can be ignored and should be no cause for concern.
 

throAU

macrumors G3
Feb 13, 2012
8,772
6,935
Perth, Western Australia
If you have very little free disk space, your drive WILL become fragmented, and there's not a lot the OS can do about it, whether it is Windows, OS X, Linux or whatever.

OS X has measures to avoid fragmentation as much as possible, but there's only so much it can do to avoid it.

Ensure you have 10-20% free disk space (as a very rough rule of thumb), otherwise there's simply not enough space available for whatever disk-fragmentation avoidance algorithm the OS is using to work. Essentially, any disk fragmentation avoidance algorithm needs chunks of free space to fit files into. If there's very little space, the chances of finding a big enough chunk go down a lot - and if there is no big enough chunk available, guess what? The file is written in a number of fragments, into whatever smaller chunks are available.

The problem gets worse if you are a user who continually creates and deletes files - and even worse if your files are small. Deleting a small file opens up a small chunk of free space. Absolute worst case example: you have a disk that is 100% full and delete 1,000 4k files that are scattered over the disk. This opens up 1000 4k chunks of space. If you then write a 200k file, it will end up in 50 fragments, all over the disk, because the OS has nowhere else to put it.

Instead, if you had say, 10 GB free, there's a good chance it could be slotted into a 200k (or larger) free chunk, and remain in a single fragment. What could (and should) have been a single read or write operation (i.e., one disk seek) is turned into 50 operations (50 seeks, or having to move the read/write head 50 times!). This kills performance, badly.

If you have a decent amount of free space the OS will attempt to move files around and re-organise them as they are opened and closed - but it NEEDS free space to juggle the files around for this to work.

Also, the way mechanical disks work, they are faster at the start of the disk and as you near the end (start filling the disk up) the read/write rate degrades. This is due to the later tracks (near the end of the disk) being smaller circumference and the speed of tracks passing by the read/write head is lower.



edit:
also +1 to inodes' post above. there's a fair bit of science behind it, and if you have a basic understanding of it you can get an idea of how, why and when fragmentation will happen, and how to avoid it.
 
Last edited:

MacNoobGuy

macrumors 6502
Original poster
Apr 18, 2012
497
0
ok this thread has confused me even more. some people are saying it's good to leave the mac running 24/7 and then some are saying it's good to turn it off during the night.

would i get better performance if i rebooted my Mac more often? i only reboot once every 3 weeks or so and it runs 24/7.

what's the definitive answer???
 

benwiggy

macrumors 68020
Jun 15, 2012
2,371
179
ok this thread has confused me even more. some people are saying it's good to leave the mac running 24/7 and then some are saying it's good to turn it off during the night.
would i get better performance if i rebooted my Mac more often? i only reboot once every 3 weeks or so and it runs 24/7.
what's the definitive answer???
Your Mac has three maintenance routines, which are scheduled to be performed at about 3 in the morning on a daily, weekly and monthly basis.
If your machine is not on at 3 in the morning, the tasks will be performed at the next available opportunity.

You can check whether these routines are being run or not with a utility like Onyx, which shows you the last time they were run.

In short: turn it off; leave it on: it doesn't really matter. Your Mac will certainly benefit from a reboot every now and then.
 

Fishrrman

macrumors Penryn
Feb 20, 2009
28,241
12,388
My recommendation is that you shut the computer down at night.

No, the "chron jobs" (routine maintenance scripts) won't run if the Mac is shut down.

But you want to download and run OnyX (free) periodically in any case, and it will take care of the chron jobs for you.

I not only shut down my Macs when I'm not using them, they're all connected to surge suppressors and I power off the strips, as well.
 

GGJstudios

macrumors Westmere
May 16, 2008
44,539
941
Your Mac has three maintenance routines, which are scheduled to be performed at about 3 in the morning on a daily, weekly and monthly basis.
If your machine is not on at 3 in the morning, the tasks will be performed at the next available opportunity.
Actually, that's only true if the computer is asleep at the scheduled times (3:15AM and 5:30AM). It will run the scripts when the computer is awakened. However, if the computer is shut down at the scheduled time, the scripts will not run.

Alternatively, you can use this widget to manually launch the scripts whenever you choose.
ok this thread has confused me even more. some people are saying it's good to leave the mac running 24/7 and then some are saying it's good to turn it off during the night.

would i get better performance if i rebooted my Mac more often? i only reboot once every 3 weeks or so and it runs 24/7.

what's the definitive answer???
There is no definitive answer, because it's largely a matter of personal preference. Nothing terrible will happen, either way.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.