ページ更新: 2005-10-02 (日) (6449日前)
関連: Windows/パーティションテーブル復活, Cygwin/パーティションテーブル 手元のPCの現在のパーティションテーブルについてのメモ。 Linuxに依存しているわけではないが、このPCはLinuxしか入れていないのでここに書く。 このパーティションはcfdiskで作ったもの、だと思う。 目次 [編集]fdisk #fdiskで見てみる。 # fdisk -l /dev/hda Disk /dev/hda: 40.0 GB, 40007761920 bytes 16 heads, 63 sectors/track, 77520 cylinders Units = cylinders of 1008 * 512 = 516096 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 194 97744+ 83 Linux /dev/hda2 1985 3968 999936 82 Linux swap /dev/hda3 3969 77520 37070208 83 Linux # fdisk -lu /dev/hda (★ -u はシリンダ数の代わりにセクタ数を表示するオプション) Disk /dev/hda: 40.0 GB, 40007761920 bytes 16 heads, 63 sectors/track, 77520 cylinders, total 78140160 sectors Units = sectors of 1 * 512 = 512 bytes Device Boot Start End Blocks Id System /dev/hda1 * 63 195551 97744+ 83 Linux /dev/hda2 1999872 3999743 999936 82 Linux swap /dev/hda3 3999744 78140159 37070208 83 Linux[編集] パーティションテーブルをダンプ #第1セクタをファイルに吸い出す。 # dd if=/dev/hda of=mbr bs=512 count=1 第1セクタのパーティションテーブル部分をダンプしてみる。(xxdはvimに付属する16進ダンプツール。オプションが豊富) $ xxd -g1 -seek 446 -len 64 mbr 00001be: 80 01 01 00 83 0f 3f c1 3f 00 00 00 a1 fb 02 00 ......?.?....... 00001ce: 00 0f ff ff 82 0f ff ff 00 84 1e 00 00 84 1e 00 ................ 00001de: 00 0f ff ff 83 0f ff ff 00 08 3d 00 00 4b 6b 04 ..........=..Kk. 00001ee: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ コメントを付けるならこうだ 00001be: 80 01 01 00 83 0f 3f c1 3f 00 00 00 a1 fb 02 00 ......?.?....... 00001ce: 00 0f ff ff 82 0f ff ff 00 84 1e 00 00 84 1e 00 ................ 00001de: 00 0f ff ff 83 0f ff ff 00 08 3d 00 00 4b 6b 04 ..........=..Kk. 00001ee: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -- -------- -- -------- ----------- ----------- Fl Cy He Se Ty Cy He Se Start(LBA) Length(LBA) Start(CHS) End(CHS) Fl: Flag Cy: Cylinder He: Head Se: Sector Ty: Type[編集] もっと見やすく #16進数ダンプをにらむのも飽きたので、即席でこんなのを作ってみた。 #!/usr/bin/perl open MBR, 'mbr' or die $?; seek MBR, 512-(16*4+2), 0; for (my $i = 1; $i <= 4; $i++) { read MBR, $b, 1; $flag = unpack "C", $b; read MBR, $b, 1; $start_c = unpack "C", $b; read MBR, $b, 1; $start_h = unpack "C", $b; read MBR, $b, 1; $start_s = unpack "C", $b; read MBR, $b, 1; $type = unpack "C", $b; read MBR, $b, 1; $end_c = unpack "C", $b; read MBR, $b, 1; $end_h = unpack "C", $b; read MBR, $b, 1; $end_s = unpack "C", $b; read MBR, $l, 4; $lba_start = unpack "L", $l; read MBR, $l, 4; $lba_length = unpack "L", $l; printf "partition no= %d\n", $i; printf "flag= %02x type= %02x\n", $flag, $type; printf "CHS start = %02x %02x %02x\n", $start_c, $start_h, $start_s; printf " end = %02x %02x %02x\n", $end_c, $end_h, $end_s; printf "LBA start = %d (%08x)\n", $lba_start, $lba_start; printf " length= %d (%08x)\n", $lba_length, $lba_length; printf "\n"; } close MBR; んで実行。 $ ./part.pl partition no= 1 flag= 80 type= 83 CHS start = 01 01 00 end = 0f 3f c1 LBA start = 63 (0000003f) length= 195489 (0002fba1) partition no= 2 flag= 00 type= 82 CHS start = 0f ff ff end = 0f ff ff LBA start = 1999872 (001e8400) length= 1999872 (001e8400) partition no= 3 flag= 00 type= 83 CHS start = 0f ff ff end = 0f ff ff LBA start = 3999744 (003d0800) length= 74140416 (046b4b00) partition no= 4 flag= 00 type= 00 CHS start = 00 00 00 end = 00 00 00 LBA start = 0 (00000000) length= 0 (00000000) |