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.
- File system defragmentation is available on specific models only.
- File system defragmentation can only be performed on volumes in Btrfs file system.
- File system defragmentation can only be performed when the status of the volume is Normal.
- Please do not shut down the system before file system defragmentation is complete. If the system is shut down before completion, file system defragmentation must restart from the beginning.
- Volume usage might increase if the volume contains snapshots of shared folders.
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.