美文网首页
把引导程序写进光盘镜像

把引导程序写进光盘镜像

作者: louyang | 来源:发表于2020-06-07 11:22 被阅读0次

https://www.jianshu.com/writer#/notebooks/19149135/notes/71282488
从这里我们已经有了boot.bin,且这个boot.bin可以放入软盘中启动虚拟机。
接下来我们研究一下怎么写进光盘,然后用光盘启动虚拟机。

https://stackoverflow.com/questions/34268518/creating-a-bootable-iso-image-with-custom-bootloader
最好的答案出在这里,我们实践一下。

boot.s

.code16
.global init
init:
  mov $0x07c0, %ax
  mov %ax, %ds
  mov $0x07e0, %ax
  mov %ax, %ss
  mov $0x2000, %sp

  mov %cs, %bx
  call print_register

  mov $0x3a, %al
  mov $0x0e, %ah
  int $0x10

  call next
next:
  pop %bx
  sub $(next-init), %bx  # starting point of memory address, now stored in %bx
  call print_register
  jmp .

print_register:  # always print out value in %bx
  mov %bh, %cl
  shr $0x4, %cl
  and $0x0f, %cl
  call print_digit
  mov %bh, %cl
  and $0x0f, %cl
  call print_digit
  mov %bl, %cl
  shr $0x4, %cl
  and $0x0f, %cl
  call print_digit
  mov %bl, %cl
  and $0x0f, %cl
  call print_digit
  ret

print_digit: # %cl has digit to be printed
  cmp $0x9, %cl
  jg print_digit_atof
print_digit_1to9:
  add $0x30, %cl
  jmp print_digit_out
print_digit_atof:
  add $0x57, %cl
print_digit_out:
  mov %cl, %al
  mov $0x0e, %ah
  int $0x10
  ret

.=510
.byte 0x55
.byte 0xaa

myos.iso放入虚拟机光驱,启动

$ as -o boot.o boot.s
$ ld -o boot.bin --oformat binary -e init boot.o
$ mkdir iso
$ cp boot.bin iso/
$ genisoimage -o myos.iso -b boot.bin -boot-load-size 1 -no-emul-boot -hide floppy.img iso/
image.png
参考

https://www.jianshu.com/writer#/notebooks/19149135/notes/71282488
https://stackoverflow.com/questions/34268518/creating-a-bootable-iso-image-with-custom-bootloader

相关文章

  • 把引导程序写进光盘镜像

    https://www.jianshu.com/writer#/notebooks/19149135/notes/...

  • VMware ESXI 6.7 安装步骤

    先提前准备一个U盘,然后去下载个ESXI镜像文件,写进U盘来引导安装。 把U盘插入到服务器进入引导进行安装(我使用...

  • linux挂载光盘

    光盘中使用我们的安装镜像文件使用前:光盘要挂载镜像文件 挂载就相当于把光盘中的文件复制到根目录下的某个文件夹中 1...

  • 实验:mbr 前446字节被损坏,修复方法

    错误提示页面 系统认为硬盘没有引导启动能力,如果有连接光盘,就直接进入光盘引导 修复方法 通过光盘引导进入救援模式...

  • 服务器安装系统

    [1] 服务器安装系统(ubuntu 12.04.5) 【1】下载镜像【2】把镜像刻录到光盘【3】给服务器连接上显...

  • 制作linux引导光盘

    isolinux.bin 光盘引导程序,在mkisofs的选项中需要明确给出文件路径,这个文件属于SYSLINUX...

  • 工具下载方式

    虚拟光驱的安装 正版的 VS 安装程序是刻录在光盘里面的,我们从互联网上下载的都是.iso格式的镜像文件。所谓镜像...

  • Linux命令总结十八(光盘)

    清空一个可复写的光盘内容 在磁盘上创建一个光盘的iso镜像文件 在磁盘上创建一个压缩了的光盘iso镜像文件 创建一...

  • 配置yum仓库步骤

    第1步:把光盘设备中的系统镜像挂载到/media/cdrom目录 mkdir -p /media/cdrommou...

  • Linux本地Yum

    0、创建目录 创建一个目录,用来存放光盘内容的; 1、挂载光盘 挂载Linux光盘(iso镜像),出现“mount...

网友评论

      本文标题:把引导程序写进光盘镜像

      本文链接:https://www.haomeiwen.com/subject/bacftktx.html