Bo2SS

Bo2SS

Try it out: From one Hello to another Hello

Environment: Ubuntu 18.04 virtual machine on Windows

Give It a Try#

🎯Goal: Make your system output "Hello OS"

Download the Source Code#

  1. You can execute the following command in the terminal at any location in the system to download the source code to the virtual machine
git clone https://gitee.com/lmos/cosmos.git

Generate the bin File#

  1. In the specific location in the library: /lesson02/HelloOS, compile the source code to generate HelloOS.bin
  • First, you need to install the tools gcc, make, and nasm. Only nasm is not installed by default. Install the other tools if they are not installed.
sudo apt update
sudo apt install nasm
  • Then, execute the compilation to generate HelloOS.bin according to the rules in the Makefile by default.
make

Move the bin File#

  1. Move HelloOS.bin to the /boot/ directory
mv HelloOS.bin /boot/

Modify the grub Boot Configuration⭐#

  1. Modify the /boot/grub/grub.cfg file
  • Use sudo privileges and open it with vim
sudo vim /boot/grub/grub.cfg
  • Insert the following code at the end, and pay attention to modifying two places: set root and multiboot2
menuentry 'HelloOS' {
     insmod part_msdos            # GRUB loads the partition module to recognize the partition
     insmod ext2                  # GRUB loads the ext file system module to recognize the ext file system
     set root='hd0,msdos4'        # Pay attention to the partition where the boot directory is mounted
     multiboot2 /boot/HelloOS.bin # GRUB loads HelloOS.bin with the multiboot2 protocol
     boot                         # GRUB starts HelloOS.bin
}
  • Refer to this step to modify the content, then open another terminal and observe the result of df /boot/. Pay attention to two places: file system and mount point.
image-20210515092657939
  • File system⭐
    • If it is /dev/sda1, modify set root='hd0,msdos1'
    • If it is not sda [other system environments], it may need to be modified according to the situation [refer to the course comments]
  • Mount point⭐
    • If it is /boot, modify multiboot2 /HelloOS.bin accordingly
    • If it is /, no modification is needed

PS: Use :w! to save and use :q to exit the editor.

image-20210515092718504

Restart the Machine#

  1. Restart the machine and press the shift key [or other keys, such as the esc key] repeatedly before the system is loaded to enter the grub boot menu.
image-20210515092730798
  • Select your system and press the enter key.

  • If an error occurs here, it mainly involves factors such as system type (physical machine, other virtual machine systems), system partition type (UEFI), partition table type (GPT), etc. You can refer to the following reference content👇

Reference Content#

If running in other environments, you can refer to the comments in the course and related blogs.

Scan the code to join:

image-20210523213829681

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.