SpaceRex · July 27, 2020 0

Defragment Array on Synology NAS

Overtime the free space on you hard drives can get spread out on the physical drive, slowing performance. In order to combat this you should defragment your hard drives on a simi-regular basis. This tutorial will cover how to defragment a hard drive array on Synology NAS.

Overview

Hard drive fragmentation is caused by the fact that when you delete something on a hard drive, it does not actually write over the data that was there. Instead the drive essentially forgets that data was ever stored there. This allows the data in this location to be overwritten the next time data is saved. Overtime this process causes your hard drive space to become fragmented, slowing down your hard drive.

Defragmentation is the process of taking all of the files, which are spaced out across your hard drive array, and saving them in a more organized manner. This process allows for the array to read and write data more quickly, as the drive head does not have to move as far between files.

On your Synology NAS the process of defragmenting a hard drive array can take anywhere from 1 – 20 hours, depending on multiple factors including, how full the drives are, drive size, and how fragmented the array was. During the time that the filesystem is defragmenting you will see a considerable, but not crippling, loss in performance. There is no perfect guide to how often you should defragment your dive as it is directly related to how often you save files to the array and many other factors. General users should not have to defragment their arrays more than 2x a year.

Defragmenting your hard drive pool will not give you faster performance past the number of drives in your RAID. However expanding the drive pool in your NAS by adding an additional drive will increase the maximum throughput of your pool!

Caveats

SSD Pool

Defragmentation should not be done on an SSD pool as there are no moving parts within an SSD. Because there are no moving parts the fact that the drive becomes fragmented does not slow it down. Furthermore SSD’s have a limited (usual very large) number of writes that can be done before to the drive fails. Defragmentation essentially rewrites everything on the drive, which would limit the lifespan of an SSD

BTRFS Snapshots

Because of the way that BTRFS Snapshots work defragmentation can cause some of the thin snapshots to become larger. This means that if you have many snapshots and you defragment your pool, the total used space may increase.

EXT4

Currently EXT4 does not support defragmentation though DSM. There are some add-on packages that handle it. However I have not tested those so it is up to the users discretion.

How To

Defragmenting on Synology is incredibly easy. First step is to login to DSM and open Storage Manager. From within Storage Manager select Volume from the submenu on the left as shown below:

Volume Tab within Storage Manager

From within the Volume tab select which volume you would like to defragment. Then in the action drop down menu select File System Defragmentation as shown below:

File System Defragmentation Drop Down Menu

After this you will likely get a conformation screen, select ok and the filesystem will begin defragmenting. You will notice a considerable drop in performance during this time. The status and percent complete of the defragmentation process should be shown on the screen.

Defragmentation in Progress

After the defragmentation process is complete the system will return to normal and you should see better performance.

Conclusion

File system defragmentation can give new life into an old array as the drive heads simply do not have to move as far when reading or writing.

Thanks for reading! Feel free to leave any comments or questions below! Always looking for more tutorials to write!

>–Read More or other great articles on SpaceRex.co –<