文書更新:2018年12月25日(火) 午後5時29分55秒

Home > 備忘録 > Linux > ddrescue コマンド( 5 )

fdisk で hdd が認識しない場合の確認方法

  1. dmesg を利用する
  2. [root@server]# dmesg | tail
    [142321.470038] usb 2-1.4: SerialNumber: 00000000000000000000
    [142321.473700] scsi host9: uas
    [142321.474630] scsi 9:0:0:0: Direct-Access     ST332041 8AS              0101 PQ: 0 ANSI: 6
    [142321.486130] sd 9:0:0:0: Attached scsi generic sg4 type 0
    [142321.486196] sd 9:0:0:0: [sdf] 625142448 512-byte logical blocks: (320 GB/298 GiB)
    [142321.487224] sd 9:0:0:0: [sdf] Write Protect is off
    [142321.487235] sd 9:0:0:0: [sdf] Mode Sense: 67 00 10 08
    [142321.487795] sd 9:0:0:0: [sdf] Write cache: enabled, read cache: enabled, supports DPO and FUA
    [142321.519407]  sdf: sdf1
    [142321.521549] sd 9:0:0:0: [sdf] Attached SCSI disk
  3. fdisk で領域を確保する
  4. [root@server]# fdisk /dev/sdf

device の切り離し

  1. 例えば /dev/sdf
  2. [root@server]# echo 1 > /sys/block/sdf/device/delete

ddrescue のインストールとヘルプ

  1. インストール
  2. [root@server]# dnf install ddresuce
  3. ヘルプ
  4. [root@server]# ddrescue --help
    	GNU ddrescue is a data recovery tool. It copies data from one file or block
    device (hard disc, cdrom, etc) to another, trying to rescue the good parts
    first in case of read errors.
    
    Always use a mapfile unless you know you won't need it. Without a mapfile,
    ddrescue can't resume a rescue, only reinitiate it. Be careful to not
    specify by mistake an old mapfile from an unrelated rescue.
    
    NOTE: In versions of ddrescue prior to 1.20 the mapfile was called
    'logfile'. The format is the same; only the name has changed.
    
    If you reboot, check the device names before restarting ddrescue.
    Don't use options '-F' or '-G' without reading the manual first.
    
    Usage: ddrescue [options] infile outfile [mapfile]
    
    Options:
      -h, --help                     display this help and exit
      -V, --version                  output version information and exit
      -a, --min-read-rate=<bytes>    minimum read rate of good areas in bytes/s
      -A, --try-again                mark non-trimmed, non-scraped as non-tried
      -b, --sector-size=<bytes>      sector size of input device [default 512]
      -B, --binary-prefixes          show binary multipliers in numbers [SI]
      -c, --cluster-size=<sectors>   sectors to copy at a time [128]
      -C, --complete-only            don't read new data beyond mapfile limits
      -d, --idirect                  use direct disc access for input file
      -D, --odirect                  use direct disc access for output file
      -e, --max-bad-areas=[+]<n>     maximum number of [new] bad areas allowed
      -E, --max-error-rate=<bytes>   maximum allowed rate of read errors per second
      -f, --force                    overwrite output device or partition
      -F, --fill-mode=<types>        fill blocks of given types with data (?*/-+l)
      -G, --generate-mode            generate approximate mapfile from partial copy
      -H, --test-mode=<file>         set map of good/bad blocks from given mapfile
      -i, --input-position=<bytes>   starting position of domain in input file [0]
      -I, --check-input-size         compare input file size with size in mapfile
      -J, --check-on-error           reread latest good sector after every error
      -K, --skip-size=[<i>][,<max>]  initial,maximum size to skip on read error
      -L, --loose-domain             accept unordered domain mapfile with gaps
      -m, --domain-mapfile=<file>    restrict domain to finished blocks in <file>
      -M, --retrim                   mark some failed blocks as non-trimmed
      -n, --no-scrape                skip the scraping phase
      -N, --no-sweep                 skip the sweeping phase
          --no-trim                  skip the trimming phase
      -o, --output-position=<bytes>  starting position in output file [ipos]
      -O, --reopen-on-error          reopen input file after every read error
      -p, --preallocate              preallocate space on disc for output file
      -P, --data-preview[=<lines>]   show some lines of the latest data read [3]
      -q, --quiet                    suppress all messages
      -r, --retry-passes=<n>         exit after <n> retry passes (-1=infinity) [0]
      -R, --reverse                  reverse the direction of all passes
      -s, --size=<bytes>             maximum size of input data to be copied
      -S, --sparse                   use sparse writes for output file
      -t, --truncate                 truncate output file to zero size
      -T, --timeout=<interval>       maximum time since last successful read
      -u, --unidirectional           run all passes in the same direction
      -v, --verbose                  be verbose (a 2nd -v gives more)
      -w, --ignore-write-errors      make fill mode ignore write errors
      -W, --compare-before-write     omit superfluous writes in rescue mode
      -x, --extend-outfile=<bytes>   extend outfile size to be at least this long
      -X, --max-read-errors=<n>      maximum number of read errors allowed
      -y, --synchronous              use synchronous writes for output file
      -Z, --max-read-rate=<bytes>    maximum read rate in bytes/s
          --ask                      ask for confirmation before starting the copy
          --bad-sector-data=<file>   treat sectors with <file> data as read errors
          --command-mode             execute commands from standard input
          --continue-on-errno=<n>[,<n>]  treat errno code <n> as non-fatal
          --cpass=<range>            select what copying pass(es) to run
          --delay-slow=<interval>    initial delay before checking slow reads [30]
          --log-events=<file>        log significant events in <file>
          --log-rates=<file>         log rates and error sizes in <file>
          --log-reads=<file>         log all read operations in <file>
          --mapfile-interval=[i][,i]   save/sync mapfile at given interval [auto]
          --max-slow-reads=<n>         maximum number of slow reads allowed
          --pause-on-error=<interval>  time to wait after each read error [0]
          --pause-on-pass=<interval>   time to wait between passes [0]
          --reset-slow               reset slow reads if rate rises above min
          --same-file                allow infile and outfile to be the same file
    
    Numbers may be in decimal, hexadecimal, or octal, may contain underscore
    separators between groups of digits, and may be followed by a SI or binary
    multiplier and 's' for 'sectors': 1_234_567kB, 4Kis, 0x1234_5678, 07_777.
    In rescue mode, '--size=output' uses the size of the output file or device.
    Time intervals have the format 1[.5][smhd] or 1/2[smhd].
    
    *Exit status*
    0 for a normal exit, 1 for environmental problems (file not found, invalid
    command-line options, I/O errors, etc), 2 to indicate a corrupt or invalid
    input file, 3 for an internal consistency error (e.g., bug) which caused
    ddrescue to panic.
    
    Report bugs to bug-ddrescue@gnu.org
    Ddrescue home page: http://www.gnu.org/software/ddrescue/ddrescue.html
    General help using GNU software: http://www.gnu.org/gethelp

