hack のためのネタ帳, etc,,,

×
HDD 等のサルベージ用コピーツール

公式ページ

Tips

Options

お薦めは -S -d
スパース対応と、入力側のダイレクト読み込み
failed block が残った場合は、-M -A を付けると、failed block に再チャレンジできる。
デフォルトでは forwards と backwards を交互に行うようなので、forwards に固定したい場合は -u、backwards に固定したい場合は -u -R を追加するとよい。

Mapfile

status
?copying non-tried blocks
*trimming non-trimmed blocks
/scraping non-scraped blocks
-retrying bad sectors
Ffilling specified blocks
Ggenerating approximate mapfile
+finished

data block
?non-tried block
*failed block non-trimmed
/failed block non-scraped
-failed block bad-sector(s)
+finished block

詳細は以下

作業確認用 AWK script

64bit 推奨かも?

show_ddrescue_log.awk

#!/usr/bin/gawk -f
BEGIN {
  W = 64; // width of map
  
  addr = 0;
  s = "";
}

NF == 3 {
  n = strtonum($2) / 512;
  for (i = 0; i < n; i++) {
    s = s $3;
    if (W <= length(s)) {
      printf("%08x %s\n", addr, s);
      s = "";
      addr += W;
      
      # skip continuous lines
      continuous = int((n - i) / W);
      if (0 < continuous) {
        printf("<skip %d lines %s>\n", continuous, $3);
        addr += continuous * W;
        i    += continuous * W;
      }
    }
  }
}

END {
  printf("%08x %s\n", addr, s);
}

calc_ddrescue_log.awk

#!/usr/bin/gawk -f
BEGIN {
  bad_sector = non_split = non_trimmed = finished = non_tried = 0;
}

$3 == "-" {bad_sector  += strtonum($2);}
$3 == "/" {non_split   += strtonum($2);}
$3 == "*" {non_trimmed += strtonum($2);}
$3 == "+" {finished    += strtonum($2);}
$3 == "?" {non_tried   += strtonum($2);}

END {
  info("?", non_tried);
  info("+", finished);
  info("-", bad_sector);
  info("/", non_split);
  info("*", non_trimmed);
  info("-/*", bad_sector + non_split + non_trimmed);
}

function info(stat, size) {
  printf("%-3s: %17s bytes (%13s blocks)\n", stat, numsep(size), numsep(size / 512));
}
function numsep(v, _h, _l) {
  if (3 < length(v)) {
    _l = substr(v, length(v) - 2, 3);
    _h = substr(v, 0, length(v) - 3);
    return numsep(_h) "," _l;
  } else {
    return v;
  }
}

decimal_ddrescue_log.awk

#!/usr/bin/gawk -f
/^#/
!/^#/ {
  for (i = 1; i <= NF; i++) {
    if (match($i, /^0x/)) {
      $i = sprintf("%'18d", strtonum($i));
    }
  }
  print $0;
}

動作サンプル

