xref: /freebsd/sbin/recoverdisk/recoverdisk.1 (revision 6419bb52)
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.\" $FreeBSD$
26.\"
27.Dd April 3, 2020
28.Dt RECOVERDISK 1
29.Os
30.Sh NAME
31.Nm recoverdisk
32.Nd recover data from hard disk or optical media
33.Sh SYNOPSIS
34.Nm
35.Op Fl b Ar bigsize
36.Op Fl r Ar readlist
37.Op Fl s Ar interval
38.Op Fl u Ar pattern
39.Op Fl v
40.Op Fl w Ar writelist
41.Ar source
42.Op Ar destination
43.Sh DESCRIPTION
44The
45.Nm
46utility reads data from the
47.Ar source
48file until all blocks could be successfully read.
49If
50.Ar destination
51was specified all data is being written to that file.
52It starts reading in multiples of the sector size.
53Whenever a block fails, it is put to the end of the working queue and will be
54read again, possibly with a smaller read size.
55.Pp
56By default it uses block sizes of roughly 1 MB, 32kB, and the native
57sector size (usually 512 bytes).
58These figures are adjusted slightly, for devices whose sectorsize is not a
59power of 2, e.g., audio CDs with a sector size of 2352 bytes.
60.Pp
61The options are as follows:
62.Bl -tag -width indent
63.It Fl b Ar bigsize
64The size of reads attempted first.
65The middle pass is roughly the logarithmic average of the bigsize and
66the sectorsize.
67.It Fl r Ar readlist
68Read the list of blocks and block sizes to read from the specified file.
69.It Fl s Ar interval
70How often we should update the writelist file while things go OK.
71The default is 60 and the unit is "progress messages" so if things
72go well, this is the same as once per minute.
73.It Fl u Ar pattern
74By default blocks which encounter read errors will be filled with
75the pattern
76.Ql _UNREAD_
77in the output file.
78This option can be
79used to specify another pattern.
80Nothing gets written if the string is empty.
81.It Fl v
82Enables nicer status report using ANSI escapes and UTF-8.
83.It Fl w Ar writelist
84Write the list of remaining blocks to read to the specified file if
85.Nm
86is aborted via
87.Dv SIGINT .
88.El
89.Pp
90The
91.Fl r
92and
93.Fl w
94options can be specified together.
95Especially, they can point to the same file, which will be updated on abort.
96.Sh OUTPUT
97The
98.Nm
99utility
100prints several columns, detailing the progress
101.Bl -tag -width remaining
102.It Va start
103Starting offset of the current block.
104.It Va size
105Read size of the current block.
106.It Va len
107Length of the current block.
108.It Va state
109Is increased for every failed read.
110.It Va done
111Number of bytes already read.
112.It Va remaining
113Number of bytes remaining.
114.It Va "% done"
115Percent complete.
116.El
117.Sh EXAMPLES
118.Bd -literal
119# recover data from failing hard drive ada3
120recoverdisk /dev/ada3 /data/disk.img
121
122# clone a hard disk
123recoverdisk /dev/ada3 /dev/ada4
124
125# read an ISO image from a CD-ROM
126recoverdisk /dev/cd0 /data/cd.iso
127
128# continue reading from a broken CD and update the existing worklist
129recoverdisk -r worklist -w worklist /dev/cd0 /data/cd.iso
130
131# recover a single file from the unreadable media
132recoverdisk /cdrom/file.avi file.avi
133
134# If the disk hangs the system on read-errors try:
135recoverdisk -b 0 /dev/ada3 /somewhere
136
137.Ed
138.Sh SEE ALSO
139.Xr dd 1 ,
140.Xr ada 4 ,
141.Xr cam 4 ,
142.Xr cd 4 ,
143.Xr da 4
144.Sh HISTORY
145The
146.Nm
147utility first appeared in
148.Fx 7.0 .
149.Sh AUTHORS
150.An -nosplit
151The original implementation was done by
152.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org
153with minor improvements from
154.An Ulrich Sp\(:orlein Aq Mt uqs@FreeBSD.org .
155.Pp
156This manual page was written by
157.An Ulrich Sp\(:orlein .
158.Sh BUGS
159Reading from media where the sectorsize is not a power of 2 will make all
1601 MB reads fail.
161This is due to the DMA reads being split up into blocks of at most 128kB.
162These reads then fail if the sectorsize is not a divisor of 128kB.
163When reading a full raw audio CD, this leads to roughly 700 error messages
164flying by.
165This is harmless and can be avoided by setting
166.Fl b
167to no more than 128kB.
168.Pp
169.Nm
170needs to know about read errors as fast as possible, i.e., retries by lower
171layers will usually slow down the operation.
172When using
173.Xr cam 4
174attached drives, you may want to set kern.cam.XX.retry_count to zero, e.g.:
175.Bd -literal
176# sysctl kern.cam.ada.retry_count=0
177# sysctl kern.cam.cd.retry_count=0
178# sysctl kern.cam.da.retry_count=0
179.Ed
180.\".Pp
181.\"When reading from optical media, a bug in the GEOM framework will
182.\"prevent it from seeing that the media has been removed.
183.\"The device can still be opened, but all reads will fail.
184.\"This is usually harmless, but will send
185.\".Nm
186.\"into an infinite loop.
187