Savehd7 saves a potentially damaged harddisk partition to an image
file. Savehd7 works for all filesystems. Calling Savehd7 with -h
gives some helping explanations.
Rationale
Harddisks are not 100% reliable and over time they can acquire bad
blocks (which cannot be fixed by the firmware). Reading a bad block
will cause the operating system to report an error or to return
garbage. Writing to a damaged partition can even cause the filesystem
to become corrupt. For this reason a file system checker should not
be used when there are read or write errors. To fix the filesystem it
is necessary to copy the whole partition to a file. Tools like 'cp'
or 'cat' are unusable to copy a damaged partition, since they will
abort on a read error. With conv=noerror 'dd' will proceed, but it
will just try to copy all blocks sequentially. A smarter approach
which jumps over bad blocks and maintains a list of bad block areas
would be helpful.
The Savehd7 program is designed to copy from a device file to a disk
image file even when read errors occur. It will try to copy as much
as possible and leave the unreadable blocks filled with zero bytes.
The file system checker can fix the saved disk image afterwards.
Finally the saved and repaired disk image file can be mounted with
the loop mount feature (which can mount a file as if it is a device).
Savehd7 tries to jump over bad blocks to reach a high rate of good
blocks in relative small time. In later phases it will try to shrink
the areas with possible bad blocks without trying to read bad blocks
too much. This way the rate of good blocks is increased without
spending too much time. Just the final phase will try to read all
blocks still marked as bad.
Savdhd7 maintains a list of potential bad areas and the processing
state. It can be paused by pressing a key and is able to continue
afterwards. This way the partition image can be mounted much
earlier. When a read only mount was used the saving process can
continue afterwards.
Usage
Several conditions must be fulfilled to use Savehd7:
- Operating systems without device files are not supported.
- To get access to the device file Savehd7 needs to be started as
superuser.
- Nothing should be mounted on the device file processed by
Savehd7.
- Programs which possibly change the device file such as
filesystem checkers should not run in parallel to Savehd7.
- There must be enough free space on the destination device
to copy the whole partition.
When Savehd7 is called it asks for the device file which should be
used as input:
root@penguin:~# /home/tm/seed7_5/prg/savehd7
Savehd7 Version 2.0 - Save a possibly damaged harddisk partition
Copyright (C) 2006, 2009 Thomas Mertes
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Savehd7 is written in the Seed7 programming language
Homepage: http://seed7.sourceforge.net
Use 'savehd7 -h' to get more information
Please enter the conditions to save the partition:
Input file name:
After entering e.g. /dev/sda3 (and pressing enter) it asks
for the output file:
Output file name:
After entering e.g. sda3 (and pressing enter) it writes
information about the current state and asks for confirmation:
Conditions to save the partition:
Input file name: /dev/sda3
Input file size: 60620313600
Output file name: sda3
State: Nothing saved
Should the save start (type 'Yes' to confirm)?
After entering Yes (and pressing enter) it starts the
saving process:
Processing - Press any key to pause (may take some time to react)
progress: okay: bad blks: fixed: bad bytes:
copy 0.0000% 0.0000% 0.0000% 0.0000% 0
The last line is updated to document the progress:
Processing - Press any key to pause (may take some time to react)
progress: okay: bad blks: fixed: bad bytes:
copy 2.6568% 2.6568% 0.0000% 0.0000% 0
The terms of the progress description are:
| copy |
| The current saving phase. Phases are:
copy, improve, examine and fix. |
| progress |
| The progress of the current phase. |
| okay |
| Percentage of data found okay. |
| bad blks |
| Percentage of bad blocks found. |
| fixed |
| Percentage of fixed potential bad blocks. |
| bad bytes |
| Bytes in potential bad areas. |
Operating systems usually retry to read bad blocks again and again
in the hope to succeed finally. Therefore copying from a damaged
harddisk can take very long (many hours even up to several days).
When Savehd7 is processing it can be interrupted by pressing any
key:
Processing - Press any key to pause (may take some time to react)
progress: okay: bad blks: fixed: bad bytes:
copy 11.5099% 11.5009% 0.0089% 0.0000% 5431296
Copy paused - To continue restart the program
root@penguin:~#
Since the OS spends so much time reading bad blocks it may take
some time until Savehd7 has a chance to save the processing state
and exit afterwards. Savehd7 should not be interrupted with
control-C or some other signal, since this prevents saving the
processing state. When Savehd7 is restarted it is prepared to
continue at the position where it was interrupted:
root@penguin:~# /home/tm/seed7_5/prg/savehd7
Savehd7 Version 2.0 - Save a possibly damaged harddisk partition
Copyright (C) 2006, 2009 Thomas Mertes
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Savehd7 is written in the Seed7 programming language
Homepage: http://seed7.sourceforge.net
Use 'savehd7 -h' to get more information
Conditions to save the partition:
Input file name: /dev/sda3
Input file size: 60620313600
Output file name: sda3
Output file size: 6977368064
State: Copy - 11.5099% done
Total bad bytes: 5431296
Should the bad areas be listed (Y/N/Q)?
When answering 'Y' Savehd7 writes a list of
potential bad areas:
List of bad areas:
position size
1610678273 983040
1744863233 1015808
1879117825 978944
2147618817 913408
2281832449 917504
2416001025 61440
2550255617 24576
2818605057 110592
2952847361 86016
3087093761 57344
3221270529 98304
3355521025 65536
3489746945 57344
6442532865 61440
Should the save continue (type 'Yes' to confirm)?
After entering Yes Savehd7 continues the saving process.