30天自制操作系统(linux环境)--第一天
我是在CentOS的环境上面实现的,使用ubuntu的环境也是类似的
第一步:因为要对二进制文件进行编辑,所以安装二进制编辑器hexedit(当然其他的也可以),安装命令
yum install hexedit
第二步:对生成的软盘镜像进行仿真运行,使用虚拟机,因为我本地是使用VM进行的虚拟机,所以直接使用VM也可以
具体过程如下:
第一步:创建一个img文件
touch hello.img
第二步:编辑该文件,输入512字节的内容(这512字节的内容我们现在不用过多的关注)
hexedit hello.img
第三步:dd出来一个新的软盘镜像文件,然后将hello.img的内容cat进去
dd if=/dev/zero of=os.img bs=512 count=2880
cat hello.img >os.img
第四步:使用VM启动os.img
具体步骤可参考:https://blog.csdn.net/NCTU_to_prove_safety/article/details/66475604
效果图如下:
备注:下面就是我们输入的512字节内容
EB 4E 90 48 45 4C 4C 4F 49 50 4C 00 02 01 01 00 02 E0 00 40 0B F0 09 00 12 00 02 00
00 00 00 00 40 0B 00 00 00 00 29 FF FF FF FF 48 45 4C 4C 4F 2D 4F 53 20 20 20 46 41
54 31 32 20 20 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B8 00 00 8E
D0 BC 00 7C 8E D8 8E C0 BE 74 7C 8A 04 83 C6 01 3C 00 74 09 B4 0E BB 0F 00 CD 10 EB
EE F4 EB FD 0A 0A 68 65 6C 6C 6F 2C 20 77 6F 72 6C 64 0A 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 55 AA