If your NAS stores videos, backup archives, installer images, or exported photo folders, duplicate files can quietly consume hundreds of GB or even several TB. The traditional approach is to delete duplicates or replace them with hard links, but neither option is ideal for long-term NAS storage.
A safer approach is to use jdupes for block-level deduplication on a filesystem that supports CoW.
For Synology and FN OS NAS users, if the storage volume uses Btrfs, jdupes -B can call the underlying filesystem capability and make duplicate files share the same physical data blocks. The files still look independent in the directory tree, but only one copy of the data is stored underneath.
How CoW deduplication differs from hard links
Hard links work by making multiple paths point to the same inode.
This does save space, but it has a clear downside: if a program modifies one of those files, all hard-linked paths see the change. For media libraries, sync folders, photo managers, and backup directories, that behavior can create subtle trouble.
Btrfs CoW deduplication is different.
Its logic is: multiple independent files can share identical data blocks; once one file is modified, the filesystem writes the changed part to new blocks, and the other files remain untouched.
After CoW deduplication:
- file paths remain independent;
- deleting one file does not delete the others;
- modifying one file does not modify the others;
- duplicate parts take only one copy of physical disk space.
This is why jdupes -B is usually a better fit for NAS deduplication than hard links.
Good use cases
CoW deduplication is especially useful for directories such as:
- duplicated TV episodes and movies in media libraries;
- installer packages, ISO files, and archives stored in different folders;
- repeated photo or video exports;
- large duplicate files produced by backup tools;
- temporary folders copied during manual cleanup.
Do not start by scanning the entire system volume. A safer workflow is to test on a user data directory first, for example:
|
|
Test the command, exclusion rules, and space savings on a small scope before expanding the scan.
Basic command
To run CoW deduplication with jdupes on a Btrfs directory, the key option is -B:
|
|
Option meanings:
-r: scan subdirectories recursively;-B: perform Btrfs/CoW deduplication for duplicate files instead of creating hard links;"/volume1/data1/aaa/": the target directory to scan.
The important part is -B. It makes jdupes use the filesystem-supported deduplication mechanism, usually through low-level reflink, clone, or dedupe range interfaces.
Exclude @eaDir and #recycle on Synology
On Synology, it is usually best to exclude @eaDir and #recycle from the scan.
@eaDir is a hidden directory generated by Synology. It commonly stores thumbnails, media indexes, extended attributes, and package-related cache data. These files are numerous, small, expensive to scan, and usually not worth deduplicating. Scanning them may also interfere with Synology indexing services.
#recycle is the recycle bin for shared folders. Files there are waiting to be removed, so deduplicating them provides little value and makes the results harder to interpret.
For Synology, exclude both directories.
Different jdupes versions support different forms of the -X option. Some tutorials use:
|
|
But some Synology environments report:
|
|
If your jdupes -X help output shows support for nostr:text_string, use this more compatible form:
|
|
The meaning is straightforward:
-X nostr:/@eaDir/: exclude files whose path contains/@eaDir/;-X nostr:/#recycle/: exclude files whose path contains/#recycle/.
If the target path contains Chinese characters or spaces, always wrap it in quotes:
|
|
How to think about FN OS NAS
If FN OS uses a Btrfs storage pool, the idea is similar to Synology: confirm that the target directory is on Btrfs, then use jdupes -B for CoW deduplication.
The difference is that hidden system directories may have different names. Synology commonly uses @eaDir and #recycle; on FN OS, you should decide exclusion rules based on the actual directory structure.
Start by listing nearby directories:
|
|
Check whether there are system caches, recycle bins, index folders, or app data directories. The files most worth deduplicating are usually large user files, not small system-generated cache files.
How to confirm CoW deduplication worked
Do not rely only on ls -l. After CoW deduplication, the logical file size remains unchanged, and the directory still appears to contain multiple complete files.
There are three more reliable ways to verify the result.
1. Check jdupes output
During execution, output like this usually means duplicate files were detected and processed:
|
|
[SRC] is the source file, and files after ====> are deduplicated against the same underlying data blocks. They still exist independently, but their physical storage has been consolidated.
2. Compare Btrfs space usage
Before and after deduplication, run:
|
|
Focus on these fields:
|
|
If deduplication took effect, you will usually see:
Useddecrease;Data,single: Useddecrease;Free (estimated)increase.
For example, if Used drops from 8.44TiB to 8.20TiB, even a reduction of a few dozen GB means CoW deduplication has released physical space.
3. Use compsize for real usage
If your system can install compsize, it gives a clearer view of real Btrfs usage after compression and deduplication:
|
|
It is more suitable than plain du for understanding actual space usage on Btrfs.
Safe operating checklist
A cautious workflow looks like this:
- Confirm that the target directory is on a Btrfs volume;
- Test on a small directory before scanning the entire volume;
- Exclude system hidden directories, recycle bins, and application cache folders;
- Quote paths that contain Chinese characters or spaces;
- Record
btrfs filesystem usagebefore deduplication; - Run it again afterward and compare
UsedandFree (estimated); - If you are unsure about an option, run
jdupes --helpand check the filters supported by your installed version.
For Synology, this is a good starting command:
|
|
If your jdupes version does not support nostr, adjust the filter options according to jdupes -X or jdupes --help.
Summary
The value of Btrfs plus jdupes -B is that you can save space without deleting files or turning them into hard links. Duplicate content shares physical blocks while each file remains independent.
For Synology and FN OS NAS users, this is especially useful for duplicate videos, backup files, and large media assets. The main things to control are scan scope and exclusion rules: focus on user data, avoid system caches and recycle bins, and compare Btrfs usage before and after the run.
For safe space savings, remember this command pattern:
|
|