English 中文(简体)
自定义启动扇区虚拟 CD
原标题:custom boot sector virtual CD

Following lots of "How to build your own Operating system" tutorials,
I m supposed to write custom loader to floppy disk boot sector via

#include <sys/types.h> /* unistd.h needs this */
#include <unistd.h>    /* contains read/write */
#include <fcntl.h>

int main()
{
    char boot_buf[512];
    int floppy_desc, file_desc;

    file_desc = open("./boot", O_RDONLY);
    read(file_desc, boot_buf, 510);
    close(file_desc);

    boot_buf[510] = 0x55;
    boot_buf[511] = 0xaa;

    floppy_desc = open("/dev/fd0", O_RDWR);
    lseek(floppy_desc, 0, SEEK_CUR);
    write(floppy_desc, boot_buf, 512);
    close(floppy_desc);
}

我没有带软盘的电脑, 我更喜欢尝试整个项目 在虚拟机器上通过虚拟Box。

So How to write custom boot sector to a virtual CD image that will be invoked by my virtual machine ? :)
If you have any alternative way please suggest it :)

问题回答

(注:本假设您在Linux)

您不必写入需要真正软盘驱动器的 / dev/fd0 , 您可以写入一些磁盘图像, 以启动虚拟框。 但是, 您需要将文件粘贴到1.44MB, 因为典型的软盘就是这样 。

更好的办法是首先创建启动区二进制( 使用 0xAA55 魔法代码 ), 然后做类似 < code> dd 如果= MyBootestrateBin 的 = Floppy. flp bs= 512 count= 2880 来创建输出文件 Floppy. flp。 这可以通过 VilowBox ( 或我的偏好, QEMU, 通过 < code> qemu - fda floppy. flp 来启动 。

我不确定虚拟 CD, 但是您可以很容易地创建 ISO 来写入磁盘。 需要的程序是 mkisofs, 并且可以从< a href=" http://wiki. osdev. org/ El- Torito" rel=“ nofollow” 标题=“ 含有可启动 ISO 的指令, 包括写入启动区 。 “ 这里 。 ”





相关问题
What resources are shared between threads?

Recently, I have been asked a question in an interview what s the difference between a process and a thread. Really, I did not know the answer. I thought for a minute and gave a very weird answer. ...

Random access of multiple files and file caching

This relates to some software I ve been given to "fix". The easiest and quickest solution would make it open and read 10 random files out of hundreds and extract some very short strings for processing ...

What form is DLL & what makes it processor dependent

I know DLL contains one or more exported functions that are compiled, linked, and stored separately.. My question is about not about how to create it.. but it is all about in what form it is stored.. ...

Thread behavior on multicore machines

Does the threads of a single process run in parallel on a multi-core machine on windows XP? Is the behavior same on different windows versions (windows server editions) I have heard that only threads ...

How to check which Operating System?

How can I check OS version in a batch file or through a vbs in an Windows 2k/2k3 environment ? You know ... Something like ... : "If winver Win2k then ... or if winver Win2k3 then ....

热门标签