-
Notifications
You must be signed in to change notification settings - Fork 0
/
007.pmd
268 lines (208 loc) · 6.56 KB
/
007.pmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
---
title: "VirtualBox: How to compile Linux Kernel on a Debian Guest"
description:
This page is about how to compile Linux Kernel on Debian VirtualBox Guest (AMD64).
tagline:
Linux, Kernel, VirtualBox, Debian, AMD64.
---
[ℼ](#idxXXX)<br id="idx01">
## Debian Packages
* See <https://doit.vlsm.org/026.html#idx02> for more details.
[ℼ](#)<br id="idx02">
## Download Latest STABLE Kernel
* Fetch the latest STABLE kernel from <https://kernel.org/>.
```
# START =============================================================
# VARIABLES
STABLE=$(wget -O - -o /dev/null https://www.kernel.org/finger_banner | awk '/stable/ {print $NF; exit}')
MAJOR=$(echo $STABLE | cut -d. -f1)
URL="https://kernel.org/pub/linux/kernel/v$MAJOR.x"
KERNEL="linux-$STABLE.tar.xz"
TARBALL="linux-$STABLE.tar"
PGP="linux-$STABLE.tar.sign"
KURL="$URL/$KERNEL"
PURL="$URL/$PGP"
# ===================================================================
# Download the latest stable kernel tarball
wget -c $KURL
# ===================================================================
# Download the signature
wget -c $PURL
# ===================================================================
# Locate and import the PGP keys for verification
gpg --locate-keys [email protected] [email protected]
```
[ℼ](#)<br id="idx02a">
## Sign Key (optional)
```
gpg --sign-key [email protected]
```
[ℼ](#)<br id="idx03">
## Uncompress the file and verify
```
# ===================================================================
# Uncompress the kernel tarball
unxz $KERNEL
# Verify the tarball signature
gpg --verify $PGP $TARBALL
```
[ℼ](#)<br id="idx04">
## Extract TAR file
```
# ===================================================================
# Extract the kernel tarball
tar xvf $TARBALL
# ===================================================================
# Enter the kernel source directory
cd linux-$STABLE
```
[ℼ](#)<br id="idx05">
## Overkilled Cleaning Habit
Once in a while, someone will ask about why not "make distclean,"
or "make mrproper," or "make clean."
Ok, this is the way! [ℼ](#idx10)
```
make distclean; make mrproper; make clean;
```
<br>
<hr>
<br>
[ℼ](#)<br id="idx06a">
## AMD64 Option 1: Reusing ".config" files
* <span style="color:red;font-weight:bold;">If copying a **wrong** ".config" file,
you might create a massive kernel with huge modules.</span>
* Consider copying a working ".config" file from the "/boot/" directory.
* Or, try to [download this ".config" file](assets/configs/config-linux-kernel-amd64.txt)
* See also [Linux/AMD64 Kernel Config for VirtualBox](008.md).
* Or, try to reuse any .config file. [ℼ](#idx10)
* Run:
```
yes "" | make oldconfig
```
[ℼ](#)<br id="idx06b">
## AMD64 OPTION 2: A ".config" file from scratch
* If OPTION 1 failed, consider making a ".config" file from scratch with:
```
make x86_64_defconfig
yes "" | make oldconfig
```
<br>
<hr>
<br>
[ℼ](#)<br id="idx07">
## Menuconfig
```
make menuconfig
```
<br id="idx08">
### E.g., for cbkadal
```
General setup --->
(-cbkadal-10) Local version - append to kernel release
Kernel compression mode (XZ) --->
(cbkadal) Default hostname
<*> Kernel .config support
[*] Enable access to .config through /proc/config.gz
<*> Enable kernel headers through /sys/kernel/kheaders.tar.xz
Processor type and features --->
[ ] EFI runtime service support
[*] Enable loadable module support --->
[*] Module unloading
[*] Forced module unloading
[*] Module versioning support
File systems --->
<*> FUSE (Filesystem in Userspace) support
<*> Character device in Userspace support
<*> Virtio Filesystem
Security options --->
[ ] NSA SELinux Support
[*] AppArmor support
[*] Enable introspection of sha1 hashes for loaded profiles
[*] Enable policy hash introspection by default
First legacy 'major LSM' to be initialized
(X) AppArmor
Kernel hacking --->
printk and dmesg option --->
[*] Enable dynamic printk() support
Compile-time checks and compiler options --->
[*] Install uapi headers to usr/include
```
[ℼ](#)<br id="idx09">
## Compile (make)
```
time make
```
* FYI Compile Time: [ℼ](#idx10)
* (Linux) Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz
* real 3m5.825s
* user 14m51.339s
* sys 1m59.721s
* (Windows 10) Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz
* real 4m17.702s
* user 21m29.718s
* sys 2m21.400s
* (Linux) Lenovo E135 (AMD E2-2000 APU with Radeon(tm) HD Graphics)
* real 123m25,746s
* user 211m58,046s
* sys 28m1,298s
* (Linux) Lenovo Yoga 300 (Intel(R) Celeron(R) CPU N2840 @2.16GHz)
* real 69m6,574s
* user 115m1,006s
* sys 19m12,436s
* (Windows 10) Lenovo Yoga 300 (Intel(R) Celeron(R) CPU N2840 @2.16GHz)
* real 4580m11.804s (<span style="color:red;font-weight:bold;">Yes, there is something wrong here!</span>)
* user 6900m36.555s
* sys 864m34.820s
<br><img src="{{ site.baseurl }}/assets/images/doit-009.jpg" style="width:960px;">
* <span style="color:red;font-weight:bold;">One More Time</span> (after fixing the Windows 10 drivers):
* real 72m26.981s
* user 114m32.041s
* sys 24m54.993s
[ℼ](#)<br id="idx10">
## Install
* Use <span style="color:red;font-weight:bold;">sudo</span> [ℼ](#idx05)
```
# USER: ROOT ============
# Install the modules
sudo make modules_install
# Install the kernel
sudo make install
# Install the headers
sudo make headers_install INSTALL_HDR_PATH=/usr
```
[ℼ](#)<br id="idx11">
## Cleaning
You need to keep some parts of the Linux kernel source. You can delete the rest.
```
make clean
rm -rf arch/[a-u]* arch/xtensa/ block/ certs/ crypto/ Documentation/
rm -rf drivers/ fs/ init/ io_uring/ ipc/ kernel/ lib/ lib/
rm -rf mm/ net/ rust/ samples/ security/ sound/ virt/ usr/
```
<br id="idx12">
## Linux Firmware
* URL: <https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/>
* E.g. TARBALL "linux-firmware-20220509.tar.gz"
* open the TARBALL
* Go to folder "linux-firmware-20220509/"
* Copy the missing modules into "/lib/firmware/". E.g. (ROOT),
```
cp -r i915/ /lib/firmware/
cp -r tigon/ /lib/firmware/
cp -r e100/ /lib/firmware/
cp -r rtl_nic/ /lib/firmware/
```
[ℼ](#)<br id="idx13">
## Old Modules
* You have to delete old modules (/lib/modules) and old config (/boot/) files manually.
Do not forget to "update-grub".
* Visit (ROOT):
```
cd /lib/modules/
ls -al
cd /boot/
ls -al
```
[ℼ](#)<br id="idx14">
{% include inc006.html %}
<br>