aboutsummaryrefslogtreecommitdiff
path: root/sbin/recoverdisk/recoverdisk.1
blob: 1661ab805b339dd1081f96dfa211f20e48bc9c76 (plain) (blame)
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
.\" Copyright (c) 2006 Ulrich Spoerlein <uspoerlein@gmail.com>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd January 5, 2012
.Dt RECOVERDISK 1
.Os
.Sh NAME
.Nm recoverdisk
.Nd recover data from hard disk or optical media
.Sh SYNOPSIS
.Nm
.Op Fl b Ar bigsize
.Op Fl r Ar readlist
.Op Fl s Ar interval
.Op Fl w Ar writelist
.Ar source
.Op Ar destination
.Sh DESCRIPTION
The
.Nm
utility reads data from the
.Ar source
file until all blocks could be successfully read.
If
.Ar destination
was specified all data is being written to that file.
It starts reading in multiples of the sector size.
Whenever a block fails, it is put to the end of the working queue and will be
read again, possibly with a smaller read size.
.Pp
By default it uses block sizes of roughly 1 MB, 32kB, and the native
sector size (usually 512 bytes).
These figures are adjusted slightly, for devices whose sectorsize is not a
power of 2, e.g., audio CDs with a sector size of 2352 bytes.
.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl b Ar bigsize
The size of reads attempted first.
The middle pass is roughly the logarithmic average of the bigsize and
the sectorsize.
.It Fl r Ar readlist
Read the list of blocks and block sizes to read from the specified file.
.It Fl s Ar interval
How often we should update the writelist file while things go OK.
The default is 60 and the unit is "progress messages" so if things
go well, this is the same as once per minute.
.It Fl w Ar writelist
Write the list of remaining blocks to read to the specified file if
.Nm
is aborted via
.Dv SIGINT .
.El
.Pp
The
.Fl r
and
.Fl w
options can be specified together.
Especially, they can point to the same file, which will be updated on abort.
.Sh OUTPUT
The
.Nm
utility
prints several columns, detailing the progress
.Bl -tag -width remaining
.It Va start
Starting offset of the current block.
.It Va size
Read size of the current block.
.It Va len
Length of the current block.
.It Va state
Is increased for every failed read.
.It Va done
Number of bytes already read.
.It Va remaining
Number of bytes remaining.
.It Va "% done"
Percent complete.
.El
.Sh EXAMPLES
.Bd -literal
# recover data from failing hard drive ad3
recoverdisk /dev/ad3 /data/disk.img

# clone a hard disk
recoverdisk /dev/ad3 /dev/ad4

# read an ISO image from a CD-ROM
recoverdisk /dev/cd0 /data/cd.iso

# continue reading from a broken CD and update the existing worklist
recoverdisk -r worklist -w worklist /dev/cd0 /data/cd.iso

# recover a single file from the unreadable media
recoverdisk /cdrom/file.avi file.avi

# If the disk hangs the system on read-errors try:
recoverdisk -b 0 /dev/ad3 /somewhere

.Ed
.Sh SEE ALSO
.Xr dd 1 ,
.Xr ada 4 ,
.Xr cam 4 ,
.Xr cd 4 ,
.Xr da 4
.Sh HISTORY
The
.Nm
utility first appeared in
.Fx 7.0 .
.Sh AUTHORS
.An -nosplit
The original implementation was done by
.An Poul-Henning Kamp Aq phk@FreeBSD.org
with minor improvements from
.An Ulrich Sp\(:orlein Aq uqs@FreeBSD.org .
.Pp
This manual page was written by
.An Ulrich Sp\(:orlein .
.Sh BUGS
Reading from media where the sectorsize is not a power of 2 will make all
1 MB reads fail.
This is due to the DMA reads being split up into blocks of at most 128kB.
These reads then fail if the sectorsize is not a divisor of 128kB.
When reading a full raw audio CD, this leads to roughly 700 error messages
flying by.
This is harmless and can be avoided by setting
.Fl b
to no more than 128kB.
.Pp
.Nm
needs to know about read errors as fast as possible, i.e. retries by lower
layers will usually slow down the operation.
When using
.Xr cam 4
attached drives, you may want to set kern.cam.XX.retry_count to zero, e.g.:
.Bd -literal
# sysctl kern.cam.ada.retry_count=0
# sysctl kern.cam.cd.retry_count=0
# sysctl kern.cam.da.retry_count=0
.Ed
.\".Pp
.\"When reading from optical media, a bug in the GEOM framework will
.\"prevent it from seeing that the media has been removed.
.\"The device can still be opened, but all reads will fail.
.\"This is usually harmless, but will send
.\".Nm
.\"into an infinite loop.