$ ./show_ddrescue_log.awk W=64 ddrescue.log | tee map
00000000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<skip 969 lines +>
0000f280 ++++++++++++++++++++++++++++++++++++++++++++++++----------------
0000f2c0 -----------------------------+-+------+------------+-----+------
0000f300 --------+------------------+------+-----------------------+-+---
0000f340 -------+----------+----+-+------+----++-------------++-+-++-+---
0000f380 -----+++++++++++++++++++++++++++++++++++++++++++--++++----+--+-+
0000f3c0 ------------+-+---+-----------------+-----------+---------+-----
0000f400 +------+----++--------+--++++--+-++---+-+--++-+-----------+---+-
0000f440 ---+----------+------+-----+-----++----+--+--++-------------+---
0000f480 +--+---+++---++-++++++++++-++--++--++--+-+--+-+++++--++-+-+-++-+
0000f4c0 ++-+++-+---+++++++++-+++++++++++++-+-+++++-+++--+-++++++---+++++
0000f500 +---+++--+--++--+-+-+-----+++--+++-+---+--++++++---++---+-++++-+
0000f540 --++++-++-++-++--+-+--++---+--+++-+++++++--+++++++--++--++-++---
0000f580 +---+++--+-+++-+++--+--+-+-+++--+++-+-++++---+++---++++++++-+-++
0000f5c0 +---+-----++-+++-+++++++-++++-++++++++++++++-+-++--++++++-++++++
0000f600 ++++++--+-++++-+--+++++++++-++++++++++++++-++++-+++++++++-++++++
0000f640 +++-+-+-+-+++++-+++++-+-++--+++++-+++++++-+++-+++--++++-++++++++
0000f680 ++++++++-++++-++++++++++++++++++++++++++++++++++++++++++++++++++
0000f6c0 +++++++++++++++++++++++++++++++-+-+++++++++++++++++++++++-++++-+
0000f700 ++++++++++++++++-+++++++++++++++++++++++++++++++++-+++++-+++++++
0000f740 ++++++++++-++++++++++++++-++++++++++++-+++++++++++++++++++++++++
0000f780 +++-+++-+++++++++++++++++++++++++++-++++++++++++++++++++++++++-+
0000f7c0 +-+-+++++-++-+++++++++++-++++++++++-+-++++++++++++-+++++++++++-+
0000f800 +++++++++++++-+++++++++++-+++++++++++-++++++++++++++--++-+++++++
0000f840 ++++++++--+++++--+++++++-+++--+++++++++--+-+-++++++-+++++++--+++
0000f880 +++++++-++-+++-+++++++++++++++++++-+++++++++++++-+++++-++-+++-++
0000f8c0 ++++-++++--+++++++++++--+++++-+++-+-+++-+++-++++---+++-+++-+--++
0000f900 +---++-++++--+++++++++++-+-+-++--++++++-++-+++++-++++++-++++++--
0000f940 -++++++-+-+-+-++-+-++---++-+++++-++++++++++++++-+-+--+++-++---++
0000f980 ++++++++-+-+---++++-++++----+-+-+--++-++-+-/////////////////////
<skip 2 lines />
0000fa40 //////////////////////////////////////////////////////////////--
0000fa80 ////////////////////////////////////////////////////////////////
<skip 30 lines />
00010240 ///////////////////////////////////////////--///////////////////
00010280 ///////////////-++++++++++++++++++++++++++++++++++++++++++++++++
<skip 63 lines +>
00011280 ++++++++++++++++++++++++++++++++++++++++-///////////////////////
000112c0 ///////////////////////////////////////////////////////-++++++++
<skip 30522730 lines +>
74706d80 ++++++++++++++++++++++++++++++++++++++++++++++++
$ ./calc_ddrescue_log.awk ddrescue.log 
?  :                 0 bytes (            0 blocks)
+  : 1,000,203,348,992 bytes (1,953,522,166 blocks)
-  :           333,824 bytes (          652 blocks)
/  :         1,203,200 bytes (        2,350 blocks)
-/ :         1,537,024 bytes (        3,002 blocks)
$ ./decimal_ddrescue_log.awk ddrescue.log
# Mapfile. Created by GNU ddrescue version 1.23
# Command line: ddrescue /dev/sdm sdm.img sdm.log
# Start time:   2022-08-28 14:47:23
# Current time: 2022-08-28 14:48:38
# Copying non-tried blocks... Pass 1 (forwards)
# current_pos  current_status  current_pass
     2,586,968,064 ? 1
#      pos        size  status
                 0      2,063,601,664 +
     2,063,601,664             61,440 *
     2,063,663,104            327,680 ?
     2,063,990,784        522,977,280 +
     2,586,968,064     29,328,015,360 ?
タグ

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

Wiki内検索

フリーエリア

管理人/副管理人のみ編集できます

広告募集中