Write the operating system by yourself - (1) Write the boot into the U disk

      Why do I write a blog? I thought about it, first of all to keep it for myself to review, because after a long time, there will definitely be a lot of things that will be forgotten. I will keep a record here, and it will not be too troublesome to organize later; The author is to share the experience, because I am relatively stupid, maybe I have misunderstood in which aspect, so please criticize and correct me. ^-^

       The first is mental preparation.

       Here's what I plan to do: write my own operating system as the whole thread. On this line, there will definitely be many difficulties. However, "opening a road in every mountain, building a bridge in the face of water", it is enough to solve the problem when encountering a problem. As long as it is based on this belief, what problems cannot be solved, let alone a mere operating system, right?

       Well, finally can really start their own operating system journey

       Let me talk about the configuration environment of my computer first: dual operating systems: win7 and linux, a virtual machine is installed in win7, and XP is installed in the virtual machine. linux is the ubuntu distribution.

       Let me talk about my configuration again: I taught myself a little microcontroller, so I am not particularly afraid of the underlying things; I learned assembly by myself, because I am lazy, so it took a long time ; I learned a little C language by myself, and only know a little bit of fur. For the operating system to start, these are enough. It's the same principle: solve difficulties when you encounter difficulties. The things that will be used in the future will be learned later, and the most important thing is to hit the road first.

        Reference book "Orange's Implementation of an Operating System" ( Write Your Own Operating System (2nd Edition))

        floppy disk? ? ? ! ! ! Not this time...

       You need a floppy disk. Where can you get a floppy disk in this day and age? If you can't get a floppy disk, use a U disk .

       How to write the boot into the U disk?

       Insert the U disk, first change the path to the folder where boot.bin is located, and then type the following code in the linux command line:

sudo dd if=boot.bin of=/dev/sdb bs=512 count=1


Note: The code must be written correctly, the length of the string must be several pairs , and don't forget the spaces inside.

       It is such a simple line of code, which is to replace the fd0 in the book with sdb .

       This was a solution I found later, and I didn't know it at first. The method used at the beginning is rather stupid, that is, in XP, use winHex software to copy the binary code of boot.bin to the mbr of the U disk, and it will be OK. If winHex is in win7, run it as administrator.

       The beginning of everything is difficult, but a good beginning is half the battle. Don't be afraid, always remember: "Open a road when you meet mountains, build a bridge when you meet water"...


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325369965&siteId=291194637