+GNU licensing accompanion
[badblock-guess.git] / README
1 $Id$
2
3
4 badblock-guess: Quickly recover most of the data from a damaged disk
5
6
7 Purpose
8 -------
9
10 badblock-guess will try to find all readable sectors of the disk in minimal
11 time. It is similiar to:
12         dd if=<src_dev> of=<dst_dev> bs=512 conv=noerror,sync
13
14 but dd(1) solution can last for many weeks/months on heavily corrupted disk
15 media as each bad sector attempted to be read costs about 5secs (your disk
16 bad-blocks performance may significantly vary). badblock-guess tries to first
17 find and recover most of the data from healthy zones of the disk and later it
18 will start trying to recover smaller bits of information spread between/around
19 badblock zones - the principle of its operation is the fact that badblocks
20 usually occur in chunks. If you don't user-terminate badblock-guess and leave
21 it to finish completely itself, its execution time should be approx. the same
22 as for dd(1). You may also use it to guess the remaining execution time as
23 during its later execution phases it will be showing the remaining number of
24 sectors ("TODO=x") while most of them are probably badblocks in this phase of
25 execution.
26
27 This program will not recover data of any sector with failing read command.
28 If dd(1) command above finishes for you in a reasonable time, you don't need
29 this program. No special read methods are used. No vendor-specific dependencies
30 exist. No IDE, SCSI or any other specific device is required.
31
32
33 License
34 -------
35
36 GNU GENERAL PUBLIC LICENSE, Version 2, June 1991.
37
38 See the file COPYING for its details. It is also available at:
39         http://www.gnu.org/licenses/gpl.txt
40
41
42 Usage
43 -----
44
45 Syntax: badblock-guess <src_dev> [<dst_dev (OVERWRITTEN & DESTROYED!!!)>]
46
47 Possible device cases (watch out for <src_dev> vs. <dst_dev> differences!):
48
49         No <dst_dev> is specified: Just the <src_dev> is scanned for errors and
50                 the detected badblocks list is output.
51
52         <src_dev> is a harddrive (/dev/hdc): Other harddrive of equal or higher
53                 capacity is recommended
54
55         <src_dev> is a partition (/dev/hdc1): Partition on any other physical
56                 drive in the system with the exactly same partition size is
57                 recommended
58
59         <dst_dev> is a file: File must exist but it will be enlarged when
60                 needed. Commands:
61                         rm -f /tmp/hdc1.img; touch /tmp/hdc1.img
62                 are recommended to specify file "/tmp/hdc1.img" for <dst_dev>
63
64 All the numbers are always expressed as sector (that means 512 bytes)
65 number/count!
66
67 Never terminate badblock-guess by CTRL-C or kill(1) if you want to utilize its
68 results - always use 'f' followed by ENTER ('f' for 'finish'). You may not see
69 'f' while typing it - type it blindly (without quotes - just the one letter!).
70 During finishing the program will produce the badblocks list output to its
71 stdout while it will be clearing the 'bad' or 'not-yet-done' zones of the
72 target disk (if any specified).
73
74 TODO: Resuming of the operation from the badblocks list to continue the
75       scanning is not yet implemented.
76
77
78 hdparm
79 ------
80
81 Although not required it is strongly recommended to turn of drive readahead
82 during severe disk failure recoveries. You can use
83
84         /sbin/hdparm -A0a0 /dev/hdX     (or /dev/sdX etc.)
85
86 for your drive to do it. You may need to install some extra package with
87 hdparm(8) for your Linux distribution.
88
89 Be aware that the disk performance will be critically hit - you may expect read
90 performance about 90KB/s (approx. 7.5GB/24hours if no badblocks read retrying
91 is needed). YMMV.
92
93
94 Compilation
95 -----------
96
97 Type:
98         make
99
100 And you should have now the binary file "badblock-guess" compiled out.
101 You may need to install the following packages of your Linux distribution:
102         e2fsprogs, e2fsprogs-devel
103         glib, glib-devel        (this is NOT glibc!)
104         other standard C compilation tools and libraries...
105
106 Compiled out binary is fully statically linked, you can bring it with you on
107 the floppy everywhere (running Linux is still required, of course!).
108
109
110 Operation description
111 ---------------------
112
113 During its run it will update its progress line. All the numbers are always
114 expressed as sector (that means 512 bytes) number/count.
115
116         @342342/819223,TODO=8192,bad=0,largest=8192,hunks=1
117          ^A     ^B          ^C       ^D        ^E         ^F
118
119 A=currently reding sector 342342 ...
120 B=... out of total sector 819223 of the disk (or partition)
121 C=8192 secters weren't yet attempted to be read
122 D=0 sectors were found with proof of read failure
123 E=currently read hunk of 8192 sectors
124  =also there is a maximum size of hunk 8192 sectors
125 F=total remaining hunks to be processed
126
127 Initially there is just one hunk (0-media_size) to be read. When no errors on
128 the disk are found, this one hunk is finished and no output (bad sectors list)
129 is generated.
130
131 When we find bad a sector, we divide our todo-listed hunks by the schema:
132
133 > successfuly read 10 ->[1 bad]<todo 1><todo 2><todo 4><todo 9><todo 19>|end
134
135 We always read the biggest hunk "todo", "todo" hunks of the size are read in
136 backwards order (to approach the found bad blocks from the other side).
137
138 In this case the program would start with the status line (*):
139
140 @27/46,TODO=35,bad=1,largest=19,hunks=5
141  ^A ^B      ^C     ^D        ^E       ^F
142
143 A=we start reading the first sector of the largest hunk <todo 19> (10+1+1+2+4+9)
144 B=total number of sectors on the disk (10+1+1+2+4+9+19)
145 C=still have to read all <todo> hunks (1+2+4+9+19)
146 D=we found just one confirmed bad sector <bad 1> (1)
147 E=the largest hunk "todo" on the disk is <todo 19> (19)
148 F=total number of the remaining "todo" hunks <t1><t2><t4><t9><t19> (1+1+1+1+1)
149
150 If you terminate badblock-guess run (by 'f' key, see above!), you can be sure
151 that you will loose the data of at most <largest> sectors after any bad sector
152 found. But you still can loose <TODO> sectors of data.
153
154 (*) The status line is printed once per a second and thus in real you can't
155     predict the exact states of the progress status line, of course.
156
157
158 Output badblock list format
159 ---------------------------
160
161 Output badblock list has form
162
163 first_sector-behind_last_sector <tab>   ;<comments>
164
165 "behind_last_sector" is last_bad_sector+1. Thus single bad sector would be:
166         5678-5679
167
168 The following three types of output lines can occur. The first one is just
169 a shortcut for the second+third - such output is chosen when TODO blocks are
170 consequently following BAD blocks.
171
172 1000-9192       ;BAD=100, TODO(@1100-@9192)=8092
173 1000-1100       ;BAD=100
174 1100-9192       ;TODO=8092