Skip to content

Commit 8a34359

Browse files
committed
add boot tiny linux
1 parent f72d64b commit 8a34359

2 files changed

Lines changed: 166 additions & 1 deletion

File tree

_posts/2025/2025-06-01-ubuntu-24-k8s-cluster.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Build a Kubernetes Cluster on Ubuntu 24
33
image: /assets/img/default-banner.jpg
44
author: jack
5-
date: 2025-05-27 20:55:00 +0800
5+
date: 2025-06-01 20:55:00 +0800
66
categories: [blog, linux]
77
tags: [linux]
88
math: false
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
---
2+
title: Build a Kubernetes Cluster on Ubuntu 24
3+
image: /assets/img/default-banner.jpg
4+
author: jack
5+
date: 2025-07-09 20:55:00 +0800
6+
categories: [blog, linux]
7+
tags: [linux]
8+
math: false
9+
pin: false
10+
---
11+
12+
This post documents my process of manually downloading, configuring, and compiling Linux kernel (v6.12) on an Ubuntu 24.04 machine.
13+
14+
## Installing Required Tools
15+
16+
To compile the Linux kernel, several development tools and libraries are needed. You can install them with the apt package manager:
17+
18+
```bash
19+
sudo apt update
20+
sudo apt install -y git build-essential flex bison bc libncurses-dev libssl-dev libelf-dev
21+
````
22+
23+
Brief explanation of each package:
24+
25+
* `build-essential`: Includes `gcc`, `make`, and other essential build tools
26+
* `flex`, `bison`: Needed for building the configuration menu
27+
* `bc`: A math utility used in kernel Makefiles
28+
* `libncurses-dev`: Provides TUI interface for `make menuconfig`
29+
* `libssl-dev`, `libelf-dev`: Required by some optional modules
30+
31+
## Downloading the Linux Kernel Source Code
32+
33+
I chose the latest mainline version, v6.12. Use the following command to clone it:
34+
35+
```bash
36+
git clone --depth=1 --branch=v6.12 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
37+
cd linux
38+
```
39+
40+
The `--depth=1` option fetches only the latest commit, which makes the download faster.
41+
42+
## Generating a Minimal Configuration with tinyconfig
43+
44+
To quickly produce a minimal working kernel, I used `tinyconfig`:
45+
46+
```bash
47+
make tinyconfig
48+
```
49+
50+
This generates a `.config` file that enables only the most essential kernel features.
51+
52+
## Compiling the Linux Kernel
53+
54+
Now compile the kernel:
55+
56+
```bash
57+
make -j$(nproc)
58+
```
59+
60+
`$(nproc)` uses all available CPU cores for faster build.
61+
62+
After compilation, the output image will be located at:
63+
64+
```none
65+
./arch/x86/boot/bzImage
66+
```
67+
68+
`bzImage` is a bootable Linux kernel image, short for "big zImage". It is a self-extracting compressed format mainly used for x86/x86\_64 architectures.
69+
70+
You can check its file type with:
71+
72+
```bash
73+
file arch/x86/boot/bzImage
74+
```
75+
76+
## Booting the Kernel with QEMU
77+
78+
First, install QEMU:
79+
80+
```bash
81+
sudo apt install qemu-system-x86
82+
```
83+
84+
Then boot the kernel:
85+
86+
```bash
87+
qemu-system-x86_64 -kernel arch/x86/boot/bzImage
88+
```
89+
90+
Unfortunately, the screen only showed:
91+
92+
```
93+
Booting from ROM...
94+
```
95+
96+
And nothing else followed—no kernel messages appeared. This usually means the kernel lacks the drivers necessary to output to the display.
97+
98+
> Tip: After clicking into the QEMU window, your mouse will be captured. Press `Ctrl + Alt + G` to release it.
99+
100+
![](https://raw.githubusercontent.com/blueskyson/image-host/master/2025/boot-tiny-linux-1.png)
101+
102+
## Configuring menuconfig
103+
104+
After closing the QEMU window, run `menuconfig` to modify kernel settings (make sure `libncurses-dev` is installed):
105+
106+
```bash
107+
make menuconfig
108+
```
109+
110+
**Enable TTY Support**
111+
112+
Navigate to:
113+
114+
```none
115+
Device Drivers --->
116+
Character devices --->
117+
<*> Enable TTY
118+
```
119+
120+
![](https://raw.githubusercontent.com/blueskyson/image-host/master/2025/boot-tiny-linux-2.png)
121+
122+
> Use arrow keys to navigate and press `Y` or the spacebar to enable the option.
123+
124+
This setting enables support for TTY devices (i.e., text console and serial output).
125+
126+
**Enable printk Support**
127+
128+
Also enable the kernel logging mechanism:
129+
130+
```none
131+
General setup --->
132+
Configure standard kernel features (expert users) --->
133+
[*] Enable support for printk
134+
```
135+
136+
![](https://raw.githubusercontent.com/blueskyson/image-host/master/2025/boot-tiny-linux-3.png)
137+
138+
Save your configuration and recompile:
139+
140+
```bash
141+
make -j$(nproc)
142+
qemu-system-x86_64 -kernel arch/x86/boot/bzImage
143+
```
144+
145+
![](https://raw.githubusercontent.com/blueskyson/image-host/master/2025/boot-tiny-linux-4.png)
146+
147+
Now the terminal finally shows kernel boot messages. Although it ends with:
148+
149+
```
150+
panic - not syncing: No working init found
151+
```
152+
153+
we have successfully booted the kernel and verified output is working.
154+
155+
To fix this panic, you need to provide a valid `init` process (e.g., `systemd` or `busybox`). This will not be covered in this post.
156+
157+
If you want to reset your kernel configuration to a clean tinyconfig state for further experiments, use:
158+
159+
```bash
160+
make mrproper
161+
```
162+
163+
## References
164+
165+
* [Building a tiny Linux from scratch](https://blinry.org/tiny-linux/)

0 commit comments

Comments
 (0)