file-management: fdupes with hardlinks

Fdupes is a very useful tool - it searches your harddisk for duplicated files and helps you to keep it structured. Currently, it only supports deleting duplicated files, which is not suitable for my music collection, because I want to store the same music in different places (eg. to make a collection for different reasons like music for a wedding and so on). One possibility would be to add tags to the music. But this would take very long to search through all and you can’t just copy the preselected files with just a filemanager. The solution is: fdupes should hardlink instead of deleting.


Use this only if you have a backup. The patch is new and not tested on a wide basis. This means it can destroy all your files! It also has no interactive modus. Use it on your own risk._

Thanks to Javier Fernández-Sanguino Peña its now possible to hardlink instead of delete duplicates (currently this is only available for deb-package-managers).

First you need to get these 3 files from a Debian FTP:

  • fdupes_1.50-PR2-2.diff.gz
  • fdupes_1.50-PR2-2.dsc
  • fdupes_1.50-PR2.orig.tar.gz

Then download the whole patch from this website: Bug#284274: Patch for the hardlink replacement bug request and save it as fdupes.patch.

If your system is not already prepared to compile software, you’ll need at least the following packages:

  • build-essential
  • devscripts
  • debhelper
  • dpatch

After that run this command to extract the source:

dpkg-source -x fdupes_1.50-PR2-2.dsc

Then change to the source directory and apply the patch:

cd fdupes-1.50-PR2
patch -p1 <../fdupes.patch

Now compile the source and make a debian package with the following command:

debuild -us -uc

After that you can install/upgrade the package easily with dpkg:

cd ..
sudo dpkg -i fdupes*deb

Happy hardlinking - the new switch is "-L".