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 October 1, 2013 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 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 w Ar writelist 72Write the list of remaining blocks to read to the specified file if 73.Nm 74is aborted via 75.Dv SIGINT . 76.El 77.Pp 78The 79.Fl r 80and 81.Fl w 82options can be specified together. 83Especially, they can point to the same file, which will be updated on abort. 84.Sh OUTPUT 85The 86.Nm 87utility 88prints several columns, detailing the progress 89.Bl -tag -width remaining 90.It Va start 91Starting offset of the current block. 92.It Va size 93Read size of the current block. 94.It Va len 95Length of the current block. 96.It Va state 97Is increased for every failed read. 98.It Va done 99Number of bytes already read. 100.It Va remaining 101Number of bytes remaining. 102.It Va "% done" 103Percent complete. 104.El 105.Sh EXAMPLES 106.Bd -literal 107# recover data from failing hard drive ada3 108recoverdisk /dev/ada3 /data/disk.img 109 110# clone a hard disk 111recoverdisk /dev/ada3 /dev/ada4 112 113# read an ISO image from a CD-ROM 114recoverdisk /dev/cd0 /data/cd.iso 115 116# continue reading from a broken CD and update the existing worklist 117recoverdisk -r worklist -w worklist /dev/cd0 /data/cd.iso 118 119# recover a single file from the unreadable media 120recoverdisk /cdrom/file.avi file.avi 121 122# If the disk hangs the system on read-errors try: 123recoverdisk -b 0 /dev/ada3 /somewhere 124 125.Ed 126.Sh SEE ALSO 127.Xr dd 1 , 128.Xr ada 4 , 129.Xr cam 4 , 130.Xr cd 4 , 131.Xr da 4 132.Sh HISTORY 133The 134.Nm 135utility first appeared in 136.Fx 7.0 . 137.Sh AUTHORS 138.An -nosplit 139The original implementation was done by 140.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org 141with minor improvements from 142.An Ulrich Sp\(:orlein Aq Mt uqs@FreeBSD.org . 143.Pp 144This manual page was written by 145.An Ulrich Sp\(:orlein . 146.Sh BUGS 147Reading from media where the sectorsize is not a power of 2 will make all 1481 MB reads fail. 149This is due to the DMA reads being split up into blocks of at most 128kB. 150These reads then fail if the sectorsize is not a divisor of 128kB. 151When reading a full raw audio CD, this leads to roughly 700 error messages 152flying by. 153This is harmless and can be avoided by setting 154.Fl b 155to no more than 128kB. 156.Pp 157.Nm 158needs to know about read errors as fast as possible, i.e. retries by lower 159layers will usually slow down the operation. 160When using 161.Xr cam 4 162attached drives, you may want to set kern.cam.XX.retry_count to zero, e.g.: 163.Bd -literal 164# sysctl kern.cam.ada.retry_count=0 165# sysctl kern.cam.cd.retry_count=0 166# sysctl kern.cam.da.retry_count=0 167.Ed 168.\".Pp 169.\"When reading from optical media, a bug in the GEOM framework will 170.\"prevent it from seeing that the media has been removed. 171.\"The device can still be opened, but all reads will fail. 172.\"This is usually harmless, but will send 173.\".Nm 174.\"into an infinite loop. 175