NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.
Forum Discussion
Platypus69
Dec 24, 2020Luminary
Should I ever run a Defrag operation if I only every insert/append to NAS (with no Snapshots enabled
I'm back... :)
Just making sure my "theory is correct", as I am not sure of the nuances with BTRFS.
Do I ever need to run a Defrag operation for the use case below?
All I had scheduled was Disk Test and Scrub operations, but as I learnt this week I should also run Balance operations periodically to optimize meta-data / allocation.
Use Case
I ever only copy files to my ReadyNAS, and as a result have no snapshots configured as there is no need.
So virtually never delete or overwrite the files The exception is when a file copy operation fails for whatever reasons so it's a partial copy-on-write, but that was/is extremely rare.
TIA
8 Replies
Replies have been turned off for this discussion
- rn_enthusiastVirtuoso
I have a similar use case to yours. My NAS is primarily a media library where files are written once and then read when played back. Rarely are files changed or deleted. I have never defragged it and it is as smooth as day one. This is a CoW filesystem and fragmentation will occur over time, especially when using snapshots. In the other big CoW filesystem, ZFS, you can't even defrag - it is not an option.
If you NAS runs fine and you have no performance issues, then don't defrag. That is my opinion. It is worth keeping in mind that defragging can increase data usage on the volume as it can cause data bloat because snapshot reflinks might have to be broken as part of the defrag process.
https://btrfs.wiki.kernel.org/index.php/Manpage/btrfs-filesystem
I stay away from defrag unless I really have to and in that case I would use the command line to defrag individual files that causes performance issues, rather than the entire volume.
- StephenBGuru - Experienced User
rn_enthusiast wrote:
If you NAS runs fine and you have no performance issues, then don't defrag. That is my opinion. It is worth keeping in mind that defragging can increase data usage on the volume as it can cause data bloat because snapshot reflinks might have to be broken as part of the defrag process.
Personally I do defrag my volumes every three months via the volume maintenace schedule, and haven't had any issues with space usage doing that.
But overall, I agree that it's fine not to run them (and disable the auto defrag option for the share), and only do defrags when you run into performance issues due to fragmented files.
Defragmenting a file that is in a snapshot (or otherwise reflinked) can increase the on-disk usage. But this only happens if the file was modified in place on the NAS. Personally I rarely do that (though re-tagging media files is one exception).
Platypus69 wrote:
... as I learnt this week I should also run Balance operations periodically to optimize meta-data / allocation.
Just to expand on this a bit. BTRFS allocates space in chunks - and the usual chunk size is 1 Gigabyte. It's not that good at keeping the chunks full, so you often end up with quite a few partially filled chunks. This results in free space that the file system can't actually use. Even in your particular usage, you will end up with these partially filled chunks.
One thing that the balance does is that it consolidates these partially filled chunks - which creates fully empty ones that the file system can use.
Also, defragging a file can increase the number of partially filled chunks, since it is basically rewriting the file into unallocated space - leaving some of the original chunks partially filled.
- rn_enthusiastVirtuoso
Back in the days, in support we did come across some extreme cases where people literally acutally ran out of storage mid/post-defrag. So, it is certainly a thing that can happen depending on how the snapshot/reflink situation is - something not easy to see/control from a user-level.
It is something that can potentially occur. For me, it is the same as with balance. I run it only if I need to but then again, I would know if/when I need to. So, it is fine that Netgear allows people to do it on a scheduled basis to ensure these tasks are done - I'm not against that :)
Related Content
NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology!
Join Us!