{"id":27078,"date":"2019-10-28T16:54:54","date_gmt":"2019-10-28T20:54:54","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=27078"},"modified":"2023-08-31T09:24:32","modified_gmt":"2023-08-31T13:24:32","slug":"enabling-defragmentation-on-apfs-hard-drives","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2019\/10\/28\/enabling-defragmentation-on-apfs-hard-drives\/","title":{"rendered":"Enabling Defragmentation on APFS Hard Drives"},"content":{"rendered":"<p><a href=\"https:\/\/eclecticlight.co\/2019\/10\/19\/should-you-enable-defragmentation-on-apfs-hard-drives\/\">Howard Oakley<\/a>:<\/p>\n<blockquote cite=\"https:\/\/eclecticlight.co\/2019\/10\/19\/should-you-enable-defragmentation-on-apfs-hard-drives\/\">\n<p>You can try this yourself, although the documentation of defragmentation is minimal. The <code>diskutil apfs<\/code> command allows you to enable and disable defragmentation at Container or Volume level, with a command such as\n<code>diskutil apfs defragment volumeDevice enable<\/code>\nenabling it on the specified volume. But I wouldn&rsquo;t expect it to have any significant impact on the poor performance that you&rsquo;re experiencing on APFS-formatted hard drives. I hate to say it, but if you possibly can, it would make good sense to keep those in HFS+ format until you replace them with SSDs.<\/p>\n<\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2019\/09\/19\/apfs-enumeration-performance-on-rotational-hard-drives\/\">APFS Enumeration Performance on Rotational Hard Drives<\/a><\/li>\n<\/ul>\n\n<p id=\"enabling-defragmentation-on-apfs-hard-drives-update-2023-08-31\">Update (2023-08-31): <a href=\"https:\/\/mastodon.social\/@felix_schwarz\/110977873028887144\">Felix Schwarz<\/a>:<\/p>\n<blockquote cite=\"https:\/\/mastodon.social\/@felix_schwarz\/110977873028887144\"><p>Three days ago, I noticed an external HDD&rsquo;s write performance had deteriorated to about 2-5 MB\/s, making me wonder if it was about to fail - or if it is an APFS performance issue.<\/p><p>I subsequently learned about APFS defragmentation and enabled it for the HDD&rsquo;s APFS container via<\/p><pre>diskutil apfs defragment [disk] enable<\/pre><p>Coming back to the disk two days later, write performance is back to normal.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Howard Oakley: You can try this yourself, although the documentation of defragmentation is minimal. The diskutil apfs command allows you to enable and disable defragmentation at Container or Volume level, with a command such as diskutil apfs defragment volumeDevice enable enabling it on the specified volume. But I wouldn&rsquo;t expect it to have any significant [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2019-10-28T20:54:59Z","apple_news_api_id":"4511d750-e736-4911-a7b6-4377e71bd908","apple_news_api_modified_at":"2023-08-31T13:24:35Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAQ==","apple_news_api_share_url":"https:\/\/apple.news\/ARRHXUOc2SRGntkN35xvZCA","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[2],"tags":[1395,30,1666,174],"class_list":["post-27078","post","type-post","status-publish","format-standard","hentry","category-technology","tag-apple-file-system-apfs","tag-mac","tag-macos-10-15","tag-storage"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/27078","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=27078"}],"version-history":[{"count":3,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/27078\/revisions"}],"predecessor-version":[{"id":40499,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/27078\/revisions\/40499"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=27078"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=27078"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=27078"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}