Skip to content

Commit 4c312ac

Browse files
committed
Misc - sudo,commit to 6.5.7 kernel,grubby, DEBUG
1 parent 3a8e7c6 commit 4c312ac

File tree

2 files changed

+58
-28
lines changed

2 files changed

+58
-28
lines changed

docs/labs/systems_administration_I/lab7-software_management.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,17 @@ After installing relevant packages, in some cases, we need to determine whether
796796
797797
Using the "-V" option of the `rpm` command.
798798
799-
Take the time synchronization program chrony as an example to illustrate the meaning of its output. It is assumed that you have installed chrony and modified the configuration file (/etc/chrony.conf)
799+
Take the time synchronization program `chrony`` as an example to illustrate the meaning of its output.
800+
801+
802+
1. To demonstrate how the `rpm` package verification works, make a modififcation to chrony's
803+
configuration file - `/etc/chrony.conf`. (It is assumed that you have installed chrony). Add 2 harmless comment `##` symbols to the end of the file. Type:
804+
805+
```
806+
$ echo -e "##" | sudo tee -a /etc/chrony.conf
807+
```
808+
809+
2. Now run the `rpm` command with the `--verify` option. Type:
800810
801811
```
802812
$ rpm -V chrony

docs/labs/systems_administration_II/lab7-the_linux_kernel.md

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
author: Wale Soyinka
3-
contributors: Steven Spencer, Ganna Zhyrnova
43
tested on: All Versions
54
tags:
65
- lab exercise
@@ -95,13 +94,13 @@ In this exercise you will directly upgrade your kernel using the rpm application
9594
2. Run the `rpm` utility to list all kernel packages currently installed on the system. Type:
9695

9796
``` { .sh data-copy="rpm -q kernel" }
98-
[root@localhost ~]# rpm -q kernel
97+
$ rpm -q kernel
9998
```
10099

101100
3. Execute the `uname` utility to view some information about the current running kernel. Type:
102101

103102
``` { .bash data-copy="uname --kernel-release" }
104-
[root@localhost ~]# uname --kernel-release
103+
$ uname --kernel-release
105104
106105
5.*.el9_8.x86_64
107106
```
@@ -111,7 +110,7 @@ In this exercise you will directly upgrade your kernel using the rpm application
111110
4. Use `dnf` to download the latest kernel package available from the official Rocky Linux package repository. Type:
112111
113112
```bash
114-
[root@localhost ~]# dnf download kernel
113+
$ dnf download kernel
115114
```
116115
You should now have an RPM package with a name similar to kernel-*.x86_64.rpm saved in your PWD.
117116
@@ -124,7 +123,7 @@ In this exercise you will directly upgrade your kernel using the rpm application
124123
6. Use `rpm` to do a test install of the downloaded kernel*.rpm to ensure that all its dependencies will be met. Type:
125124
126125
```bash
127-
[root@localhost ~]# rpm --test -ivh kernel-*.x86_64.rpm
126+
$ rpm --test -ivh kernel-*.x86_64.rpm
128127
129128
error: Failed dependencies:
130129
kernel-core-uname-r = *.x86_64 is needed by kernel-*.x86_64
@@ -136,13 +135,13 @@ In this exercise you will directly upgrade your kernel using the rpm application
136135
7. Use `dnf` to download the needed dependencies reported in the previous error message. Type:
137136
138137
```bash
139-
[root@localhost ~]# dnf download kernel-core-uname-r kernel-modules-uname-r
138+
$ dnf download kernel-core-uname-r kernel-modules-uname-r
140139
```
141140
142141
8. Run `rpm` with the test option again to see if the kernel package can be upgraded. Type:
143142
144143
```bash
145-
[root@localhost ~]# rpm --test -Uvh kernel-*.rpm
144+
$ rpm --test -Uvh kernel-*.rpm
146145
147146
Verifying... ################################# [100%]
148147
Preparing... ################################# [100%]
@@ -153,7 +152,7 @@ In this exercise you will directly upgrade your kernel using the rpm application
153152
9. Finally use `rpm` to install the kernel package along with all its dependencies. Type:
154153
155154
```bash
156-
[root@localhost ~]# rpm -ivh kernel-*.rpm
155+
$ sudo rpm -ivh kernel-*.rpm
157156
```
158157
159158
10. Use `rpm` to list all the installed kernel packages on your system.
@@ -232,13 +231,13 @@ In this exercise you will build a new kernel from source, by configuring, compil
232231
2. Install needed development tools. Type:
233232
234233
```bash
235-
[root@localhost linux-6.5.7]# dnf -y groupinstall 'Development Tools'
234+
$ sudo dnf -y groupinstall 'Development Tools'
236235
```
237236
238237
3. Install the needed libraries and tools. Type:
239238
240239
```bash
241-
[root@localhost linux-6.*]# dnf -y install ncurses-devel bc openssl-devel elfutils-libelf-devel python3 dwarves
240+
$ sudo dnf -y install ncurses-devel bc openssl-devel elfutils-libelf-devel python3 dwarves
242241
```
243242
244243
4. Download the latest kernel source by typing:
@@ -263,25 +262,25 @@ In this exercise you will build a new kernel from source, by configuring, compil
263262
8. Change (cd) into the kernel source directory. Type:
264263
265264
```bash
266-
[root@localhost ~]# cd linux-6.*
265+
$ cd linux-6.5.7
267266
```
268267
269268
9. Clean (prepare) the kernel build environment by using the `make mrproper` command. Type:
270269
271270
```bash
272-
[root@localhost ~]# make O=~/build/kernel mrproper
271+
$ make O=~/build/kernel mrproper
273272
```
274273
275274
10. Copy over and rename the preexisting configuration file from the /boot directory into our kernel build environment:
276275
277276
```bash
278-
[root@localhost ~]# cp /boot/config-`uname -r` ~/build/kernel/.config
277+
$ cp /boot/config-`uname -r` ~/build/kernel/.config
279278
```
280279
281280
11. Launch the graphical kernel configuration utility. Type:
282281
283282
```bash
284-
[root@localhost ~]# make O=~/build/kernel menuconfig
283+
$ make O=~/build/kernel menuconfig
285284
```
286285
A screen similar to this will appear:
287286
@@ -329,37 +328,51 @@ In this exercise you will build a new kernel from source, by configuring, compil
329328
330329
18. Let's optimize the kernel build time and also reduce the amount of disk space used during the kernel compile stage by setting. By setting `CONFIG_DEBUG_INFO=no`, the resulting kernel image will NOT include debugging info thereby resulting in a smaller kernel image. This removes debugging symbols from the built kernel and modules. Type:
331330
332-
```bash
333-
# sed -ri '/CONFIG_DEBUG_INFO/s/=.+/="no"/g' ~/build/kernel/.config
331+
```bash
332+
$ ./scripts/config --file ~/build/kernel/.config -d DEBUG_INFO \
333+
-d DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT -d DEBUG_INFO_DWARF4 \
334+
-d DEBUG_INFO_DWARF5 -e CONFIG_DEBUG_INFO_NONE
334335
```
335336
336337
19. Complete another important step for custom Kernels on Rocky Linux distro. Type:
337338
338339
339340
```bash
340-
[root@localhost linux-6*]# sed -ri '/CONFIG_SYSTEM_TRUSTED_KEYS/s/=.+/=""/g' ~/build/kernel/.config
341+
$ sed -ri '/CONFIG_SYSTEM_TRUSTED_KEYS/s/=.+/=""/g' ~/build/kernel/.config
341342
```
342343
343344
20. Add a simple customization to the new kernel, allowing you to distinguish it from the other stock Kernels more easily. For this, use the `sed` utility to edit the Makefile in place. Type:
344345
345346
```bash
346-
[root@localhost linux-6.*]# sed -i 's/^EXTRAVERSION.*/EXTRAVERSION = -custom/' Makefile
347+
$ sed -i 's/^EXTRAVERSION.*/EXTRAVERSION = -custom/' Makefile
347348
```
348349
349350
21. Verify the full version of the kernel that you just customized by passing the `kernelversion` target to the `make` command. Type:
350351
351352
```bash
352-
[root@localhost ~]# make O=~/build/kernel kernelversion
353+
$ make O=~/build/kernel kernelversion
354+
```
355+
356+
OUTPUT:
357+
```
358+
make[1]: Entering directory '/home/rocky/build/kernel'
359+
6.5.7-custom
360+
make[1]: Leaving directory '/home/rocky/build/kernel'
353361
```
354362
355363
22. You are ready to compile the kernel. Type:
356364
357365
```bash
358-
[root@localhost linux-6.*]# make O=~/build/kernel -j $(nproc)
366+
$ sudo make O=~/build/kernel -j $(nproc)
367+
```
368+
369+
OUTPUT:
370+
```
359371
make[1]: Entering directory '/root/build/kernel'
360372
SYNC include/config/auto.conf.cmd
361373
GEN Makefile
362374
HOSTCC scripts/kconfig/conf.o
375+
...
363376
```
364377
365378
23. After the compilation completes successfully, you'll end up with the finished kernel stored here:
@@ -371,41 +384,48 @@ In this exercise you will build a new kernel from source, by configuring, compil
371384
24. Install the portions of the kernel that were configured as modules. Type:
372385
373386
```bash
374-
[root@localhost linux-6.*]# make O=~/build/kernel modules_install
387+
$ sudo make O=~/build/kernel modules_install
375388
```
376389
377390
25. With the kernel now built it's time to install it. Type:
378391
379392
```bash
380-
[root@localhost linux-6.*]# cp ~/build/kernel/arch/x86/boot/bzImage \
393+
$ sudo cp ~/build/kernel/arch/x86/boot/bzImage \
381394
/boot/vmlinuz-<kernel-version>
382395
```
383396
384397
Replace <kernel-version> with the version number of your custom kernel.
385398
For the sample kernel we are using in this guide, the filename would be vmlinuz-6.*-custom. So here’s the exact command for this example:
386399
387400
```bash
388-
cp ~/build/kernel/arch/x86/boot/bzImage /boot/vmlinuz-6.*-custom
401+
sudo cp ~/build/kernel/arch/x86/boot/bzImage /boot/vmlinuz-6.5.7-custom
389402
```
390403
391404
26. Copy over and rename the corresponding System.map file into the /boot directory using the same naming convention:
392405
393406
```bash
394-
[root@localhost linux-6.*]# cp -v ~/build/kernel/System.map /boot/System.map-6.*-custom
407+
$ sudo cp -v ~/build/kernel/System.map /boot/System.map-6.5.7-custom
395408
```
396409
397410
27. Use the `kernel-install` utility to complete the file step. Type:
398411
399412
```bash
400-
[root@localhost linux-6.*]# kernel-install add 6.*-custom /boot/vmlinuz-6.*-custom
413+
$ sudo kernel-install add 6.5.7-custom /boot/vmlinuz-6.5.7-custom
401414
```
402415
403416
28. The `kernel-install` utility will create a new boot entry in the boot loader configuration file. For EFI based systems you can look under /boot/loader/entries/ for matching entries.
417+
418+
29. Run the grubby program to view the default kernel for the server. Type:
419+
420+
```
421+
$ sudo grubby --default-kernel
422+
```
404423
405-
29. All done. Moment of truth now. You can reboot your system and select the new custom Kernel in the GRUB boot menu.
424+
30. All done. Moment of truth now. The latest kernel will likely be configured as the new
425+
default kernel to boot into. If you have access to the system's console you can reboot your system and select the new custom Kernel in the GRUB boot menu.
406426
If all goes well after the reboot, you can verify that system is running the custom kernel by running the `uname` command like this:
407427
408428
```bash
409-
[root@localhost linux-6.*]# uname -r
429+
$ uname -r
410430
```
411431

0 commit comments

Comments
 (0)