How Synology and FN OS NAS Users Can Save Space with Btrfs, jdupes, and CoW Deduplication

A practical guide to using Btrfs CoW deduplication with jdupes on Synology and FN OS NAS systems to save space without the risks of hard links.

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.

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:

1
2
3
/volume1/video/
/volume1/photo/
/volume1/data1/aaa/

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:

1
jdupes -r -B "/volume1/data1/aaa/"

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:

1
jdupes -r -B -X "req:*/@eaDir/*" -X "req:*/#recycle/*" "/volume1/data1/aaa/"

But some Synology environments report:

1
Invalid extfilter filter name was specified

If your jdupes -X help output shows support for nostr:text_string, use this more compatible form:

1
jdupes -r -B -X nostr:/@eaDir/ -X nostr:/#recycle/ "/volume1/data1/aaa/"

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:

1
jdupes -r -B -X nostr:/@eaDir/ -X nostr:/#recycle/ "/volume1/photo/视频工作/"

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:

1
find "/你的目标目录" -maxdepth 2 -type d

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:

1
2
3
[SRC] /volume1/data1/aaa/1/file.mkv
====> /volume1/data1/aaa/2/file.mkv
====> /volume1/data1/aaa/3/file.mkv

[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:

1
sudo btrfs filesystem usage /volume1/data1/aaa/

Focus on these fields:

1
2
3
Used:
Free (estimated):
Data,single: Used:

If deduplication took effect, you will usually see:

  • Used decrease;
  • Data,single: Used decrease;
  • 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:

1
sudo compsize "/volume1/data1/aaa/"

It is more suitable than plain du for understanding actual space usage on Btrfs.

Safe operating checklist

A cautious workflow looks like this:

  1. Confirm that the target directory is on a Btrfs volume;
  2. Test on a small directory before scanning the entire volume;
  3. Exclude system hidden directories, recycle bins, and application cache folders;
  4. Quote paths that contain Chinese characters or spaces;
  5. Record btrfs filesystem usage before deduplication;
  6. Run it again afterward and compare Used and Free (estimated);
  7. If you are unsure about an option, run jdupes --help and check the filters supported by your installed version.

For Synology, this is a good starting command:

1
jdupes -r -B -X nostr:/@eaDir/ -X nostr:/#recycle/ "/volume1/data1/aaa/"

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:

1
jdupes -r -B -X nostr:/@eaDir/ -X nostr:/#recycle/ "/你的Btrfs数据目录/"
记录并分享
Built with Hugo
Theme Stack designed by Jimmy