![syslinux がディスク イメージに予期しないパーティションを作成する](https://rvso.com/image/231062/syslinux%20%E3%81%8C%E3%83%87%E3%82%A3%E3%82%B9%E3%82%AF%20%E3%82%A4%E3%83%A1%E3%83%BC%E3%82%B8%E3%81%AB%E4%BA%88%E6%9C%9F%E3%81%97%E3%81%AA%E3%81%84%E3%83%91%E3%83%BC%E3%83%86%E3%82%A3%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E4%BD%9C%E6%88%90%E3%81%99%E3%82%8B.png)
ディスク イメージにブートローダーをインストールしようとしているときに、奇妙な動作が発生しています。私が実行したプロセスは次のとおりです。
$ dd if=/dev/zero of=test.img status=progress bs=200M count=1
1+0 records in
1+0 records out
209715200 bytes (210 MB, 200 MiB) copied, 0.190117 s, 1.1 GB/s
$ mkfs.ext2 test.img
mke2fs 1.47.0 (5-Feb-2023)
Discarding device blocks: done
Creating filesystem with 204800 1k blocks and 51200 inodes
Filesystem UUID: f6442813-7b8c-4636-b69e-334696e0840b
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
$ sudo mount test.img mount-point/ -o loop
$ fdisk -l test.img
Disk test.img: 200 MiB, 209715200 bytes, 409600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
$ sudo extlinux -i mount-point/
mount-point/ is device /dev/loop0
Warning: unable to obtain device geometry (defaulting to 64 heads, 32 sectors)
(on hard disks, this is usually harmless.)
$ fdisk -l test.img
Disk test.img: 200 MiB, 209715200 bytes, 409600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x20ac7dda
Device Boot Start End Sectors Size Id Type
test.img1 3224498923 3657370039 432871117 206.4G 7 HPFS/NTFS/exFAT
test.img2 3272020941 5225480974 1953460034 931.5G 16 Hidden FAT16
test.img3 0 0 0 0B 6f unknown
test.img4 50200576 974536369 924335794 440.8G 0 Empty
Partition table entries are not in disk order.
このコマンドがディスク イメージに新しいパーティションを作成する理由がわかりませんextlinux -i
。ファイルシステムのメタデータの一部が変更されているのではないかと考えていますが、詳細について説明していただければ幸いです。また、パーティション化されていないディスク イメージに Syslinux をインストールすることは可能ですか?
答え1
MBR パーティション テーブルは、ディスクの最初の 512 バイト ブロックの末尾にある非常に単純な構造です。チェックサム、ハッシュ、その他のエラー保護機能は含まれていません。
作成したファイルシステム/パーティション イメージに対して実行することでfdisk -l
、最初のブロック (パーティション ブート レコード、略して PBR) を MBR として誤って解釈するように強制することになります。その結果、お示しのとおり、意味のない出力が生成されます。
私の記憶が正しければ、作成されたPBRにextlinux
はブートコードMBR 内の実際のパーティション テーブルが占める場所にあります。つまり、 PBR ブート コードfdisk
の一部を読み取って、それを MBR コンテンツとして表示しようとすることになりますextlinux
。出力が意味をなさないのも不思議ではありません。