Skip to content
/ dd_rescue Public

Unofficial git repository tracking dd_rescue source package from Kurt Garloff

License

Notifications You must be signed in to change notification settings

vaab/dd_rescue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README file for dd_rescue
=========================
(c) garloff@suse.de, 10/99, GNU GPL


Description of dd_rescue
------------------------
Like dd, dd_rescue does copy data from one file or block device to another.
You can specify file positions (called seek and Skip in dd).

There are several differences:
* dd_rescue does not provide character conversions.
* The command syntax is different. Call dd_rescue -h.
* dd_rescue does not abort on errors on the input file, unless you specify a
  maximum error number. Then dd_rescue will abort when this number is
  reached.
* dd_rescue does not truncate the output file, unless asked to.
* You can tell dd_rescue to start from the end of a file and move backwards.
* It uses two block sizes, a large (soft) block size and a small (hard) block
  size. In case of errors, the size falls back to the small one and is
  promoted again after a while without errors.


Purpose of dd_rescue
--------------------
The latter three features make it suitable for rescuing data from a medium
with errors, i.e. a hard disk with some bad sectors.
Why?
* Imagine, one of your partitions is crashed, and as there are some hard
  errors, you don't want to write to this hard disk any more. Just getting
  all the data off it and retiring it seems to be suitable. However, you
  can't access the files, because the file system is damaged.
* Now, you want to copy the whole partition into a file. You burn it on
  DVD, just to never lose it again.
  You can setup a loop device, and repair (fsck) it and hopefully are able
  to mount it.
* Copying this partition with normal Un*x tools like cat or dd will fail, as
  those tools abort on error. dd_rescue instead will try to read and if it
  fails, it will go on with the next sectors. The output file naturally will
  have holes in it, of course. You can write a log file, to see where all
  these errors are located.
* The data rate drops very low, when errors are encountered. If you
  interrupt the process of copying, you don't lose anything. You can just
  continue at any position later. The output file will just be filled in
  further and not truncated as with other Un*x tools.
* If you have one spot of bad sectors within the partition, it might be a
  good idea, to approach this spot from both sides. Reverse direction copy
  is helpful.
* The two block sizes are a performance optimization. Large block sizes
  result in superior performance, but in case of errors, you want to try
  to salvage every single sector. So hardbs is best be set to the hardware
  sector size (most often 512 bytes) and softbs to a large value, such as
  the default 64k or even larger. (When doing buffered reads on Linux, you
  might as well set the hardbs to 4k resp. page size, as the kernel will
  read that much at a time anyway.)


Does it actually work?
----------------------
Yes. I wrote a predecessor program (dw) and saved most of the data of two
crashed hard disks. The current program also helped me secure the data of
one beginning to have problems.

A good approach is first to copy all those sectors which are working without
problems. For this, you approach the critical regions from both sides.
It is a good idea to take notes on which sectors are still missing.
If you are lucky, you will be able to reconstruct your file system, already.
Otherwise, you should try to fill in more of the critical sectors. Some of
them might be readable and provide some more useful data. This will take a
long time, however, depending on how hard your hard disk tries to read bad
sectors.

You can overwrite a disk or a partition with its own data -- the drive's
reallocation procedure might result in the whole disk to be readable again
afterwards (yet the replaced sectors will be filled with 0). If you want
to use dd_rescue for this purpose, please use O_DIRECT and a block size of 
4096. (Late 2.6 and 3.x kernels allow a block size of 512b as well, so you
might be able to recover a few sectors more.)

dd_rhelp from LAB Valentin does automate some of this, so you might want to
give that a try.


Limitations
-----------
The source code does use the 64bit functions provided by glibc for file
positioning. However, your kernel might not support it, so you might be
unable to copy partitions larger then 2GB into a file.
This program has been written using Linux and only tested on a couple of
Linux systems. It should be possible to port it easily to other Un*x
platforms, but I have not tried.
Currently, the escape sequence for moving the cursor up is hard coded in the
sources. It's fine for most terminal emulations (including vt100 and linux),
but it should use the terminal description database instead.
Due to the way the program works (input and output are always written to the
designated position, i.e. a seek() is done before the I/O operation is
actually performed), char devices can not be read from or written to.
Therefore you can't redirect output to stdout.
This limitation has been lifted in version 1.10; though with non-seekable
in- and our output, you can't recover from errors on that channel.


Goodies
-------
dd_rescue has a few nifty features:
* A progress bar (since 1.17) and an estimated time to go.
* Logging of bad blocks into a log file (-l) or for a file to be 
  consumed by mke2fs (-b) when creating a file system.
  Overall, dd_rescue keeps you well informed where it is ...
* Optional use of fallocate -P to tell the target filesystem how much
  space it should reserve. (Some filesystems support this to avoid
  fragmentation -- since 1.19.)
* File copy without copying data into userspace buffers using splice
  on Linux) option -k, since 1.15).
* Optionally, dd_rescue checks whether read blocks are empty and does
  create sparse output files (option -a, since 1.0x, warns when target
  is a block device or an existing file since 1.21 -- only ignore this
  warning if your target device has been initialized with zeros 
  previously.)
* Support for direct I/O; this will circumvent kernel buffering and
  thus will expose medium errors right away. With 
  dd_rescue -d -D -A bdev bdev you will read a bdev and write
  things back to itself -- if some unreadable blocks are found, those
  will be filled with zeros -- the defect management of your hardware
  might result in all of your disk to be usable again afterwards,
  though you'll have lost a few sectors. (You should still look out
  for a new disk: When it rains, it pours.)
* When overwriting a file with itself (but with some offsets, i.e.
  moving data inside a file), dd_rescue figures out whether it
  needs to do this backwards (-r) to not end up destroying the data.


Copyright
---------
This little program is protected by the GNU General Public License (GPL). 
(See the file COPYING, which probably exists a few hundred times on your
 computer. If not: I will send you one.)
To summarize:
* You are free to use this program for anything you like. However, if you
  release a program that uses code from this program, your program must be
  released under the terms of the GNU GPL again.
* You are allowed to put this program on CDs or other media and charge a 
  fee for copying and distributing it. You have to provide the source code
  (or a written offer to provide it) and the GPL text, too, then.
* There is no warranty whatsoever for this program. If it crashes your
  disks, it's at your risk.
* This summary does not replace reading the GNU GPL itself.


Feedback
--------
... is always welcome. Just send me an e-mail.
The web page of this program, BTW, is 
http://www.garloff.de/kurt/linux/ddrescue/


Have fun! 
(Hopefully you don't need this program. But if you do: I wish it will be
 of some help.)


Kurt Garloff <kurt@garloff.de>, 2000-08-30
$Id$

About

Unofficial git repository tracking dd_rescue source package from Kurt Garloff

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages