简体   繁体   English

使bootloader和内核成为iso?

[英]make bootloader and kernel into iso?

how to create simple bootloader that load kernel into iso? 如何创建将内核加载到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)? 它已经有5天,我在谷歌搜索并多次尝试和错误但没有得到任何.....我已经尝试过很多教程,如mikeos,osdev,supernova,cosmos os但仍然没有解决方案.....我的计算机没有floopy磁盘所以我不能使用floopy磁盘制作bo​​otloader ...我在mikeos教程中看到第一个扇区512字节用于bootloader而第二个用于内核可以用imdisk制作但是使用floopy磁盘他也可以制作bootloader &kernel将另一个文件加载到iso中......他怎么做(不使用floopy磁盘制作iso)? 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.. 我想使用程序集制作引导加载程序和内核...它不是第一次使用程序集并且已经体验过一些其他语言,如c ++,vb,php,phyton和其他语言....如何为bootloader制作第一个扇区,即seacrhing / load内核编译成iso?还将一些文件和文件夹添加到iso中?谢谢..

I'll assume you are on a x86 PC. 我假设您使用的是x86 PC。 The El Torito bootable cdrom specification supports 3 operating modes: El Torito可启动cdrom规范支持3种操作模式:

  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. 对于软盘和硬盘模拟模式,您必须指定适当的图像文件,BIOS将照常加载引导扇区,提供访问图像文件的模拟驱动器。

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. 对于无仿真模式,您可以指定负载基础段和代码的大小,并且BIOS将相应地执行加载。 You won't be able to access the cdrom through the disk interrupt functions in this case. 在这种情况下,您将无法通过磁盘中断功能访问cdrom。

If you are on linux, you can use the genisoimage tool with the -b , -hard-disk-boot or the -no-emul-boot options, respectively. 如果您使用的是linux,则可以将genisoimage工具分别与-b-hard-disk-boot-no-emul-boot选项一起使用。

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). 另请注意,如果您的BIOS支持从这样的设备启动(大多数设备都支持),USB闪存驱动器可能比cdrom更方便。

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 使用以下代码使用NASM编译bootloader.asm: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. 下载'dd for windo * s'(在Google上搜索),并将程序“dd.exe”放入保存引导加载程序文件的目录中。 Open command prompt and move to directory you saved the bootloader, and type this command: dd if=bootloader.bin of=bootloader.flp 打开命令提示符并移动到保存引导加载程序的目录,然后键入以下命令:dd if = bootloader.bin of = bootloader.flp

  3. Download 'imdisk' (search on Google), and install it. 下载'imdisk'(在Google上搜索),然后安装它。 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: 输入以下命令: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. 然后,Windows将创建一个带有字母B的虚拟软盘驱动器。将您的KERNEL文件复制到该B驱动器中。

  1. Open command prompt again and type: imdisk -D -m B: 再次打开命令提示符并键入:imdisk -D -m B:

Windows will then unmount the drive B and your bootloader.flp is ready to mount by emulator. 然后,Windows将卸载驱动器B,并且您的bootloader.flp已准备好由模拟器安装。

I recommend you QEMU because it is so small and fast program to launch your os file. 我推荐你QEMU因为它是如此小而快的程序来启动你的os文件。 To run bootloader.flp with qemu, type this command in the command prompt: qemu -fda bootloader.flp 要使用qemu运行bootloader.flp,请在命令提示符下键入以下命令: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. 如果要生成bootloader.flp文件的ISO文件,则必须具有名为“mkisofs”的程序,并将程序“mkisofs.exe”移动到保存引导加载程序的目录中。 Then move your bootloader.flp file into the folder called 'cdiso' (make it first). 然后将bootloader.flp文件移动到名为“cdiso”的文件夹中(首先将其设置)。 Then open command prompt and type this: mkisofs -no-emul-boot -boot-load-size 4 -o myos.iso -b bootloader.flp cdiso/ 然后打开命令提示符并键入: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. 然后它将生成ISO文件,您可以在模拟器上运行它。

If you want to ask me more, you can email me at danasap90@gmail.com 如果你想问我更多,你可以发送电子邮件至danasap90@gmail.com

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. 如果您要编写操作系统并使用模拟器而不是真机,我建议您使用标准引导程序(不是因为引导加载程序可能会破坏计算机 - 它可能不会,但因为它是一种更简单的启动方式几乎肯定会对每次更新刻录CD感到厌倦。

Also, note that ISO uses a more complicated boot protocol than floppy/harddisks does. 另请注意,ISO使用比软盘/硬盘更复杂的引导协议。 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. 最好的方法是使用GRUB或ISOLINUX,如果你想使用CD并使用软盘映像(可以通过模拟后者附加到CD),如果你想拥有自己的引导加载程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM