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