File: duperemove.html

package info (click to toggle)
duperemove 0.11.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 844 kB
  • sloc: ansic: 11,586; makefile: 110
file content (644 lines) | stat: -rw-r--r-- 19,924 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>duperemove(8) - </title>
<style type="text/css">
h1 { font-size: 100%; margin-top: 2em; margin-bottom: 0; }
h2 { font-size: 100%; margin-left: 4ex; margin-top: 2em; margin-bottom: 0; }
p { margin-top: 1ex; margin-bottom: 1ex; }
.j { text-align: justify; }
.pp { margin-left: 8ex; }
.tp1 { margin-left: 12ex; }
.tp2 { margin-left: 16ex; }
.pre { font-family: monospace; }
</style>
</head>

<body>

<table width="98%">
	<tr>
		<td>duperemove(8)</td>
		<td align="center">Version 0.11</td>

		<td>duperemove(8)</td>

		</tr>
</table>

<h1><a name="0"></a>"NAME"</h1>

<p class="pp j">duperemove - Find duplicate extents and print them to stdout
</p>

<h1><a name="1"></a>"SYNOPSIS"</h1>

<p class="pp j"><b>duperemove</b> <i>[options]</i> \fIfiles...\fI
</p>

<h1><a name="2"></a>"DESCRIPTION"</h1>

<p class="pp j"><b>duperemove</b> is a simple tool for finding duplicated extents and
submitting them for deduplication. When given a list of files it will
hash their contents on a block by block basis and compare those hashes
to each other, finding and categorizing blocks that match each
other. When given the <b>-d</b> option, <b>duperemove</b> will submit
those extents for deduplication using the Linux kernel extent-same
ioctl.
<br />
<br />
<b>duperemove</b> can store the hashes it computes in a <i>hashfile</i>. If
given an existing hashfile, <b>duperemove</b> will only compute hashes
for those files which have changed since the last run.  Thus you can run
<b>duperemove</b> repeatedly on your data as it changes, without having to
re-checksum unchanged data.  For more on hashfiles see the
<b>--hashfile</b> option below as well as the <i>Examples</i> section.
<br />
<br />
<b>duperemove</b> can also take input from the <b>fdupes</b> program, see the
<b>--fdupes</b> option below.
<br />
<br />
</p>

<h1><a name="3"></a>"GENERAL"</h1>

<p class="pp j">Duperemove has two major modes of operation one of which is a subset
of the other.
<br />
<br />
</p>

<h2><a name="4"></a>"Readonly / Non-deduplicating Mode"</h2>

<br />
<br />
<p class="pp j">When run without <b>-d</b> (the default) duperemove will print out one or
more tables of matching extents it has determined would be ideal
candidates for deduplication. As a result, readonly mode is useful for
seeing what duperemove might do when run with <b>-d</b>. The output could
also be used by some other software to submit the extents for
deduplication at a later time.
<br />
<br />
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.
<br />
<br />
</p>

<h2><a name="5"></a>"Deduping Mode"</h2>

<br />
<br />
<p class="pp j">This functions similarly to readonly mode with the exception that the
duplicated extents found in our "read, hash, and compare" step will
actually be submitted for deduplication. 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.
<br />
<br />
</p>

<h1><a name="6"></a>"OPTIONS"</h1>

<p class="pp j"><i>files</i> 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.
<br />
<br />
</p>

<p class="tp1"><b>-r</b>
</p>

<p class="tp2 j">Enable recursive dir traversal.
<br />
<br />
</p>

<p class="tp1"><b>-d</b>
</p>

<p class="tp2 j">De-dupe the results - only works on <i>btrfs</i> and \fIxfs (experimental)\FR.
<br />
<br />
</p>

<p class="tp1"><b>-A</b>
</p>

<p class="tp2 j">Opens files readonly when deduping. Primarily for use by privileged
users on readonly snapshots.
<br />
<br />
</p>

<p class="tp1"><b>-h</b>
</p>

<p class="tp2 j">Print numbers in human-readable format.
<br />
<br />
</p>

<p class="tp1"><b>--hashfile=hashfile</b>
</p>

