How can I create a bootable CD image with my kernel?

前端 未结 1 1187
孤街浪徒
孤街浪徒 2021-02-06 09:35

I have a kernel, to boot I am using command qemu-system-i386 -kernel kernel.bin. Is any way to create bootable disk image to boot with qemu-system-i386 -cdrom

1条回答
  •  心在旅途
    2021-02-06 10:10

    First I give you basic idea of how booting process really works. Actually when you run command qemu-system-i386 -kernel kernel.bin Qemu loads up your kernel binary into memory at location 0x7c000 from where booting further proceed. If you want to boot from ISO then you have to tell the BIOS that there is a Bootable image (mark boot flag) in my iso, and give it proper instructions to laod up your kernel.

    How to do that?
    You have to setup a Bootloader that can be loaded by your BIOS at 0x7c000 and later It would load your Kernel Image into memory and jump to kernel entry point.
    So, mark your ISO active (boot flag) and add boot loader code.

    I can see you already have setup multiboot entrypoint code

    align 4
    dd 0x1BADB002
    dd 0x00
    dd - (0x1BADB002 + 0x00)
    

    You can read more about setting up grub boot chain from here http://wiki.osdev.org/GRUB_2 You can also use syslinux bootloader http://www.syslinux.org/wiki/index.php?title=The_Syslinux_Project

    syslinux Copy isolinux.bin, syslinux.cfg and mboot.c32 to your build path of your kernel binary image. configure syslinux.cfg and execute the following command.

    mkisofs.exe -o %OUTPUT_DIR%\%BUILD_NAME%.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table %ISO_DIR%
    

    0 讨论(0)
提交回复
热议问题