Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Defragging an APFS hard disk.

I have an external Hard Disk (NOT AN SSD). I have it formatted in APFS. How do I defrag the drive or know if the drive is de-fragmented or not?

MacBook Pro 13”, macOS 10.14

Posted on Jun 6, 2019 7:56 AM

Reply
Question marked as Best reply

Posted on Jun 6, 2019 8:20 AM

Okay, I messed around with diskutil's manual and got it done with the following command.


diskutil APFS defragment /dev/<yourdiskloaction> status


If it says disabled, enter the following command to enable it.


diskutil APFS defragment /dev/<yourdisklocation> enable

Similar questions

8 replies

Jun 6, 2019 8:14 AM in response to BobTheFisherman

I am a long linux based user, so I am good with DIY and usual experiments. To be honest, I would like a LITTLE bit more control on how macOS manages MY FILES. Nothing else. Cause my old hard disk slowed down immensely because it was not defragmented. I do not want the same thing to happen again.


Plus, I am a terminal (both, UNIX and Linux) power user. I just can't get my head over how to achieve this.

Jun 6, 2019 8:24 AM in response to Pratham Patel

Unix ex2,3,&4 formats leave space between the files, it's a preemptive alternative to defragmentation, if your disk is hitting ~90% capacity you might expect some fragmentation. I'm not entirely sure but HFS+ and AFPS avoid defragmentation all together. On a Mac formatted rotational drive it's unnecessary wear and tear, on an SSD it can cause damage and decrease the lifetime of the device.


If you have to defrag something then format NTFS and run windows and defrag away. On macOS you are opening a can of worms.

Defragging an APFS hard disk.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.