HDDデータの完全消去

  1. /dev/sdg の完全消去。
  2. [root@server]# ddrescue -f /dev/zero /dev/sdg
  3. /dev/sdg に乱数を書き込む。
  4. [root@server]# ddrescue -f /dev/urandom /dev/sdg

HDDのコピー

  1. /dev/sdaから/dev/sdbに丸ごとコピーする。
  2. [root@server]# ddrescue -f -n /dev/sda /dev/sdb logfile
  3. MBRを「/dev/sdc」バックアップする。
  4. [root@server]# ddrescue -f -n -s 512 /dev/sda /dev/sdc logfile
  5. HDDをイメージファイルとしてバックアップをとる。
  6. [root@server]# ddrescue -f -n /dev/sda backup.img logfile
  7. HDDをイメージファイルとしてバックアップをとる。
  8. [root@server]# fdisk -l
    
    単位: セクタ (1 * 512 = 512 バイト)
    セクタサイズ (論理 / 物理): 512 バイト / 512 バイト
    I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
    ディスクラベルのタイプ: dos
    ディスク識別子: 0x00000000
    
    /dev/sda1           2048  27265023  27262976    13G 27 隠し NTFS WinRE
    /dev/sda2  *    27265024  27469823    204800   100M  7 HPFS/NTFS/exFAT
    /dev/sda3       27469824 625139711 597669888   285G  7 HPFS/NTFS/exFAT
    ( 625139711 + 1 ) × 512 = 320071532544
    [root@server]# ddrescue -f -n -s320071532544 /dev/sda backup.img logfile
  9. LBA が 625142448 のHDD( 320GB )をバックアップする。
  10. 625142448 × 512 = 320072933376
    [root@server]# ddrescue -f -n -s320072933376 /dev/sda backup.img logfile

イメージファイルの書込み

  1. イメージファイルをHDDに書き込む。
  2. [root@server]# ddrescue -f -n backup.img /dev/sda logfile

HDD修復ユーティリティー

  1. ハードディスクの壊れたパーティションを復元できるフリーソフト
  2. [root@server]# testdisk
  3. ファイル復元ソフト
  4. [root@server]# photorec