Booting Linux in QEMU and Writing PID 1 in Go to Illustrate Kernel as Program

https://news.ycombinator.com/rss Hits: 13
Summary

Most books and courses introduce Linux through shell commands, leaving the kernel as a mysterious black box doing magic behind the scenes. In this post, we will run some experiments to demystify it: the Linux kernel is just a binary that you can build and run. The experiments are designed so you can follow along if you have a Linux PC. But this is completely optional, the goal is to build a mental model about how Linux works, seeing how components of the system fit together. But first let鈥檚 talk about what a kernel is. What is a kernel? Computers are built from CPUs, memory, and other devices, like video cards, network cards, keyboards, displays, and a lot of other stuff. These devices can be manufactured by different companies, have different capabilities, and can be programmed differently. An operating system kernel provides an abstraction to use these devices and resources conveniently and securely. Without one, writing programs would be much more difficult. We would need to write the low-level code to use every device that our program needs, and it鈥檚 likely that it wouldn鈥檛 work on other computers. A kernel gives us APIs to interact with the hardware over a unified interface manages how programs can use the computer鈥檚 CPU, memory and other resources provides access control over what resources can a program access provides additional features like firewalls, file systems, mechanisms for programs to communicate, etc. The closest analogy from the software development world is that the kernel is a runtime for our computer. Where is the kernel? On most Linux distributions we will find the kernel under the /boot directory. Let鈥檚 enter the directory and list its contents: ~$ cd /boot /boot$ ls -1 System.map-6.12.43+deb13-amd64 System.map-6.12.48+deb13-amd64 config-6.12.43+deb13-amd64 config-6.12.48+deb13-amd64 efi grub initrd.img-6.12.43+deb13-amd64 initrd.img-6.12.48+deb13-amd64 vmlinuz-6.12.43+deb13-amd64 vmlinuz-6.12.48+deb13-amd64 We see a few files here, but the o...

First seen: 2025-12-11 06:36

Last seen: 2025-12-11 18:38