initrd補足

この間の日記に書いた作業の中で打ったコマンドなどを載せておきます。

magicファイルの中身

# cpio archives
#
# Yes, the top two "cpio archive" formats *are* supposed to just be "short".
# The idea is to indicate archives produced on machines with the same
# byte order as the machine running "file" with "cpio archive", and
# to indicate archives produced on machines with the opposite byte order
# from the machine running "file" with "byte-swapped cpio archive".
#
# The SVR4 "cpio(4)" hints that there are additional formats, but they
# are defined as "short"s; I think all the new formats are
# character-header formats and thus are strings, not numbers.
0 short 070707 cpio archive
0 short 0143561 byte-swapped cpio archive
0 string 070707 ASCII cpio archive (pre-SVR4 or odc)
0 string 070701 ASCII cpio archive (SVR4 with no CRC)
0 string 070702 ASCII cpio archive (SVR4 with CRC)

ここに書かれているように"070701"で始まるのは「SVR4 with no CRC」フォーマットのcpioファイルだったりする。

cpioファイルを作成するときにはこんな感じに。(カレントをルートファイルシステムのトップディレクトリに移した上で実行)

# find . | cpio -o --format=newc > ../ramdisk-test.cpio

odコマンドで中身を確認するときちんと"070701"で始まっている。(右側の文字列表示部分)

# od --read-bytes 32 -t x1z ../ramdisk-test.cpio 
0000000 30 37 30 37 30 31 30 30 30 30 30 30 30 32 30 30  >0707010000000200<
0000020 30 30 34 31 45 44 30 30 30 30 30 30 30 30 30 30  >0041ED0000000000<

fileコマンドで確認すると「SVR4」の表記が付く。cpioコマンドに「--format」を付け忘れるとSVR4にならない。

# file ../ramdisk-test.cpio 
../ramdisk-test.cpio: ASCII cpio archive (SVR4 with no CRC)