# os-x86-iso **Repository Path**: chenlongos/os-x86-iso ## Basic Information - **Project Name**: os-x86-iso - **Description**: 如何制作u盘启动OS的iso文件 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2023-10-05 - **Last Updated**: 2023-10-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 如何制作u盘启动OS的iso文件 Thanks to ### 下载项目 ``` $ git clone https://gitee.com/chenlongos/os-x86-iso.git Cloning into 'os-x86-iso'... remote: Enumerating objects: 14, done. remote: Counting objects: 100% (14/14), done. remote: Compressing objects: 100% (10/10), done. remote: Total 14 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (14/14), done. $ cd os-x86-iso/ $ tree . ├── Makefile ├── README.md └── src └── arch └── x86_64 ├── boot.asm ├── grub.cfg ├── linker.ld └── multiboot_header.asm ``` ### Ubuntu 安装依赖 ``` sudo aptitude install nasm mtools xorriso ``` ## 无需编译,直接验证 ### 快速烧写验证 最终iso文件 ./build/os-x86_64.iso 已经推入仓库,可以直接用 make dd 进行烧写验证 ``` $ make dd diskutil unmountDisk /dev/disk3 Unmount of all volumes on disk3 was successful sudo dd if=./build/os-x86_64.iso of=/dev/disk3 Password: 22580+0 records in 22580+0 records out 11560960 bytes transferred in 22.977369 secs (503146 bytes/sec) diskutil eject /dev/disk3 Disk /dev/disk3 ejected ``` ## 编译源码,了解细节 ### 编译生成 iso ``` $ make mkdir -p build/arch/x86_64 nasm -felf64 src/arch/x86_64/boot.asm -o build/arch/x86_64/boot.o mkdir -p build/arch/x86_64 nasm -felf64 src/arch/x86_64/multiboot_header.asm -o build/arch/x86_64/multiboot_header.o ld -n -T src/arch/x86_64/linker.ld -o build/kernel-x86_64.bin build/arch/x86_64/boot.o build/arch/x86_64/multiboot_header.o $ make iso mkdir -p build/isofiles/boot/grub cp build/kernel-x86_64.bin build/isofiles/boot/kernel.bin cp src/arch/x86_64/grub.cfg build/isofiles/boot/grub grub-mkrescue -o build/os-x86_64.iso build/isofiles 2> /dev/null rm -r build/isofiles $ ls -l build/os-x86_64.iso -rw-r--r-- 1 root root 9097216 Oct 5 22:56 build/os-x86_64.iso ``` ### 烧写iso文件到u盘 ``` $ sudo dd if=./build/os-x86_64.iso of=/dev/disk3 Password: 17768+0 records in 17768+0 records out 9097216 bytes transferred in 17.312507 secs (525471 bytes/sec) ```