diff --git a/_posts/2024-10~12/2024-10-16-iso.md b/_posts/2024-10~12/2024-10-16-iso.md new file mode 100644 index 0000000..231c9fe --- /dev/null +++ b/_posts/2024-10~12/2024-10-16-iso.md @@ -0,0 +1,120 @@ +--- +layout: post +title: "ISO Image" +date: 2024-10-16 +tags: [system] +--- + + genisoimage 镜像生成测试。 + +# 简介 + + ISO Image 是一种文件系统,可写入所有内容,包括文本、二进制等。参考 [Optical disc image](https://en.wikipedia.org/wiki/Optical_disc_image) + +# docker 测试 + +```sh +$ 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 创建 + +```sh +$ apt-get update +$ apt-get install genisoimage + +# 指定目录生成 iso 文件 +$ genisoimage -o file.iso dir_name +``` + + +# File Format + + * 前 [32768](https://en.wikipedia.org/wiki/ISO_9660), 即 `0x8000` 之前为系统区域。 + * [The Primary Volume Descriptor](https://wiki.osdev.org/ISO_9660),主要的描述符如下: + +```sh +# 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](https://wiki.osdev.org/El-Torito) + + Demo: https://intermezzos.github.io/book/first-edition/hello-world.html + + +# 参考 + +* [How-To: Create ISO Images from Command-Line](https://www.tuxarena.com/static/tut_iso_cli.php) +* [Optical disc image](https://en.wikipedia.org/wiki/Optical_disc_image) +* [ISO_9660](https://en.wikipedia.org/wiki/ISO_9660) diff --git a/_posts/2024-10~12/2024-10-17-lfs.md b/_posts/2024-10~12/2024-10-17-lfs.md new file mode 100644 index 0000000..f3e27a0 --- /dev/null +++ b/_posts/2024-10~12/2024-10-17-lfs.md @@ -0,0 +1,31 @@ +--- +layout: post +title: "Linux from Scratch" +date: 2024-10-15 +tags: [system] +--- + + 编译 Linux + +# Quick Start + + 从 [release](https://github.com/reinterpretcat/lfs/releases/tag/v8.1.0) 下载 lfs.iso.tar.gz + +```sh +$ brew install qemu +$ qemu-system-x86_64 -boot d -cdrom ./lfs.iso -m 2G + +# 在 qemu 中 +# 用户名 root,无秘密 +$ root +``` + +# Cross-Linux from scratch + +* https://github.com/reinterpretcat/lfs +* https://github.com/bajorekp/lfs-docker/blob/main/README.md + * https://github.com/cross-lfs/cross-lfs +* https://github.com/xiez/lfs + +* docker 配置 + * https://github.com/bajorekp/lfs-docker/blob/main/README.md