fdupes – find & replace duplicate files with hardlinks

Warning!

If you do not know how hardlink works, do not follow this tutorial.

We use this method when duplicate files are kind of “read-only”. Because if you replace 2 duplicate files with hardlink pointing to common storage, editing one will change others content. If this is fine, then you can go ahead.

Don’t worry about deletion. Deleting one file won’t delete other file.

Install fdupes 1.51

Ubutnu 12.04 has repo has older version. So follow this:

git clone https://github.com/tobiasschulz/fdupes
cd fdupes
make fdupes
su root
make install

Usage

Find duplicate files…

fdupes -r /path/to/dir

Find duplicate files and replace with hardlinks

fdupes -rL /path/to/dir

Note -L option which is responsible for replacing duplicate with hardlinks.