make bootloader and kernel into iso?

2019-06-27 12:23发布

how to create simple bootloader that load kernel into iso? it has been 5 days , I searching in google and do trial and error many times but got nothing.....I have tried many tutorial like mikeos,osdev,supernova,cosmos os but still get no solution..... my computer doesn't have floopy disk so I can't make bootloader using floopy disk... I see in mikeos tutorial first sector 512 byte is for bootloader and second for kernel can be made using imdisk but using floopy disk also he can made bootloader & kernel load another file into iso...how he can do it(make iso without using floopy disk)? I want to make bootloader and kernel using assembly...it's not first time I using assembly and have experinced some other language like c++,vb,php,phyton and others.... how to make first sector for bootloader that seacrhing/load kernel compiled into iso?also adding some file and folder into iso?thanks..

3条回答
Juvenile、少年°
2楼-- · 2019-06-27 13:11

I'll assume you are on a x86 PC. The El Torito bootable cdrom specification supports 3 operating modes:

  1. floppy emulation
  2. hard disk emulation
  3. no emulation

For the floppy and hard disk emulation modes, you have to specify an appropriate image file and the bios will load the boot sector as usual, providing an emulated drive that accesses the image file.

For the no emulation mode, you can specify a load base segment and the size of your code and the bios will perform the loading accordingly. You won't be able to access the cdrom through the disk interrupt functions in this case.

If you are on linux, you can use the genisoimage tool with the -b, -hard-disk-boot or the -no-emul-boot options, respectively.

Also note that a USB flash drive may be more convenient than a cdrom, if your bios supports booting from such a device (most of them do).

查看更多
我想做一个坏孩纸
3楼-- · 2019-06-27 13:19

You can do that only following my simple steps:

  1. Compile bootloader.asm with NASM using this code: nasm -f bin -o bootloader.bin bootloader.asm

  2. Download 'dd for windo*s' (search on Google), and put the program 'dd.exe' into the directory you saved the bootloader file. Open command prompt and move to directory you saved the bootloader, and type this command: dd if=bootloader.bin of=bootloader.flp

  3. Download 'imdisk' (search on Google), and install it. After you install, open command prompt and go to the directory you saved the bootloader. Type this command: imdisk -a -f bootloader.flp -s 1440k -m B:

Windows will then create a virtual floppy drive with the letter B. Copy your KERNEL file into that B drive.

  1. Open command prompt again and type: imdisk -D -m B:

Windows will then unmount the drive B and your bootloader.flp is ready to mount by emulator.

I recommend you QEMU because it is so small and fast program to launch your os file. To run bootloader.flp with qemu, type this command in the command prompt: qemu -fda bootloader.flp

If you want to produce the ISO file of your bootloader.flp file, you must have a program named 'mkisofs' and move the program 'mkisofs.exe' into the directory you saved the bootloader. Then move your bootloader.flp file into the folder called 'cdiso' (make it first). Then open command prompt and type this: mkisofs -no-emul-boot -boot-load-size 4 -o myos.iso -b bootloader.flp cdiso/

It will then produce ISO file and you can run it on emulator.

If you want to ask me more, you can email me at danasap90@gmail.com

查看更多
够拽才男人
4楼-- · 2019-06-27 13:20

I recommend you to use a standard bootloader if you are going to write an OS and use an emulator instead of real machine any way (not because you bootloader could break computer - it probably couldn't, but because it is a simpler way to start up with and debug. You will almost certainly get bored of burning a CD each update.

Also, note that ISO uses a more complicated boot protocol than floppy/harddisks does. The best approach is to use GRUB or ISOLINUX if you wish to use CD and use a floppy image (which can be attached to CD by emulation latter) if you wish to have you very own bootloader.

查看更多
登录 后发表回答