<p class="tp2 j">Use a file for storage of hashes instead of memory. This option drastically
reduces the memory footprint of duperemove and is recommended when your data
set is more than a few files large.  <i>Hashfiles</i> are also reusable,
allowing you to further reduce the amount of hashing done on subsequent
dedupe runs.
<br />
<br />
If <i>hashfile</i> does not exist it will be created.  If it exists,
<b>duperemove</b> 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 <i>hashfile</i>.  Deleted files will be removed from the <i>hashfile</i>.
<br />
<br />
New files are only added to the <i>hashfile</i> if they are discoverable via
the <i>files</i> argument.  For that reason you probably want to provide the
same <i>files</i> list and <b>-r</b> arguments on each run of
<b>duperemove</b>.  The file discovery algorithm is efficient and will only
visit each file once, even if it is already in the <i>hashfile</i>.
<br />
<br />
Adding a new path to a hashfile is as simple as adding it to the <i>files</i>
argument.
<br />
<br />
When deduping from a hashfile, duperemove will avoid deduping files which
have not changed since the last dedupe.
<br />
<br />
</p>

<p class="tp1"><b>-L</b>
</p>

<p class="tp2 j">Print all files in the hashfile and exit. Requires the <b>--hashfile</b> option.
Will print additional information about each file when run with <b>-v</b>.
<br />
<br />
</p>

<p class="tp1"><b>-R [file]</b>
</p>

<p class="tp2 j">Remove file from the db and exit. Can be specified multiple
times. Duperemove will read the list from standard input if a hyphen
(-) is provided. Requires the <b>--hashfile</b> option.
<br />
<br />
<b>Note:</b> If you are piping filenames from another duperemove instance it
is advisable to do so into a temporary file first as running duperemove
simultaneously on the same hashfile may corrupt that hashfile.
<br />
<br />
</p>

<p class="tp1"><b>--fdupes</b>
</p>

<p class="tp2 j">Run in <b>fdupes</b> mode. With this option you can pipe the output of
<b>fdupes</b> to duperemove to dedupe any duplicate files found. When
receiving a file list in this manner, duperemove will skip the hashing phase.
<br />
<br />
</p>

<p class="tp1"><b>-v</b>
</p>

<p class="tp2 j">Be verbose.
<br />
<br />
</p>

<p class="tp1"><b>--skip-zeroes</b>
</p>

<p class="tp2 j">Read data blocks and skip any zeroed blocks, useful for speedup duperemove,
but can prevent deduplication of zeroed files.
<br />
<br />
</p>

<p class="tp1"><b>-b size</b>
</p>

<p class="tp2 j">Use the specified block size. Raising the block size will consume less
memory but may miss some duplicate blocks. Conversely, lowering the
blocksize consumes more memory and may find more duplicate blocks. The
default blocksize of <b>128K</b> was chosen with these parameters in
mind.
<br />
<br />
</p>

<p class="tp1"><b>--io-threads=N</b>
</p>

<p class="tp2 j">Use N threads for I/O. This is used by the file hashing and dedupe
stages. Default is automatically detected based on number of
host cpus.
<br />
<br />
</p>

<p class="tp1"><b>--cpu-threads=N</b>
</p>

<p class="tp2 j">Use N threads for CPU bound tasks. This is used by the duplicate
extent finding stage. Default is automatically detected based on
number of host cpus.
<br />
<br />
<b>Note:</b> 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.
<br />
<br />
</p>

<p class="tp1"><b>--dedupe-options=</b><i>options</i>
</p>

<p class="tp2 j">Comma separated list of options which alter how we dedupe. Prepend 'no' to an
option in order to turn it off.
</p>

<p class="tp1"><b>[no]same</b>
</p>

<p class="tp2 j">Defaults to <b>off</b>. Allow dedupe of extents within the same
file.
</p>

<p class="tp1"><b>[no]fiemap</b>
</p>

<p class="tp2 j">Defaults to <b>on</b>. Duperemove uses the <i>fiemap</i> ioctl during
the dedupe stage to optimize out already deduped extents as well as to
provide an estimate of the space saved after dedupe operations are
complete.
<br />
<br />
Unfortunately, some versions of Btrfs exhibit extrmely poor
performance in fiemap as the number of references on a file extent
goes up. If you are experiencing the dedupe phase slowing down
or 'locking up' this option may give you a significant amount of
performance back.
<br />
<br />
<b>Note:</b> This does not turn off all useage of fiemap, to disable
fiemap during the file scan stage, you will also want to use the
<b>--lookup-extents=no</b> option.
</p>

<p class="tp1"><b>[no]block</b>
</p>

<p class="tp2 j">Defaults to <b>on</b>. Duperemove submits duplicate blocks directly to
the dedupe engine.
<br />
<br />
Duperemove can optionally optimize the duplicate block lists into
larger extents prior to dedupe submission. The search algorithm used
for this however has a very high memory and cpu overhead, but may
reduce the number of extent references created during dedupe. If you'd
like to try this, run with 'noblock'.
<br />
<br />
</p>

