Duperemove(8)
Duperemove(8) ๐ System Managerโs Manual โ ok so welcome to the manual page for duperemove, section 8, bestie. buckle up ๐
โจ NAME โจ
duperemove โ find duplicate regions in files and submit them for deduplication ๐ฆ
๐ธ SYNOPSIS ๐ธ
duperemove options files...
๐ DESCRIPTION ๐
ok so duperemove is literally the chillest little tool for finding duplicated regions inside your files and then submitting them for deduplication. that's the whole vibe. ๐ซถ
when you hand it a list of files it hashes their contents and compares those hashes to each other, finding and categorizing regions that match each other. and when you give it the -d option, it will submit those regions for deduplication using the Linux kernel FIDEDUPERANGE ioctl. periodt. ๐
duperemove computes hashes for each file's extents as well as for the whole file's content. optionally, per-block hashes can be computed too. slay.
duperemove can store the hashes it computes in a hashfile. and if you give it an existing hashfile, it will only compute hashes for those files which have changed since the last run. so you can run duperemove repeatedly on your data as it changes, without having to re-checksum unchanged data. that's the dream fr fr. for more on hashfiles see the --hashfile option below plus the Examples section. ๐
duperemove can also take input from the fdupes program, see the --fdupes option below.
๐ GENERAL ๐
duperemove has two major modes of operation, and one of them is a subset of the other. iconic behaviour honestly.
๐ Readonly / Non-deduplicating Mode ๐
when you run it without -d (that's the default) duperemove will print out one or more tables of matching extents it has determined would be ideal candidates for deduplication. so readonly mode is perfect for peeking at what duperemove might do when you run it with -d. a little preview, a little vibe check. ๐
generally, duperemove does not concern itself with the underlying representation of the extents it processes. some of them could be compressed, undergoing I/O, or even have already been deduplicated. in dedupe mode, the kernel handles those details and therefore we try not to replicate that work. not me doing the kernel's job ๐
๐ฆ Deduping Mode ๐ฆ
this functions similarly to readonly mode with one exception: the duplicated extents found in our "read, hash, and compare" step will actually be submitted for deduplication. extents that have already been deduped will be skipped. ๐
an estimate of the total data deduplicated will be printed after the operation is complete. this estimate is calculated by comparing the total amount of shared bytes in each file before and after the dedupe. math girlies rise ๐ง
โจ OPTIONS โจ
๐ธ Common options ๐ธ
files can refer to a list of regular files and directories, or be a hyphen (-) to read them from standard input. if a directory is specified, all regular files within it will also be scanned. Duperemove can also be told to recursively scan directories with the -r switch. ๐ซถ
-rโ enable recursive dir traversal. ๐-dโ de-dupe the results โ only works on btrfs and xfs. use this option twice to disable the check and try to run the ioctl anyway. ๐--hashfile=hashfileโ use a file for storage of hashes instead of memory. this option drastically reduces the memory footprint ofduperemoveand is recommended when your data set is more than a few files large. hashfiles are also reusable, so you can further reduce the amount of hashing done on subsequent dedupe runs. ๐พ
if hashfile does not exist it will be created. if it exists, duperemove will check the file paths stored inside of it for changes. files which have changed will be rescanned and their updated hashes will be written to the hashfile. deleted files will be removed from the hashfile. โจ
new files are only added to the hashfile if they are discoverable via the files argument. for that reason you probably want to provide the same files list and -r arguments on each run of duperemove. the file discovery algorithm is efficient and will only visit each file once, even if it is already in the hashfile. no cap. ๐ฅ
adding a new path to a hashfile is as simple as adding it to the files argument.
when deduping from a hashfile, duperemove will avoid deduping files which have not changed since the last dedupe.
-B N,--batchsize=Nโ run the deduplication phase everyNfiles newly scanned. this greatly reduces memory usage for large datasets, or when you are doing partial extents lookup, but it reduces multithreading efficiency. ๐ญ
because of that small overhead, its value shall be selected based on the average file size and blocksize.
the default is a sane value for extents-only lookups, while you can go as low as 1 if you are running duperemove on very large files (like virtual machines etc). ๐ฅ๏ธ
by default, batching is set to 1024.
-hโ print numbers in human-readable format. ๐ฅฐ-qโ quiet mode.Duperemovewill only print errors and a short summary of any dedupe. ๐คซ-vโ be verbose. ๐ฃ๏ธ--helpโ prints help text. ๐
๐ Advanced options ๐
--fdupesโ run in fdupes mode. with this option you can pipe the output offdupestoduperemoveto dedupe any duplicate files found. when receiving a file list in this manner,duperemovewill skip the hashing phase. ๐-Lโ print all files in the hashfile and exit. requires the--hashfileoption. will print additional information about each file when run with-v. ๐-R files ..โ remove file from the db and exit.Duperemovewill read the list from standard input if a hyphen (-) is provided. requires the--hashfileoption. ๐๏ธ
note: if you are piping filenames from anotherduperemoveinstance it is advisable to do so into a temporary file first, as runningduperemovesimultaneously on the same hashfile may corrupt that hashfile. โ ๏ธ not a drill bestie.
--skip-zeroesโ read data blocks and skip any zeroed blocks, useful for speedupduperemove, but can prevent deduplication of zeroed files. โก-b sizeโ use the specified block size for reading file extents. defaults to128K. ๐--io-threads=Nโ useNthreads for I/O. this is used by the file hashing and dedupe stages. default is automatically detected based on number of host cpus. ๐งต--cpu-threads=Nโ useNthreads for CPU bound tasks. this is used by the duplicate extent finding stage. default is automatically detected based on number of host cpus. ๐ง
note: hyperthreading can adversely affect performance of the extent finding stage. if duperemove detects an Intel CPU with hyperthreading it will use half the number of cores reported by the system for cpu bound tasks. ๐
--dedupe-options=optionsโ comma separated list of options which alter how we dedupe. prependnoto an option in order to turn it off. ๐๏ธ[no]partialโDuperemovecan often find more dedupe by comparing portions of extents to each other. this can be a lengthy, CPU intensive task so it is turned off by default. using--batchsizeis recommended to limit the negative effects of this option. ๐ฎโ๐จ
the code behind this option is under active development and as a result the semantics of the partial argument may change. ๐ง
[no]sameโ defaults to on. allow dedupe of extents within the same file. ๐ฏ[no]only_whole_filesโ defaults to off.Duperemovewill only work on full file. both extent-based and block-based deduplication will be disabled. the hashfile will be smaller, some operations will be faster, but the deduplication efficiency will indeed be reduced. ๐
--read-hashes=hashfileโ this option is primarily for testing. see the--hashfileoption if you want to use hashfiles. ๐งช
read hashes from a hashfile. a file list is not required with this option. dedupe can be done if duperemove is run from the same base directory as is stored in the hash file (basically duperemove has to be able to find the files).
--write-hashes=hashfileโ this option is primarily for testing. see the--hashfileoption if you want to use hashfiles. ๐งช
write hashes to a hashfile. these can be read in at a later date and deduped from.
--debugโ print debug messages, forces-vif selected. ๐--hash-threads=Nโ deprecated, see--io-threadsabove. ๐ชฆ--exclude=PATTERNโ you can exclude certain files and folders from the deduplication process. this might be beneficial for skipping subvolume snapshot mounts, for instance. unless you provide a full path for exclusion, the exclude will be relative to the current working directory. another thing to keep in mind is that shells usually expand glob patterns, so the passed-in pattern ought to also be quoted. taking everything into consideration, the correct way to pass an exclusion pattern isduperemove --exclude "/path/to/dir/file*" /path/to/dir๐ซ
๐ EXAMPLES ๐
๐ Simple Usage ๐
dedupe the files in directory /foo, recurse into all subdirectories. you only want to use this for small data sets:
duperemove -dr /foo
use duperemove with fdupes to dedupe identical files below directory foo:
fdupes -r /foo | duperemove --fdupes
๐ง Using Hashfiles ๐ง
Duperemove can optionally store the hashes it calculates in a hashfile. hashfiles have two primary advantages โ memory usage and re-usability. when using a hashfile, duperemove will stream computed hashes to it, instead of main memory. ๐พโจ
if Duperemove is run with an existing hashfile, it will only scan those files which have changed since the last time the hashfile was updated. the files argument controls which directories duperemove will scan for newly added files. in the simplest usage, you rerun duperemove with the same parameters and it will only scan changed or newly added files โ see the first example below. ๐
dedupe the files in directory foo, storing hashes in foo.hash. we can run this command multiple times and duperemove will only checksum and dedupe changed or newly added files:
duperemove -dr --hashfile=foo.hash foo/
don't scan for new files, only update changed or deleted files, then dedupe:
duperemove -dr --hashfile=foo.hash
add directory bar to our hashfile and discover any files that were recently added to foo:
duperemove -dr --hashfile=foo.hash foo/ bar/
list the files tracked by foo.hash:
duperemove -L --hashfile=foo.hash
๐ FAQ ๐
Is duperemove safe for my data?
Yes bestie, it literally is. And here's the tea: duperemove does not deduplicate the data itself. It just finds candidates for dedupe and hands them over to the Linux kernel FIDEDUPERANGE ioctl. And to keep your data integrity on lock ๐, the kernel locks out other access to the file and does a byte-by-byte compare before it even thinks about proceeding with the dedupe. So yeah, your files are safe, no cap.
Is it safe to interrupt the program (Ctrl-C)?
Yep! Go ahead and smash that Ctrl-C, it's fine ๐ซถ The Linux kernel is the one dealing with the actual data. On duperemove's side, a transactional database engine is used. So the result is that you should be able to ctrl-c the program at any point and re-run it without experiencing corruption of your hashfile. And even in the worst-case scenario where a bug bites, your hashfile might get broken โ but your data never will. Periodt.
I got two identical files, why are they not deduped?
Okay so this one is giving "wait, what" energy, but it makes sense ๐ญ Duperemove by default works on extent granularity. What that means is: if there are two files which are logically identical (same content, bestie, same vibes) but they're laid out on disk with a different extent structure, they won't be deduped.
For example: if 2 files are 128k each and their content is identical, but one of them consists of a single 128k extent and the other consists of 2 * 64k extents, then they won't be deduped. That's just how it goes. This behavior is dependent on the current implementation and is subject to change as duperemove is being improved. So like, watch this space โจ
What is the cost of deduplication?
Deduplication will lead to increased fragmentation, that's the tradeoff ๐ And the blocksize you choose can have an effect on this. Larger blocksizes will fragment less but may not save you as much space. Conversely, smaller block sizes may save more space at the cost of increased fragmentation. Pick your fighter, I guess.
How can I find out my space savings after a dedupe?
Duperemove will print out an estimate of the saved space after a dedupe operation for you. Easy.
But if you want a more accurate picture, run btrfs fi df before and after each duperemove run.
Be careful about using thedftool on btrfs โ it is common for space reporting to bebehindwhile delayed updates get processed, so an immediate df after deduping might not show any savings. Don't panic, it's just lagging ๐ข
Why is the total deduped data report an estimate?
At the moment duperemove can detect that some underlying extents are shared with other files, but it can not resolve which files those extents are shared with. So it's out here doing its best with incomplete info ๐ญ
Imagine duperemove is examining a series of files and it notes a shared data region in one of them. That data could be shared with a file outside of the series. Since duperemove can't resolve that information, it will account the shared data against our dedupe operation โ while in reality, the kernel might deduplicate it further for us. So the estimate is like, an under-promise. Very demure of it honestly.
Why are my files showing dedupe but my disk space is not shrinking?
Oof, this one's a little complicated, but it comes down to a feature in Btrfs called bookending. The Btrfs wiki explains this in detail.
Essentially though, the underlying representation of an extent in Btrfs can not be split (with small exception). So sometimes we can end up in a situation where a file extent gets partially deduped (and the extents marked as shared) but the underlying extent item is not freed or truncated. Rude, honestly. ๐ค
Is there an upper limit to the amount of data duperemove can process?
Duperemove is fast at reading and cataloging data, that part's easy. Dedupe runs will be memory limited unless the --hashfile option is used. --hashfile allows duperemove to temporarily store duplicated hashes to disk, thus removing the large memory overhead and allowing for a far larger amount of data to be scanned and deduped. Iconic behavior, truly.
Realistically though you will be limited by the speed of your disks and cpu. And in those situations where resources are limited, you may have success by breaking up the input data set into smaller pieces. Slay by divide and conquer โจ
When using a hashfile, duperemove will only store duplicate hashes in memory. During normal operation then, the hash tree will make up the largest portion of duperemove memory usage. As of Duperemove v0.11, hash entries are 88 bytes in size. If you know the number of duplicate blocks in your data set, you can get a rough approximation of memory usage by multiplying with the hash entry size.
Actual performance numbers are dependent on hardware โ up to date testing information is kept on the duperemove wiki (see below for the link).
How large of a hashfile will duperemove create?
Hashfiles are essentially sqlite3 database files with several tables, the largest of which are the files and extents tables. Each extents table entry is about 72 bytes, though that may grow as features are added. The size of a files table entry depends on the file path, but a good estimate is around 270 bytes per file. And the number of extents in a data set is directly proportional to file fragmentation level โ so, more fragmented, more entries, you get it.
If you know the total number of extents and files in your data set, then you can calculate the hashfile size as:
Hashfile Size = Num Hashes * 72 + Num Files * 270
Using a real world example of 1TB (8388608 128K blocks) of data over 1000 files:
8388608 * 72 + 270 * 1000 = 755244720 or about 720MB for 1TB spread over 1000 files.
Note that none of this takes database overhead into account. So like, add a lil extra in your head, bestie ๐ญ
๐ NOTES ๐
Deduplication is currently only supported by the btrfs and xfs filesystem. That's the whole guest list, no plus-ones.
The Duperemove project page can be found on github.
There is also a wiki.
๐ SEE ALSO ๐
hashstats(8)filesystems(5)btrfs(8)xfs(8)fdupes(1)ioctl_fideduprange(2)
And that's the whole page, bestie, you made it to the end ๐ This was duperemove 0.15.1, dated 01 Mar 2025 โ go forth and dedupe responsibly, mwah ๐๐ฆโจ
๐ฆ where this page comes from
- alpine 3.24: duperemove-doc 0.15.2-r0 ยท GPL-2.0-only
- arch rolling: duperemove 0.15.2-1 ยท GPL-2.0-only
- epel 10: duperemove 0.15.2-1.el10_1 ยท GPL-2.0-only
- fedora 43: duperemove 0.15.2-2.fc43 ยท GPL-2.0-only
- fedora 44: duperemove 0.15.2-3.fc44 ยท GPL-2.0-only
- nixos 26.05: duperemove 0.15.2
- nixpkgs unstable: duperemove 0.15.2
- ubuntu resolute: duperemove 0.15.2-1 ยท GPL-2.0-only
- ubuntu stonking: duperemove 0.15.2-1 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms