Synology: Speed up Your NAS by Defragging Your Hard Drives

Synology Speed up Your NAS by Defragging Your Hard Drives

Defragmentation, also known as “defrag” or “defragging”, is the process of reorganizing the data stored on your Synology NAS hard drive so that related pieces of data are put back together, all lined up in a continuous fashion. You could say that defragmentation is like cleaning house for your NAS – it picks up all of the pieces of data that are spread across your hard drive and puts them back together again. If your data is being modified constantly, the number of fragmented files in the file system will increase, resulting in slow access performance of files on the drives. Performing file system defragmentation can improve performance.

Note: The guide below is for DSM 6.2.4 – For DSM 7 check here: How to Defrag Your Hard Drives on DSM 7

Do you remember the golden years when you would perform a C drive defragmentation on your Windows computer? Well, Synology provides the exact same option as back then to speed up your drives. Surely many of you will remember this image:

defragmentation HDD

Why is defragmentation important for my Synology NAS?

Every NAS suffers from a constant growth of fragmentation. If you don’t clean up, your NAS performance is ultimately impacted. Defragging helps speed up your Hard Disk on your Synology NAS.

How can I perform File System Defragmentation on my Synology NAS?

Follow the step by step guide below.

  • STEP 1

Please Support My work by Making a Donation.

  • STEP 2

Warning: Do not continue using File System Defragmentation if you have snapshots on your volume created by Snapshot Replication. Please delete all snapshots before continuing.

  • STEP 3

Go to Storage ManagerVolume, select the volume you want to defrag, then at the top, click on the Action tab and then on “File System Defragmentation”. Follow the instructions in the image below. Note: Synology file system defragmentation can only be performed on volumes in the Btrfs file system, not Ext4. If you have volumes in Ext4, you will see the “File System Defragmentation” text greyed out.

Synology Defragmentation 1

  • STEP 4

After you click on File System Defragmentation, a pop up window will appear with the following message: File system defragmentation will be stopped if the system is shut down. Volume usage might increase if the volume contains snapshots of shared folders. Click Yes. Follow the instructions in the image below.

Synology Defragmentation 2

  • STEP 4 

After you click Yes, the defrag process will start, and it will last a few minutes (depends on volume size). After the defragmentation process is complete, the system will return to normal and you should see your HDD brought to new life as well as notice increments in performance.

Note: If you’re running off an SSD or some flash storage, you should really forget about defragmentation. SSD disks don’t have any mechanical parts.
Note: File system defragmentation is available on specific Synology NAS models only.
Note: It is necessary to run system defragmentation to rearrange data to speed up/accelerate file read speed.
Note: Synology file system defragmentation can only be performed on volumes in the Btrfs file system, not Ext4.
Note: For Ext4 volumes, you can download and run a command line tool e4defrag which is part of the e2fsprogs project. But remember, this only works in the ‘Ext4’ file system, not in the Btrfs file system.
Note: You can also make a task schedule for File System Defragmentation that is using Btrfs. Go to Control Panel / Task Scheduler / Create / Scheduled Task / User-defined script / Task Settings / Add the following code in the Run Command Area.

/sbin/btrfs filesystem defragment -r /volume1

Note: File system defragmentation can only be performed when the status of the volume is Healthy.
Note: Very important! Do not shut down the system before file system defragmentation is completed. If the system is shut down before completion, file system defragmentation must restart from the beginning. When you perform such operations, it’s mandatory to have an UPS.
Note: Volume usage might increase if the volume contains snapshots of different shared folders.
Note: File system defragmentation can give new life to an old HDD that has become less responsive over the years.

This post was updated on Monday / September 13th, 2021 at 6:46 PM