<p class="tp1"><b>--help</b>
</p>

<p class="tp2 j">Prints help text.
<br />
<br />
</p>

<p class="tp1"><b>--lookup-extents=[yes|no]</b>
</p>

<p class="tp2 j">Defaults to no. Allows duperemove to skip checksumming some blocks by
checking their extent state.
<br />
<br />
</p>

<p class="tp1"><b>-x</b>
</p>

<p class="tp2 j">Don't cross filesystem boundaries, this is the default behavior since
duperemove v0.11. The option is kept for backwards compatibility.
<br />
<br />
</p>

<p class="tp1"><b>--read-hashes=hashfile</b>
</p>

<p class="tp2 j"><b>\This option is primarily for testing.</b> See the <b>--hashfile</b> option if you want to use hashfiles.
<br />
<br />
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).
<br />
<br />
</p>

<p class="tp1"><b>--write-hashes=hashfile</b>
</p>

<p class="tp2 j"><b>\This option is primarily for testing.</b> See the <b>--hashfile</b> option if you want to use hashfiles.
<br />
<br />
Write hashes to a hashfile. These can be read in at a later date and
deduped from.
<br />
<br />
</p>

<p class="tp1"><b>--debug</b>
</p>

<p class="tp2 j">Print debug messages, forces <b>-v</b> if selected.
<br />
<br />
</p>

<p class="tp1"><b>--hash-threads=N</b>
</p>

<p class="tp2 j">Deprecated, see <b>--io-threads</b> above.
<br />
<br />
</p>

<p class="tp1"><b>--hash=alg</b>
</p>

<p class="tp2 j">You can choose between murmur3 and xxhash. The default is murmur3 as
it is very fast and can generate 128 bit digests for a very small
chance of collision. Xxhash may be faster but generates only 64 bit
digests. Both hashes are fast enough that the default should work well
for the overwhelming majority of users.
<br />
<br />
</p>

<h1><a name="7"></a>"EXAMPLES"</h1>

<h2><a name="8"></a>"Simple Usage"</h2>

<p class="pp j">Dedupe the files in directory /foo, recurse into all subdirectories. You only want to use this for small data sets.
</p>

<p class="tp2 j">duperemove -dr /foo
</p>

<p class="pp j">Use duperemove with fdupes to dedupe identical files below directory foo.
</p>

<p class="tp2 j">fdupes -r /foo | duperemove --fdupes
<br />
<br />
</p>

<h2><a name="9"></a>"Using Hashfiles"</h2>

<p class="pp j">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.
<br />
<br />
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 <i>files</i> 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.
<br />
<br />
</p>

<p class="pp j">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.
</p>

<p class="tp2 j">duperemove -dr --hashfile=foo.hash foo/
</p>

<p class="pp j">Don't scan for new files, only update changed or deleted files, then dedupe.
</p>

<p class="tp2 j">duperemove -dr --hashfile=foo.hash
</p>

<p class="pp j">Add directory bar to our hashfile and discover any files that were
recently added to foo.
</p>

<p class="tp2 j">duperemove -dr --hashfile=foo.hash foo/ bar/
</p>

<p class="pp j">List the files tracked by foo.hash.
</p>

<p class="tp2 j">duperemove -L --hashfile=foo.hash
<br />
<br />
</p>

<h1><a name="10"></a>"FAQ"</h1>

<h2><a name="11"></a>Is there an upper limit to the amount of data duperemove can process?</h2>

<br />
<br />
<p class="pp j">Duperemove v0.11 is fast at reading and cataloging data. 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. Realistically though you will be limited by the speed of
your disks and cpu. In those situations where resources are limited you may
have success by breaking up the input data set into smaller pieces.
<br />
<br />
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 dupremoves 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.
<br />
<br />
Actual performance numbers are dependent on hardware - up to date
testing information is kept on the duperemove wiki (see below for the link).
<br />
<br />
</p>

<h2><a name="12"></a>How large of a hashfile will duperemove create?</h2>

<br />
<br />
<p class="pp j">Hashfiles are essentially sqlite3 database files with several tables,
the largest of which are the files and hashes tables. Each hashes
table entry is under 90 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.
<br />
<br />
If you know the total number of blocks and files in your data set then
you can calculate the hashfile size as:
<br />
<br />
<b>Hashfile Size = Num Hashes X 90 + Num Files X 270</b>
<br />
<br />
Using a real world example of 1TB (8388608 128K blocks) of data over 1000 files:
<br />
<br />
8388608 * 90 + 270 * 1000 = 755244720 or about <b>720MB for 1TB spread over 1000 files.</b>
<br />
<br />
</p>

