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
- Log into your Synology DSM.
- Open Storage Manager (found under the “Start Menu”) then click on Volume > Manage.
- Next select Start file system defragmentation and click on Next.
- Now click on Apply.
How to schedule the Synology defrag
If you would rather this be an automated process you can schedule the defrag instead.
- Log into your Synology DSM and go to Control Panel.
- Go to Task Scheduler and click on Create > Scheduled Task > User-defined script.
- 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
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.
Post in the comments below if you’ve noticed any speed improvements as well after a defrag.