-
Notifications
You must be signed in to change notification settings - Fork 0
/
011.pmd
236 lines (177 loc) · 5.33 KB
/
011.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
---
title: "UTM MacOS Silicon: How to compile Linux Kernel on a Debian Guest"
description:
This page is about how to compile Linux Kernel on Debian UTM MacOS Silicon Guest (AARCH64).
tagline:
Linux, Kernel, VirtualBox, Debian, AARCH64, ARM64.
---
[ℼ](#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 xf $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="idx06aa">
## ARM64 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-arm64.txt)
* See also [Linux/ARM64 Kernel Config for UTM](010.md).
* Or, try to reuse any .config file [ℼ](#idx10)
* Run:
```
yes "" | make oldconfig
```
[ℼ](#)<br id="idx06bb">
## ARM64 OPTION 2: A ".config" file from scratch
* If OPTION 1 failed, consider making a ".config" file from scratch with:
```
cp arch/arm64/configs/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
(cbkadal) Default hostname
[*] Support initial ramdisk/ramfs compressed using XZ
<*> Kernel .config support
[*] Enable access to .config through /proc/config.gz
<*> Enable kernel headers through /sys/kernel/kheaders.tar.xz
Boot options --->
[*] UEFI runtime support
File systems --->
<*> FUSE (Filesystem in Userspace) support
<*> Character device in Userspace support
<*> Virtio Filesystem
[*] FUSE passthrough operations support
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:
* (Linux) Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz
* real 3m5.825s
* user 14m51.339s
* sys 1m59.721s
[ℼ](#)<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/{alpha, arc, [c-x]*} 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>