RECOVERDISK(1)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’Ύ RECOVERDISK(1) β€” the group-chat guide πŸ’Ύ

okay so bestie, buckle up, because this one is about the little tool called recoverdisk from the General Commands Manual section 1, and it literally rescues your data from disks that are actively dying. iconic behavior honestly. 🫢


✨ NAME ✨

recoverdisk β€” recover data from disk-like devices. that's it, that's the whole vibe. it goes and gets your bytes back. πŸ’…


🌸 SYNOPSIS 🌸

recoverdisk [-b bigsize] [-i interval] [-r readlist] [-s interval]
            [-u pattern] [-v] [-w writelist] source [destination]

πŸ¦‹ DESCRIPTION πŸ¦‹

So recoverdisk reads all the data from source, and it just keeps retrying read operations until they succeed. no cap, it will sit there and try again and again. if you give it a destination, then everything it reads gets written there too. πŸŽ€

The internal work-list can be saved and loaded, which means recoverdisk sessions can be resumed β€” super handy when, like, a marginal source hard-disk just shuts down mid-recovery. rude of it, but okay. 😭

The work-list starts out initialized with a single item that covers the entire source, and recoverdisk always chips away at the first item on the work-list. first in line, first served, periodt.

When a read succeeds, that part of the current chunk is eliminated from the work-list. slay. ✨

When a read fails, that part of the item gets appended to the worklist as a separate item, and it'll be retried in due order. and if destination is specified, the corresponding range gets filled with '_UNREAD_' so you know exactly which bits ghosted you. πŸ’€

The first pass attempts to read everything in "big-size" chunks, the second pass reads in "medium-size" chunks, and the third and subsequent passes read in "small-size" chunks. this three stage process is an attempt to optimize the case where only a few bad blocks exist on source. and if too many read-errors show up, recoverdisk will fall back to smaller sizes sooner β€” it's adaptive, it's giving main character energy honestly.

The three sizes default to 128kB (or less if the sector size does not divide 128kB cleanly β€” think audio CD media, iykyk), and the reported DIOCGSTRIPESIZE and DIOCGSECTORSIZE respectively.

The options are as follows:


πŸ’œ OPTIONS πŸ’œ

  • -b bigsize β€” the size of reads attempted in the first pass. the chunky era. πŸ“
  • -m mediumsize β€” the size of reads attempted in the second pass. the middle child. 🌈
  • -s smallsize β€” the size of reads attempted in the third and subsequent passes. tiny but mighty. 🧚
  • -r work-list-file β€” read the work-list from a file. resuming your saga. ⭐
  • -w work-list-file β€” write the work-list to a file when a read succeed, but at most once every minute. (yes, "succeed", that's verbatim, we don't fix what the manpage wrote πŸ’…) this is your safety net bestie, use it.
  • -l log-file β€” each successful read is logged with timestamp, offset and length. receipts. πŸ’–
  • -t totalsize β€” how many bytes should be recovered. the default is what DIOCGMEDIASIZE reports for character and block devices, or st_size if source is a regular file.
  • -i pause β€” sleep(3) this long between reads. this reduces the load on the source device and the system in general. be gentle with it. πŸŽ€
  • -p pause β€” sleep(3) this long whenever a read fails. this makes the source device look less sick to the operating system. gaslight gatekeep girlboss, but for hardware. πŸ™ˆ
  • -u pattern β€” by default blocks which cannot be read are filled with the pattern '_UNREAD_' in the output file. this option can be used to specify a different pattern. if the pattern is the empty string, nothing is written.
  • -v β€” produce a detailed progress report with ANSI escapes and UTF-8. pretty colors, pretty bytes. 🌸

Also super important: recoverdisk can be aborted with SIGINT, but with a sick source it may take up to several minutes before the current read operation returns from the kernel. so like… press Ctrl+C and then go make a snack, it's not ignoring you, it's just stuck in the kernel. 😭


πŸ”₯ EXAMPLES πŸ”₯

# check if all sectors can be read on a USB stick:
recoverdisk /dev/da0

# recover data from failing hard drive ada3
recoverdisk /dev/ada3 /data/disk.img

# clone a hard disk
recoverdisk /dev/ada3 /dev/ada4

# 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

πŸ‘‘ PRACTICAL ADVICE πŸ‘‘

In Datamuseum.dk recoverdisk has been used to recover all sorts of data-media for two decades, and here are some things they've learned (elder wisdom, fr fr):

  • Interacting with failing hardware has a tendency to crash machines, so it is always a good idea to use the --w -work-list-file so that it is possible to continue. (yep, that's written exactly like that in the original, we are not touching it ✨)
  • When attempting to recover hard to read data from failing hard disks, it pays to pamper the drive as much as possible:
  • It is generally best to keep the drive in it's usual physical orientation, but it can also help to try other orientations. (again β€” verbatim, "it's" and all. we respect the elders 🫢)
  • Insulate the drive from external vibrations.
  • Keep the drive cool with a fan.
  • If possible, power the drive from a laboratory power supply.
  • Do not loose patience: Let recoverdisk run as long as possible. (yes, "loose". iconic typo. let it run forever honestly πŸ•―οΈ)
  • (S)ATA controllers do not handle failing disks well, if this is a problem, use a USB-(S)ATA adapter instead.
  • The recoverdisk source code is deliberately written to be easily portable to older versions of FreeBSD and to other operating systems.
  • If you need to read ST-506, RLL or ESDI drives FreeBSD 3.5.1 is a good compromise.
  • Sometimes forcing the disk to step between reads helps. Since recoverdisk process the work-list in the order it is read, this can be accomplished by sorting the work-list with something like:
% sort +0.5
  • By default the CAM layer will retry failing read operations, but that will get stuck on the bad sectors for long time and delay recovering what actually can be read from a rapidly failing drive. In that situation, set the appropriate
kern.cam.*.retry_count

sysctl to zero.

  • For floppies and un-zoned hard disks (ST-506 to early IDE) set -b bigsize to the size of a track.

🧚 SEE ALSO 🧚

dd(1), ada(4), cam(4), cd(4), da(4)


⭐ HISTORY ⭐

The recoverdisk utility first appeared in FreeBSD 7.0 because Somebodyβ„’ forgot to make a backup copy. πŸ’€ not me tho. anyway. a whole tool, born from one person's oopsie. we love to see it.


🌈 AUTHORS 🌈

The original implementation was done by Poul-Henning Kamp <phk@FreeBSD.org> with minor improvements from Ulrich SpΓΆrlein <uqs@FreeBSD.org>.

This manual page was originally written by Ulrich SpΓΆrlein.


πŸ’€ BUGS πŸ’€

  • If a failing device causes the machine to crash, there is a risk that a chunk might have been successfully read and removed from the work-list, but not yet flushed to the destination. 😬
  • recoverdisk calls fdatasync(3) on the destination before writing the work-list to a temporary file, and calls it again on the temporary file before renaming it to the specified -w work-file-list filename. But even then things dont always work out. (yep, "dont". we keep it.)
  • recoverdisk should have an option for reconstructing the work-list from the destination by enumerating the -u pattern filled ranges.

πŸ’– kudos for making it to the end of the manpage bestie, you ate that. this page came from the Debian edition and it's dated April 3, 2020. now go save some data. mwah. πŸ’…βœ¨πŸŽ€
πŸ“¦ where this page comes from
  • freebsd 15.1: base 15.1
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms