genisoimage 镜像生成测试。

简介

ISO Image 是一种文件系统,可写入所有内容,包括文本、二进制等。参考 Optical disc image

docker 测试

$ docker run -it mirror.gcr.io/ubuntu:22.04

# 切换到 ali 镜像源
# https://developer.aliyun.com/mirror/ubuntu-ports/
$ cat > /etc/apt/sources.list << "EOF"
deb http://mirrors.aliyun.com/ubuntu-ports/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu-ports/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu-ports/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu-ports/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy-backports main restricted universe multiverse

EOF

创建 iso 文件

使用 genisoimage 创建

$ apt-get update
$ apt-get install genisoimage

# 指定目录生成 iso 文件
$ genisoimage -o file.iso dir_name

File Format

# Type Code
$ xxd -s 0x8000 -l 1 ./test.iso
00008000: 01                                       .

# Standard Identifier
$ xxd -s 0x8001 -l 5 ./test.iso
00008001: 4344 3030 31                             CD001

# Version
$ xxd -s 0x8006 -l 1 ./test.iso
00008006: 01                                       .

$ xxd -s 0x8007 -l 1 ./test.iso
00008007: 00                                       .

# System Identifier
$ xxd -s 0x8008 -l 32 ./test.iso
00008008: 4c49 4e55 5820 2020 2020 2020 2020 2020  LINUX
00008018: 2020 2020 2020 2020 2020 2020 2020 2020

# Volume Identifier
$ xxd -s 0x8028 -l 32 ./test.iso
00008028: 4344 524f 4d20 2020 2020 2020 2020 2020  CDROM
00008038: 2020 2020 2020 2020 2020 2020 2020 2020

# Volume Space Size
$ xxd -s 0x8050 -l 8 ./test.iso
00008050: af00 0000 0000 00af

# Volume Set Size
$ xxd -s 0x8078 -l 4 ./test.iso
00008078: 0100 0001

# Application Identifier
$ xxd -s 0x823e -l 128 ./test.iso
0000823e: 4745 4e49 534f 494d 4147 4520 4953 4f20  GENISOIMAGE ISO
0000824e: 3936 3630 2f48 4653 2046 494c 4553 5953  9660/HFS FILESYS
0000825e: 5445 4d20 4352 4541 544f 5220 2843 2920  TEM CREATOR (C)
0000826e: 3139 3933 2045 2e59 4f55 4e47 4441 4c45  1993 E.YOUNGDALE
0000827e: 2028 4329 2031 3939 372d 3230 3036 204a   (C) 1997-2006 J
0000828e: 2e50 4541 5253 4f4e 2f4a 2e53 4348 494c  .PEARSON/J.SCHIL
0000829e: 4c49 4e47 2028 4329 2032 3030 362d 3230  LING (C) 2006-20
000082ae: 3037 2043 4452 4b49 5420 5445 414d 2020  07 CDRKIT TEAM

# Volume Creation Date and Time
$ xxd -s 0x832d -l 17 ~/Downloads/test.iso
0000832d: 3230 3234 3130 3136 3032 3135 3536 3030  2024101602155600
0000833d: 00

Bootable

可启动的 iso 文件格式,参考:El-Torito

Demo: https://intermezzos.github.io/book/first-edition/hello-world.html

参考