Find and remove duplicated hard link files
To remove duplicated hard link files using following command. The hard link files could be created by rmlint deduplication.
find . -type f -links +1 -printf '%i %n %p\n' -exec rm '{}' \;
To remove duplicated hard link files using following command. The hard link files could be created by rmlint deduplication.
find . -type f -links +1 -printf '%i %n %p\n' -exec rm '{}' \;
rmlintusageThe command rmlint can be used to dedup the files, which can support reflink.
I was using reflink dedup for BTRFS, but end up, I changed to hardlink. I think hardlink is more commonly used in Unix environment
rmlint -T df --config=sh:handler=hardlink /dedup
This will dedup the files in /dedup directory, and will generate a file called rmlint.sh in current directory. Run that shell script, will change duplicated files to hard link.
The -T df means dedup files.
The config=sh means generate shell script
The handler=hardlink means generate script using hardlink dedup
There are many options, but I don't use them.