xref: /freebsd/sbin/recoverdisk/recoverdisk.1 (revision a64729f5077d77e13b9497cb33ecb3c82e606ee8)
1.\" Copyright (c) 2006 Ulrich Spoerlein <uspoerlein@gmail.com>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.Dd April 3, 2020
26.Dt RECOVERDISK 1
27.Os
28.Sh NAME
29.Nm recoverdisk
30.Nd recover data from hard disk or optical media
31.Sh SYNOPSIS
32.Nm
33.Op Fl b Ar bigsize
34.Op Fl r Ar readlist
35.Op Fl s Ar interval
36.Op Fl u Ar pattern
37.Op Fl v
38.Op Fl w Ar writelist
39.Ar source
40.Op Ar destination
41.Sh DESCRIPTION
42The
43.Nm
44utility reads data from the
45.Ar source
46file until all blocks could be successfully read.
47If
48.Ar destination
49was specified all data is being written to that file.
50It starts reading in multiples of the sector size.
51Whenever a block fails, it is put to the end of the working queue and will be
52read again, possibly with a smaller read size.
53.Pp
54By default it uses block sizes of roughly 1 MB, 32kB, and the native
55sector size (usually 512 bytes).
56These figures are adjusted slightly, for devices whose sectorsize is not a
57power of 2, e.g., audio CDs with a sector size of 2352 bytes.
58.Pp
59The options are as follows:
60.Bl -tag -width indent
61.It Fl b Ar bigsize
62The size of reads attempted first.
63The middle pass is roughly the logarithmic average of the bigsize and
64the sectorsize.
65.It Fl r Ar readlist
66Read the list of blocks and block sizes to read from the specified file.
67.It Fl s Ar interval
68How often we should update the writelist file while things go OK.
69The default is 60 and the unit is "progress messages" so if things
70go well, this is the same as once per minute.
71.It Fl u Ar pattern
72By default blocks which encounter read errors will be filled with
73the pattern
74.Ql _UNREAD_
75in the output file.
76This option can be
77used to specify another pattern.
78Nothing gets written if the string is empty.
79.It Fl v
80Enables nicer status report using ANSI escapes and UTF-8.
81.It Fl w Ar writelist
82Write the list of remaining blocks to read to the specified file if
83.Nm
84is aborted via
85.Dv SIGINT .
86.El
87.Pp
88The
89.Fl r
90and
91.Fl w
92options can be specified together.
93Especially, they can point to the same file, which will be updated on abort.
94.Sh OUTPUT
95The
96.Nm
97utility
98prints several columns, detailing the progress
99.Bl -tag -width remaining
100.It Va start
101Starting offset of the current block.
102.It Va size
103Read size of the current block.
104.It Va len
105Length of the current block.
106.It Va state
107Is increased for every failed read.
108.It Va done
109Number of bytes already read.
110.It Va remaining
111Number of bytes remaining.
112.It Va "% done"
113Percent complete.
114.El
115.Sh EXAMPLES
116.Bd -literal
117# recover data from failing hard drive ada3
118recoverdisk /dev/ada3 /data/disk.img
119
120# clone a hard disk
121recoverdisk /dev/ada3 /dev/ada4
122
123# read an ISO image from a CD-ROM
124recoverdisk /dev/cd0 /data/cd.iso
125
126# continue reading from a broken CD and update the existing worklist
127recoverdisk -r worklist -w worklist /dev/cd0 /data/cd.iso
128
129# recover a single file from the unreadable media
130recoverdisk /cdrom/file.avi file.avi
131
132# If the disk hangs the system on read-errors try:
133recoverdisk -b 0 /dev/ada3 /somewhere
134
135.Ed
136.Sh SEE ALSO
137.Xr dd 1 ,
138.Xr ada 4 ,
139.Xr cam 4 ,
140.Xr cd 4 ,
141.Xr da 4
142.Sh HISTORY
143The
144.Nm
145utility first appeared in
146.Fx 7.0 .
147.Sh AUTHORS
148.An -nosplit
149The original implementation was done by
150.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org
151with minor improvements from
152.An Ulrich Sp\(:orlein Aq Mt uqs@FreeBSD.org .
153.Pp
154This manual page was written by
155.An Ulrich Sp\(:orlein .
156.Sh BUGS
157Reading from media where the sectorsize is not a power of 2 will make all
1581 MB reads fail.
159This is due to the DMA reads being split up into blocks of at most 128kB.
160These reads then fail if the sectorsize is not a divisor of 128kB.
161When reading a full raw audio CD, this leads to roughly 700 error messages
162flying by.
163This is harmless and can be avoided by setting
164.Fl b
165to no more than 128kB.
166.Pp
167.Nm
168needs to know about read errors as fast as possible, i.e., retries by lower
169layers will usually slow down the operation.
170When using
171.Xr cam 4
172attached drives, you may want to set kern.cam.XX.retry_count to zero, e.g.:
173.Bd -literal
174# sysctl kern.cam.ada.retry_count=0
175# sysctl kern.cam.cd.retry_count=0
176# sysctl kern.cam.da.retry_count=0
177.Ed
178.\".Pp
179.\"When reading from optical media, a bug in the GEOM framework will
180.\"prevent it from seeing that the media has been removed.
181.\"The device can still be opened, but all reads will fail.
182.\"This is usually harmless, but will send
183.\".Nm
184.\"into an infinite loop.
185