Skip to content

Commit c391999

Browse files
authored
Update README.md
1 parent e7f9c39 commit c391999

File tree

1 file changed

+111
-2
lines changed

1 file changed

+111
-2
lines changed

README.md

Lines changed: 111 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,111 @@
1-
# easylkb
2-
easylkb - Easy Linux Kernel Builder
1+
# easylkb - Easy Linux Kernel Builder
2+
3+
easylkb is a simple script designed to make Linux Kernel Debugging easier and more accessible.
4+
5+
## How do you install easylkb?
6+
7+
easylkb is best run on a bare metal Linux system. You need the following things installed in order to use it:
8+
9+
- python3
10+
- curl
11+
- gcc
12+
- make
13+
- qemu
14+
15+
You can clone this repo and run from the easylkb directory, or you can install with pip (not yet lol).
16+
17+
```
18+
pip install easylkb
19+
```
20+
21+
## How do you use easylkb?
22+
23+
Build a specific mainline kernel version:
24+
25+
```
26+
easylkb -k 6.2
27+
```
28+
29+
Build some other kernel in a directory:
30+
```
31+
easylkb -p path/to/linux/
32+
```
33+
34+
Command line flags are tied to specific parts of the build process.
35+
36+
To (d)ownload, (c)onfigure, and co(m)pile a kernel
37+
```
38+
easylkb -k 6.2 -dcm
39+
```
40+
41+
To build a Debian (i)mage from this kernel
42+
```
43+
easylkb -k 6.2 -i
44+
```
45+
46+
To (r)un the generated image:
47+
```
48+
easylkb -k 6.2 -r
49+
```
50+
51+
Combine all of these steps into one:
52+
```
53+
easylkb -k 6.2 -a
54+
```
55+
56+
When it's running, it will run qemu with the Debian image and expose ssh and GDB debugging features accessible via localhost.
57+
58+
## How Do I Interact With The Image?
59+
60+
The image, keys, and run script are stored in the img/ directory within the kernel source.
61+
62+
You can ssh into your image like so:
63+
```
64+
ssh root@localhost -p 10021 -i ~/kernel/linux-6.2/img/bullseye.id_rsa
65+
```
66+
67+
The default login for the resulting image is the user "root" with no password.
68+
69+
This is an example ssh config entry for the resulting image, which you can add to your `~/.ssh/config` file.
70+
```
71+
Host linux62
72+
HostName localhost
73+
User root
74+
Port 10021
75+
IdentityFile ~/kernel/linux-6.2/img/bullseye.id_rsa
76+
StrictHostKeyChecking no
77+
```
78+
79+
Now you can ssh into your kernel by doing:
80+
```
81+
ssh linux62
82+
```
83+
84+
You can scp files by doing
85+
```
86+
scp myfile.bin linux62:
87+
```
88+
89+
## Kernel Debugging
90+
91+
To debug the kernel, you need `$KERNEL_DIR/scripts/gdb/vmlinux-gdb.py`
92+
93+
Add this to your `~/.gdbinit` file if you want to debug this kernel, changing the path to the kernel source you're working with.
94+
```
95+
add-auto-load-safe-path /home/user/kernel/linux-6.2/scripts/gdb/vmlinux-gdb.py
96+
```
97+
98+
Now to debug just do
99+
```
100+
cd /path/to/your/kernel/
101+
gdb ./vmlinux
102+
```
103+
Once you're in gdb just do this:
104+
```
105+
(gdb) lx-symbols
106+
(gdb) target remote :1234
107+
```
108+
Wow! You're debugging the kernel you just built, pretty neat.
109+
110+
For more info on kernel debugging with gdb:
111+
- https://docs.kernel.org/dev-tools/gdb-kernel-debugging.html

0 commit comments

Comments
 (0)