<h2><a name="13"></a>Is is safe to interrupt the program (Ctrl-C)?</h2>

<br />
<br />
<p class="pp j">Yes, Duperemove uses a transactional database engine and organizes db
changes to take advantage of those features. The result is that you
should be able to ctrl-c the program at any point and re-run without
experiencing corruption of your hashfile.
<br />
<br />
</p>

<h2><a name="14"></a>How can I find out my space savings after a dedupe?</h2>

<br />
<br />
<p class="pp j">Duperemove will print out an estimate of the saved space after a
dedupe operation for you.
<br />
<br />
You can get a more accurate picture by running 'btrfs fi df' before
and after each duperemove run.
<br />
<br />
Be careful about using the 'df' tool on btrfs - it is common for space
reporting to be 'behind' while delayed updates get processed, so an
immediate df after deduping might not show any savings.
<br />
<br />
</p>

<h2><a name="15"></a>Why is the total deduped data report an estimate?</h2>

<br />
<br />
<p class="pp j">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.
<br />
<br />
Imagine duperemove is examing 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.
<br />
<br />
</p>

<h2><a name="16"></a>Why are my files showing dedupe but my disk space is not shrinking?</h2>

<br />
<br />
<p class="pp j">This is a little complicated, but it comes down to a feature in Btrfs
called _bookending_. The Btrfs wiki explains this in detail:
http://en.wikipedia.org/wiki/Btrfs#Extents.
<br />
<br />
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.
<br />
<br />
</p>

<h2><a name="17"></a>Is duperemove safe for my data?</h2>

<br />
<br />
<p class="pp j">Yes. To be specific, duperemove does not deduplicate the data itself.
It simply finds candidates for dedupe and submits them to the Linux
kernel extent-same ioctl. In order to ensure data integrity, the
kernel locks out other access to the file and does a byte-by-byte
compare before proceeding with the dedupe.
<br />
<br />
</p>

<h2><a name="18"></a>What is the cost of deduplication?</h2>

<br />
<br />
<p class="pp j">Deduplication will lead to increased fragmentation. The blocksize
chosen 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.
<br />
<br />
</p>

<h1><a name="19"></a>"NOTES"</h1>

<p class="pp j">Deduplication is currently only supported by the <i>btrfs</i> and <i>xfs</i> filesystem.
<br />
<br />
The Duperemove project page can be found at http://github.com/markfasheh/duperemove
<br />
<br />
There is also a wiki at http://github.com/markfasheh/duperemove/wiki
<br />
<br />
</p>

<h1><a name="20"></a>"SEE ALSO"</h1>

<p class="pp j"><b>hashstats(8)</b> <b>filesystems(5)</b> <b>btrfs(8)</b> <b>xfs(8)</b> <b>fdupes(1)</b> </p>

<h1>Index</h1>

<ol>
<li><a href="#0">"NAME"</a></li><li><a href="#1">"SYNOPSIS"</a></li><li><a href="#2">"DESCRIPTION"</a></li><li><a href="#3">"GENERAL"</a></li><ol>
<li><a href="#4">"Readonly / Non-deduplicating Mode"</a></li><li><a href="#5">"Deduping Mode"</a></li></ol>
<li><a href="#6">"OPTIONS"</a></li><li><a href="#7">"EXAMPLES"</a></li><ol>
<li><a href="#8">"Simple Usage"</a></li><li><a href="#9">"Using Hashfiles"</a></li></ol>
<li><a href="#10">"FAQ"</a></li><ol>
<li><a href="#11">Is there an upper limit to the amount of data duperemove can process?</a></li><li><a href="#12">How large of a hashfile will duperemove create?</a></li><li><a href="#13">Is is safe to interrupt the program (Ctrl-C)?</a></li><li><a href="#14">How can I find out my space savings after a dedupe?</a></li><li><a href="#15">Why is the total deduped data report an estimate?</a></li><li><a href="#16">Why are my files showing dedupe but my disk space is not shrinking?</a></li><li><a href="#17">Is duperemove safe for my data?</a></li><li><a href="#18">What is the cost of deduplication?</a></li></ol>
<li><a href="#19">"NOTES"</a></li><li><a href="#20">"SEE ALSO"</a></li></ol>
</body>
</html>