operating-systemkernelgrubiso-image

Generating an iso from Kernel built with GRUB/NASM/C


I was following along with this series of articles, and on the last page, he linked an iso image of the kernel that he produced. He doesn't mention this in the series, so that's my question... how do I generate an iso image from my kernel executable?


Solution

  • There are two approaches I generally use. The first is mkisofs, below is what I ripped out from a Makefile I use:

     mkisofs -quiet -R -b boot/grub/eltorito.img       \
             -no-emul-boot -boot-load-size 4           \
             -boot-info-table -o my_iso.iso iso_folder
    

    You will need the El Torito image. You can find more information on this approach here.

    The second approach (and the one I prefer) is to use grub-mkrescue:

    grub-mkrescue -o bootable.iso iso
    

    For this to work iso/boot/grub/grub.cfg will need to be a valid grub configuration file. I prefer this approach because you can dd the result to a USB and boot. The first approach is using the El Torito which is only for bootable optical media (e.g. CDs, DVDs) so you can's easily create a bootable USB with the first iso.