Media collections often hold the same file twice: once in the download folder, where the torrent keeps seeding, and once in the library, copied there by Sonarr, Radarr or by hand. jdupes finds such duplicates by their content and can turn them into hard links: both names stay, but the data is stored only once. The commands were tested on Ubuntu 26.04 LTS with jdupes 1.31; run them as root.
1. Install jdupes
apt install jdupes
2. Find Duplicates
Search a folder and all folders below it (-r), here /srv/media; -S also shows the size:
jdupes -r -S /srv/media
For example, it finds a film that is in the download folder and in the library under another name:
52428800 bytes each: /srv/media/downloads/Big.Movie.2024.1080p.mkv /srv/media/library/Movies/Big Movie (2024).mkv
jdupes compares the content, not the names. For a short summary, use -m: 1 duplicate files (in 1 sets), occupying 52 MB. This step changes nothing.
3. Replace the Copies With Hard Links
jdupes -r -L /srv/media
Each set of duplicates now points to the same data. Both names are kept: ls -li shows the same number in the first column (the same data) and a 2 for two names. In this example, the folder shrinks from 141 MB to 91 MB. The torrent client keeps seeding, and the library keeps working.
- Deleting one name leaves the other untouched. After you delete the download, the file in the library is still complete.
- A hard link only works within one file system. Duplicates on two different disks stay as they are.
- Both names show the same data: if a program changes the file under one name, the other name shows the change too. Media files are normally not changed, so this is rarely a problem.
Run jdupes -r -m /srv/media again: No duplicates found. jdupes does not count hard links as duplicates; add -H to see them.
jdupes can also delete duplicates. Linking is safer: you keep every name, and nothing that a torrent or an app expects disappears. If you delete, check the list from step 2 first.
Avoid duplicates from the start: Sonarr and Radarr can use hard links themselves when the download and library folders are on the same disk. Where the space goes: What Fills the Disk and What Loads the Server.