macnerd48

Q: defragging Apple hard drive

Today I helped a friend defrag his Windows 10 laptop. While I waited & waited & waited for the drive to defrag, I wondered why Apple drives don't have a defrag option. Or do they? Do they?

Mac mini, OS X El Capitan (10.11.6)

Posted on Sep 15, 2016 10:45 AM

Close

Q: defragging Apple hard drive

  • All replies
  • Helpful answers

  • by Niel,

    Niel Niel Sep 15, 2016 10:46 AM in response to macnerd48
    Level 10 (312,590 points)
    Mac OS X
    Sep 15, 2016 10:46 AM in response to macnerd48

    That's handled by the OS automatically.

     

    (144648)

  • by Kurt Lang,

    Kurt Lang Kurt Lang Sep 15, 2016 11:00 AM in response to macnerd48
    Level 8 (37,815 points)
    Mac OS X
    Sep 15, 2016 11:00 AM in response to macnerd48

    I haven't defragged a drive in years. As Niel noted, it isn't necessary. And if you have an SSD, you don't do it at all - ever. It doesn't matter how fragmented a file may be on an SSD. Since it's a form of RAM, there's no head that has to move around to retrieve the bits and pieces as a hard drive needs to do. A heavily fragmented file on an SSD will read just as fast as it would if it were contiguous. Not to mention the extra, unnecessary wear you'd put on an SSD by trying to defragment it. The only thing you'd succeed in is shortening the life of the drive.

  • by macnerd48,

    macnerd48 macnerd48 Sep 15, 2016 12:21 PM in response to Kurt Lang
    Level 1 (6 points)
    Mac OS X
    Sep 15, 2016 12:21 PM in response to Kurt Lang

    I have a MacBookPro & a mini both with traditional hard drive. When a new version of OS X comes out, I nuke the hard drive to get rid of all of the junk files & do a clean install of OS X. When either one gives up the ghost, I want to replace it with a computer with a SSD. A SSD has a limited number of read/write cycles. So, how do I get rid of junk files on a SSD so I can do a clean install of OS X? Is that what TRIM is for?

  • by Kurt Lang,

    Kurt Lang Kurt Lang Sep 15, 2016 12:28 PM in response to macnerd48
    Level 8 (37,815 points)
    Mac OS X
    Sep 15, 2016 12:28 PM in response to macnerd48
    So, how do I get rid of junk files on a SSD so I can do a clean install of OS X?

    As with a hard drive, you don't. A simple erase clears the file table. With no reference for the OS to locate any of the files that are technically still on the drive, for all intents and purposes, they don't exist and will eventually be overwritten.

     

    If your thinking of a secure erase on an SSD, you don't do that, either. SSDs are drastically different. Member BobHarris made an excellent post on the subject in this topic.

  • by John Galt,Apple recommended

    John Galt John Galt Sep 15, 2016 12:38 PM in response to macnerd48
    Level 8 (49,039 points)
    Mac OS X
    Sep 15, 2016 12:38 PM in response to macnerd48

    I wondered why Apple drives don't have a defrag option.

     

    Please read About disk optimization with Mac OS X - Apple Support.

  • by macnerd48,

    macnerd48 macnerd48 Sep 16, 2016 7:10 AM in response to Kurt Lang
    Level 1 (6 points)
    Mac OS X
    Sep 16, 2016 7:10 AM in response to Kurt Lang

    Is that what the disk utility does? Before I install a new version of OS X, I use disk utility to erase the hard drive. It doesn't take very long to do so I suppose all that erase does is delete the file table. Is that correct?

     

    So, when the times comes to replace my mini or laptop, I want an SSD. I know that SSDs have a limited number of read/write cycles. Does erasing the SSD "wear it out" faster?

  • by Kurt Lang,

    Kurt Lang Kurt Lang Sep 16, 2016 7:23 AM in response to macnerd48
    Level 8 (37,815 points)
    Mac OS X
    Sep 16, 2016 7:23 AM in response to macnerd48
    It doesn't take very long to do so I suppose all that erase does is delete the file table. Is that correct?

    Yes, it just wipes out the current file table. From that point, the OS sees the drive as empty since there are no entries of live data to read.

    Does erasing the SSD "wear it out" faster?

    No faster than deleting a few files. The current file table goes to the garbage collection and a new table is created. If you read through BobHarris' post I linked to, you'll also see that all newer SSD drives (like from at least the past two or three years) use wear leveling so data isn't always written to the same empty areas of the drive. It's spread around so the cells across the entire drive are written to at about all the same rate.