Defrag to improve Synology BTRFS performance

My Synology NAS gets a lot of use at home. Not only is the Synology NAS a central point for my VMware home lab, but all my PCs are connected to it for document, photo, and ISO storage.

In order to keep things as optimized as possible I try to defrag the drives every once in a while. Depending on how fragmented the drives are, this could help improve performance in sequential read and random IOPS.

In this post I’ll show how it easy it is to kick off the task. Just keep in mind you will want to do this during low usage as the defrag task will certainly impact performance while it’s running.

How to defrag Synology NAS using BTRFS

  1. Log into your Synology DSM.
  2. Open Storage Manager (found under the “Start Menu”) then click on Volume > Manage.
    synology defrag storage manager
  3. Next select Start file system defragmentation and click on Next.
    defrag synology volume wizard
  4. Now click on Apply.
    synology defrag confirm wizard

How to schedule the Synology defrag

If you would rather this be an automated process you can schedule the defrag instead.

  1. Log into your Synology DSM and go to Control Panel.
  2. Go to Task Scheduler and click on Create > Scheduled Task > User-defined script.
    synology defrag schedule task create
  3. Under the General tab give the task a name and keep the user set to root. Then under the Schedule tab configure when you want the defrag to run. On the Task Settings tab enter the following command:
    /sbin/btrfs filesystem defragment -r /volume1

    synology defrag schedule task command

Finally you’ll be taken back to the Storage Manager and will see a message stating that defrag has started. Depending on how fragmented your drives are this could take several minutes to a couple hours.

synology defrag

Post in the comments below if you’ve noticed any speed improvements as well after a defrag.

Similar Posts