Palm84 某所の日記

死のうは一定、しのびクマには何しよぞ...

dd for windowsでMBR/ブートセクタをバックアップ

Vista/7 ではコマンド プロンプトを「管理者として実行」しないと --list などオプションが使えないので注意。

D:\dd-0.5>dd /?
rawwrite dd for windows version 0.5.
Written by John Newbigin 
This program is covered by the GPL.  See copying.txt for details
Unknown command /?
dd [bs=SIZE] [count=BLOCKS] [if=FILE] [of=FILE] [seek=BLOCKS] [skip=BLOCKS] [--s
ize] [--list] [--progress]
SIZE and BLOCKS may have one of the following suffix:
 k = 1024
 M = 1048576
 G = 1073741824
default block size (bs) is 512 bytes
skip specifies the starting offset of the input file (if)
seek specifies the starting offset of the output file (of)
D:\00_Tools\dd-0.5>dd --list
rawwrite dd for windows version 0.5.
Written by John Newbigin 
This program is covered by the GPL.  See copying.txt for details
Win32 Available Volume Information
\\.\Volume{87fe18b0-c04e-11db-8d02-806d6172696f}\
  link to \\?\Device\HarddiskVolume1
  fixed media
  Mounted on \\.\c:

\\.\Volume{87fe18b1-c04e-11db-8d02-806d6172696f}\
  link to \\?\Device\HarddiskVolume2
  fixed media
  Mounted on \\.\d:

\\.\Volume{11093f41-b15a-11d6-a018-806d6172696f}\
  link to \\?\Device\CdRom0
  CD-ROM
  Mounted on \\.\e:

\\.\Volume{6e280c70-2d1b-11d8-a4f5-00022d51f75a}\
  link to \\?\Device\Harddisk1\DP(1)0-0+6
  removeable media
  Mounted on \\.\f:


NT Block Device Objects
\\?\Device\CdRom0
  size is 2147483647 bytes
\\?\Device\Harddisk0\Partition0
  link to \\?\Device\Harddisk0\DR0
  Fixed hard disk media. Block size = 512
  size is 20003880960 bytes
\\?\Device\Harddisk0\Partition1
  link to \\?\Device\HarddiskVolume1
\\?\Device\Harddisk0\Partition2
  link to \\?\Device\HarddiskVolume2
\\?\Device\Harddisk0\Partition3
  link to \\?\Device\HarddiskVolume3
  Fixed hard disk media. Block size = 512
  size is 534643200 bytes
\\?\Device\Harddisk0\Partition4
  link to \\?\Device\HarddiskVolume4
  Fixed hard disk media. Block size = 512
  size is 5190151680 bytes
\\?\Device\Harddisk1\Partition0
  link to \\?\Device\Harddisk1\DR5
  Removable media other than floppy. Block size = 512
  size is 1017643008 bytes
\\?\Device\Harddisk1\Partition1
  link to \\?\Device\Harddisk1\DP(1)0-0+6

Virtual input devices
 /dev/zero   (null data)
 /dev/random (pseudo-random data)
 -           (standard input)

Virtual output devices
 -           (standard output)

if=で読み出し対象of=で書き込み対象。of=にデバイス名を指定すると書き込みされるのでご注意!

ローカルHD

  • MBRのバックアップ
D:\dd-0.5>dd if=\\?\Device\Harddisk0\Partition0 of=hda_mbr.bin bs=512 count=1
  • 第1パーティションのブートセクタのバックアップ
D:\dd-0.5>dd if=\\?\Device\Harddisk0\Partition1 of=hda1_bs.bin bs=512 count=20

※ NTFSの場合は 20セクタ取っときませう。

  • HD先頭 (MBR) から64,65番目のセクタ(第1パーティションのブートセクタx2)をバックアップ
D:\dd-0.5>dd if=\\?\Device\Harddisk0\Partition0 of=hda1_bs.bin bs=512 skip=63 count=2

※ Vista 以降では2049番目となるので skip=2048 としませう

  • MBR(HD先頭)から65番目のセクタ(第1パーティションのブートセクタ)までをバックアップ
D:\dd-0.5>dd if=\\?\Device\Harddisk0\Partition0 of=hda_65.bin bs=512 count=65

※ Vista 以降では2049番目となるので count=2050 としませう

注意

システムパーティションのブートセクタや、プログラムなどで使用中のパーティションのブートセクタは直接指定できないらしいです。

CドライブについてはHD先頭からセクタ数(番地)を指定する、その他のパーティションについてはUSBメモリなどにddをコピーして実行するとかしないといけないかも?

※あっと、拡張パーティションがある場合は、拡張パーティションのブート先頭セクタに論理パーティションのパーティションテーブルがあるので、そちらのバックアップも必要ですね。論理パーティションが2つ以上ある場合は、それらすべての先頭セクタが必要、ブートセクタが別だったりするのでかなりややこしいです...。

【追記】UnxUtils の dd コマンド

UnxUtils に入ってる dd.exe では、全ドライブのブートセクタの保存が可能でした。

dd for windows の様に安全装置(何)があるのかよくわかってないので【取り扱い注意】ですけど...

dd if=\\.\c: of=c_drive.bin bs=512 count=20

リムーバブル・ディスク

※ 内蔵HDが1台なら、USBメモリなどは \\?\Device\Harddisk1 となる筈です。

  • MBRのバックアップ
D:\dd-0.5>dd if=\\?\Device\Harddisk1\Partition0 of=usbkey_mbr.bin bs=512 count=1
  • ブートセクタのバックアップ
D:\dd-0.5>dd if=\\.\F: usbkey_bs.bin bs=512 count=1
D:\dd-0.5>dd if=\\?\Device\Harddisk1\Partition1 usbkey_bs.bin bs=512 count=1