Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Ddrescue-helper.sh – A bash script for GNU ddrescue (github.com/c-o-pr)
14 points by _wire_ 7 months ago | hide | past | favorite | 2 comments
ddrescue-helper.sh is a bash script to make running GNU ddrescue easier.

Do you have a spinning drive with read errors that you can't access?\ Do you need to rescue a drive, partition, or file from read errors?

ddrescue-helper.sh might be useful.

This is a pure bash script that hooks you up to the majesty that is GNU ddrescue, and makes it more useful.

For Linux and macOS.

Rescue... - device-to-device - device-to-file (image) - file-to-file

Consistency checks help avoid user mistakes, such as trying to place the domain map on a target device, or targeting the boot drive.

Auto persistent un-mount via /etc/fstab ensures rescue integrity.

Ddrescue's domain-map file and read-rate logs are placed in a directory named by the user.

Once you have a ddrescue domain map, a REPORT function lists files affected by read errors and slow-reads for supported filesystems...\ Linux: NTFS, ext2/3/4, HFS+\ macOS: HFS+.

Making a device or file copy is the best way to rescue. But if you need to work in situ with a filesystem or file that contains bad blocks, this helper offers a ZAP function that uses the domain map to write device blocks with read errors to attempt to make the blocks readable. This can regain access to an unreadable file, or make an un-mountable filesystem accessible, aiding further forensics (the data in the bad blocks are gone, but gaining device access may still be valuable).

An -K option allows ZAP of 4K blocks, for advanced format drives, instead of the default 512-byte block. This option may encourage the drive to re-allocate a bad sector.

(ZAP doesn't rely on hdparm, it uses dd(1) to target single blocks.)

A PLOT function uses gnuplot to render the GNU ddrescue read-rate log as a simple graph at the terminal, helping you assess device health.

By rescuing (COPYING) to /dev/null instead of a proper destination, you can SCAN a source to create the domain-map and read-rate log without replicating to another device. This lets you REPORT, ZAP, and PLOT a source without need for a target device-- maybe you don't have a spare.

If nothing else, a bit assistance running GNU ddrescue might be just the ticket.

DOCUMENTATION:

- The github README.md - Built-in help. (-h) - A LinkedIn article describing the helper's use:

https://www.linkedin.com/feed/update/urn:li:activity:7177497...

WARNING! This script has so far only been tested by me and mistakes due to maker myopia are likely. Plus bash is a can'o'worms!

While I believe this helper is not fundamentally dangerous, try it in a situation that's low stakes to start. There's a time for disaster later.

Also try to overlook that a huge bash script seems like an epic security hazard.

If something goes wrong, you should've voted for Kodos.

I would appreciate laments about the approach and code.

The github README.md contains thoughts about many concerns & improvements.\ (see TODOs at the end.)

I think the most gross part of this script is the mainline option processing, so pointers to idioms for smarter option processing will be appreciated. But beat me over the head in any way you like.

I am a github noob so I have no idea how collaboration works over there, but I'm ready to learn.

I truly enjoy the nightmare that is the Unix shell. So I have no intention of rewriting this in a more palatable language. I just wanted to hack together a tool to help me work with failing drives and this script took on a life of its own.

Blame these guys:

AT&T The UNIX System: Making Computers More Productive (1982)

https://www.youtube.com/watch?v=tc4ROCJYbm0

I like to think that old K & R and KenT would have only dreamed of shell utility that is this byzantine.

With any luck this code will soon be polluting a LLM.




Just in case someone reading this, anyone know what block-size one should use for ddrescue on a DVD? Sectors are 2kiB, but are grouped into ECC groups of 32kiB. Is it possible to read a single sector without error without also reading the entire ECC group without error?


I'm ignorant on the topic, but will observe that ultimately a block is a hardware construct for precisely such reasons as error correction. The way you've formed the question, it sounds like the answer will be no.

But maybe there's another way of looking at it?

This writeup discusses some features of DVD "raw" access (a figure of speech) and an approach to accessing data at lowest level possible with drive logic.

https://debugmo.de/2007/07/read-your-dvds-the-raw-way/?tl7




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: