201.2. Compiling a kernel

201.2 Compiling a kernel

Weight: 3

Description: Candidates should be able to properly configure a kernel to include or disable specific features of the Linux kernel as necessary. This objective includes compiling and recompiling the Linux kernel as needed, updating and noting changes in a new kernel, creating an initrd image and installing new kernels.
Key Knowledge Areas:
    /usr/src/linux/
    Kernel Makefiles
    Kernel 2.6.x/3.x make targets
    Customize the current kernel configuration.
    Build a new kernel and appropriate kernel modules.
    Install a new kernel and any modules.
    Ensure that the boot manager can locate the new kernel and associated files.
    Module configuration files
    Use DKMS to compile kernel modules.
    Awareness of dracut
Terms and Utilities:
    mkinitrd
    mkinitramfs
    make
    make targets (all, config, xconfig, menuconfig, gconfig, oldconfig, mrproper, zImage, bzImage, modules, modules_install, rpm-pkg, binrpm-pkg, deb-pkg)
    gzip
    bzip2
    module tools
    /usr/src/linux/.config
    /lib/modules/kernel-version/
    depmod
    dkms

Kernel

Why we should compile our linux kernel or upgrade it ? to tell the truth as linux kernel is so modular and flexible, most of the time there is no need to manipulate kernel. Specially When we are talking about commercial versions of linux like redhat, manipulating kernel cause support issues. In contrast in embedded linux system, you should try to make kernel as small as possible. So compile or upgrade kernel just if there is a good reason.
Upgrading kernel and compiling it is very distro specific. The way that we traverse to achive that might be different in Ubuntu, Open Suse or cent OS. Upgrading kernel include compiling, so here we start with downloading new version of kernel and compiling it, but as an administrator you might recompile current version of your linux inorder to add / remove some modules and futures.

Upgrading kernel

First go to https://kernel.org inorder to get the desired kernel version:
We chose latest stable kernel version, do not forget we have to be in /usr/src/ and from now on work in this directory only, in this demonstartion we use CentOS7 machine:
1
[[email protected] ~]# cd /usr/src/
2
[[email protected] src]# ls -l
3
total 0
4
drwxr-xr-x. 2 root root 6 Nov 5 2016 debug
5
drwxr-xr-x. 2 root root 6 Nov 5 2016 kernels
6
[[email protected] src]# wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.14.3.tar.xz
7
--2017-12-04 08:34:00-- https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.14.3.tar.xz
8
Resolving cdn.kernel.org (cdn.kernel.org)... 151.101.1.176, 151.101.65.176, 151.101.129.176, ...
9
Connecting to cdn.kernel.org (cdn.kernel.org)|151.101.1.176|:443... connected.
10
HTTP request sent, awaiting response... 200 OK
11
Length: 100778240 (96M) [application/x-xz]
12
Saving to: ‘linux-4.14.3.tar.xz’
13
14
100%[=============================================>] 100,778,240 247KB/s in 8m 15s
15
16
2017-12-04 08:42:20 (199 KB/s) - ‘linux-4.14.3.tar.xz’ saved [100778240/100778240]
17
18
[[email protected] src]# ls -l
19
total 98420
20
drwxr-xr-x. 2 root root 6 Nov 5 2016 debug
21
drwxr-xr-x. 2 root root 6 Nov 5 2016 kernels
22
-rw-r--r--. 1 root root 100778240 Nov 30 03:52 linux-4.14.3.tar.xz
Copied!
Now lets extract .xz file. Also we should make a symbolic link as linux which point to downloaded kernel:
1
[[email protected] src]# tar -Jxvf linux-4.14.3.tar.xz
2
********
3
******
4
****
5
**
6
[[email protected] src]# ls -l
7
total 98424
8
drwxr-xr-x. 2 root root 6 Nov 5 2016 debug
9
drwxr-xr-x. 2 root root 6 Nov 5 2016 kernels
10
drwxrwxr-x. 24 root root 4096 Nov 30 03:41 linux-4.14.3
11
-rw-r--r--. 1 root root 100778240 Nov 30 03:52 linux-4.14.3.tar.xz
12
[[email protected] src]# ln -s linux-4.14.3 linux
13
[[email protected] src]# ls -l
14
total 98424
15
drwxr-xr-x. 2 root root 6 Nov 5 2016 debug
16
drwxr-xr-x. 2 root root 6 Nov 5 2016 kernels
17
lrwxrwxrwx. 1 root root 12 Dec 4 08:48 linux -> linux-4.14.3
18
drwxrwxr-x. 24 root root 4096 Nov 30 03:41 linux-4.14.3
19
-rw-r--r--. 1 root root 100778240 Nov 30 03:52 linux-4.14.3.tar.xz
Copied!
Before continue there is document folder inside downloaded kernel, There are amazing help text file:
1
[[email protected] src]# cd linux/Documentation/
2
[[email protected] Documentation]# ls
3
00-INDEX gpio parport-lowlevel.txt
4
ABI gpu PCI
5
accounting hid pcmcia
6
acpi highuid.txt percpu-rw-semaphore.txt
7
admin-guide hwmon perf
8
aoe hw_random.txt phy
9
arm hwspinlock.txt phy.txt
10
arm64 i2c pi-futex.txt
11
atomic_bitops.txt ia64 platform
12
atomic_t.txt ide pnp.txt
13
auxdisplay iio power
14
backlight index.rst powerpc
15
bcache.txt infiniband pps
16
blackfin input preempt-locking.txt
17
block Intel-IOMMU.txt printk-formats.txt
18
blockdev intel_txt.txt process
19
bt8xxgpio.txt ioctl pti
20
btmrvl.txt io-mapping.txt ptp
21
bus-devices io_ordering.txt pwm.txt
22
bus-virt-phys-mapping.txt iostats.txt rapidio
23
cachetlb.txt IPMI.txt rbtree.txt
24
cdrom IRQ-affinity.txt RCU
25
cgroup-v1 IRQ-domain.txt remoteproc.txt
26
cgroup-v2.txt irqflags-tracing.txt rfkill.txt
27
Changes IRQ.txt robust-futex-ABI.txt
28
circular-buffers.txt isapnp.txt robust-futexes.txt
29
clk.txt isa.txt rpmsg.txt
30
cma isdn rtc.txt
31
CodingStyle kbuild s390
32
conf.py kdump SAK.txt
33
connector kernel-doc-nano-HOWTO.txt scheduler
34
console kernel-hacking scsi
35
core-api kernel-per-CPU-kthreads.txt security
36
cpu-freq kobject.txt serial
37
cpuidle kprobes.txt sgi-ioc4.txt
38
cpu-load.txt kref.txt sh
39
cputopology.txt laptops siphash.txt
40
crc32.txt ldm.txt SM501.txt
41
cris leds smsc_ece1099.txt
42
crypto lightnvm sound
43
dcdbas.txt livepatch sparc
44
debugging-modules.txt locking sphinx
45
debugging-via-ohci1394.txt lockup-watchdogs.txt sphinx-static
46
dell_rbu.txt logo.gif spi
47
device-mapper logo.txt static-keys.txt
48
devicetree lsm.txt SubmittingPatches
49
dev-tools lzo.txt svga.txt
50
digsig.txt m68k switchtec.txt
51
DMA-API-HOWTO.txt mailbox.txt sync_file.txt
52
DMA-API.txt Makefile sysctl
53
DMA-attributes.txt md target
54
dmaengine media tee.txt
55
DMA-ISA-LPC.txt memory-barriers.txt thermal
56
doc-guide memory-devices this_cpu_ops.txt
57
docutils.conf memory-hotplug.txt timers
58
dontdiff men-chameleon-bus.txt trace
59
driver-api metag translations
60
driver-model mic unaligned-memory-access.txt
61
early-userspace mips usb
62
EDID misc-devices userspace-api
63
efi-stub.txt mmc vfio-mediated-device.txt
64
eisa.txt mn10300 vfio.txt
65
errseq.rst mtd video-output.txt
66
extcon namespaces virtual
67
fault-injection netlabel vm
68
fb networking w1
69
features nfc watchdog
70
filesystems nios2 wimax
71
firmware_class nommu-mmap.txt x86
72
flexible-arrays.txt ntb.txt xillybus.txt
73
fmc numastat.txt xtensa
74
fpga nvdimm xz.txt
75
frv nvmem zorro.txt
76
futex-requeue-pi.txt padata.txt
77
gcc-plugins.txt parisc
Copied!
Before continue there are some Development tools which is need to compile the kernel lets install them first:
1
[[email protected] linux]# yum groupinstall "Development tools"
2
[[email protected] ~]# yum install elfutils-libelf-devel
Copied!
Next step is making kernel with modules that we like, compile it and make other kernel required components. to do do that we use make. make is a command that make a program from the source code. Make can do somany thing and is used for many targets.
1
[[email protected] ~]# cd /usr/src/linux
2
[[email protected] linux]# make help
3
./scripts/gcc-version.sh: line 26: gcc: command not found
4
./scripts/gcc-version.sh: line 27: gcc: command not found
5
make: gcc: Command not found
6
make: gcc: Command not found
7
Cleaning targets:
8
clean - Remove most generated files but keep the config and
9
enough build support to build external modules
10
mrproper - Remove all generated files + config + various backup files
11
distclean - mrproper + remove editor backup and patch files
12
13
Configuration targets:
14
config - Update current config utilising a line-oriented program
15
nconfig - Update current config utilising a ncurses menu based
16
program
17
menuconfig - Update current config utilising a menu based program
18
xconfig - Update current config utilising a Qt based front-end
19
gconfig - Update current config utilising a GTK+ based front-end
20
oldconfig - Update current config utilising a provided .config as base
21
localmodconfig - Update current config disabling modules not loaded
22
localyesconfig - Update current config converting local mods to core
23
silentoldconfig - Same as oldconfig, but quietly, additionally update deps
24
defconfig - New config with default from ARCH supplied defconfig
25
savedefconfig - Save current config as ./defconfig (minimal config)
26
allnoconfig - New config where all options are answered with no
27
allyesconfig - New config where all options are accepted with yes
28
allmodconfig - New config selecting modules when possible
29
alldefconfig - New config with all symbols set to default
30
randconfig - New config with random answer to all options
31
listnewconfig - List new options
32
olddefconfig - Same as silentoldconfig but sets new symbols to their
33
default value
34
kvmconfig - Enable additional options for kvm guest kernel support
35
xenconfig - Enable additional options for xen dom0 and guest kernel support
36
tinyconfig - Configure the tiniest possible kernel
37
38
Other generic targets:
39
all - Build all targets marked with [*]
40
* vmlinux - Build the bare kernel
41
* modules - Build all modules
42
modules_install - Install all modules to INSTALL_MOD_PATH (default: /)
43
dir/ - Build all files in dir and below
44
dir/file.[ois] - Build specified target only
45
dir/file.ll - Build the LLVM assembly file
46
(requires compiler support for LLVM assembly generation)
47
dir/file.lst - Build specified mixed source/assembly target only
48
(requires a recent binutils and recent build (System.map))
49
dir/file.ko - Build module including final link
50
modules_prepare - Set up for building external modules
51
tags/TAGS - Generate tags file for editors
52
cscope - Generate cscope index
53
gtags - Generate GNU GLOBAL index
54
kernelrelease - Output the release version string (use with make -s)
55
kernelversion - Output the version stored in Makefile (use with make -s)
56
image_name - Output the image name (use with make -s)
57
headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH
58
(default: ./usr)
59
60
Static analysers:
61
checkstack - Generate a list of stack hogs
62
namespacecheck - Name space analysis on compiled kernel
63
versioncheck - Sanity check on version.h usage
64
includecheck - Check for duplicate included header files
65
export_report - List the usages of all exported symbols
66
headers_check - Sanity check on exported headers
67
headerdep - Detect inclusion cycles in headers
68
coccicheck - Check with Coccinelle.
69
70
Kernel selftest:
71
kselftest - Build and run kernel selftest (run as root)
72
Build, install, and boot kernel before
73
running kselftest on it
74
kselftest-clean - Remove all generated kselftest files
75
kselftest-merge - Merge all the config dependencies of kselftest to existing
76
.config.
77
78
Userspace tools targets:
79
use "make tools/help"
80
or "cd tools; make help"
81
82
Kernel packaging:
83
rpm-pkg - Build both source and binary RPM kernel packages
84
binrpm-pkg - Build only the binary kernel RPM package
85
deb-pkg - Build both source and binary deb kernel packages
86
bindeb-pkg - Build only the binary kernel deb package
87
tar-pkg - Build the kernel as an uncompressed tarball
88
targz-pkg - Build the kernel as a gzip compressed tarball
89
tarbz2-pkg - Build the kernel as a bzip2 compressed tarball
90
tarxz-pkg - Build the kernel as a xz compressed tarball
91
perf-tar-src-pkg - Build perf-4.14.3.tar source tarball
92
perf-targz-src-pkg - Build perf-4.14.3.tar.gz source tarball
93
perf-tarbz2-src-pkg - Build perf-4.14.3.tar.bz2 source tarball
94
perf-tarxz-src-pkg - Build perf-4.14.3.tar.xz source tarball
95
96
Documentation targets:
97
Linux kernel internal documentation in different formats from ReST:
98
htmldocs - HTML
99
latexdocs - LaTeX
100
pdfdocs - PDF
101
epubdocs - EPUB
102
xmldocs - XML
103
linkcheckdocs - check for broken external links (will connect to external hosts)
104
cleandocs - clean all generated files
105
106
make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2
107
valid values for SPHINXDIRS are: networking input core-api userspace-api media process sound crypto sh dev-tools doc-guide driver-api filesystems kernel-hacking admin-guide gpu
108
109
make SPHINX_CONF={conf-file} [target] use *additional* sphinx-build
110
configuration. This is e.g. useful to build with nit-picking config.
111
112
Architecture specific targets (x86):
113
* bzImage - Compressed kernel image (arch/x86/boot/bzImage)
114
install - Install kernel using
115
(your) ~/bin/installkernel or
116
(distribution) /sbin/installkernel or
117
install to $(INSTALL_PATH) and run lilo
118
fdimage - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)
119
fdimage144 - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)
120
fdimage288 - Create 2.8MB boot floppy image (arch/x86/boot/fdimage)
121
isoimage - Create a boot CD-ROM image (arch/x86/boot/image.iso)
122
bzdisk/fdimage*/isoimage also accept:
123
FDARGS="..." arguments for the booted kernel
124
FDINITRD=file initrd for the booted kernel
125
126
i386_defconfig - Build for i386
127
x86_64_defconfig - Build for x86_64
128
129
make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build
130
make V=2 [targets] 2 => give reason for rebuild of target
131
make O=dir [targets] Locate all output files in "dir", including .config
132
make C=1 [targets] Check re-compiled c source with $CHECK (sparse by default)
133
make C=2 [targets] Force check of all c source with $CHECK
134
make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections
135
make W=n [targets] Enable extra gcc checks, n=1,2,3 where
136
1: warnings which may be relevant and do not occur too often
137
2: warnings which occur quite often but may still be relevant
138
3: more obscure warnings, can most likely be ignored
139
Multiple levels can be combined with W=12 or W=123
140
141
Execute "make" or "make all" to build all targets marked with [*]
142
For further info see the ./README file
Copied!
Lets classified each target with it usefull commands:
Cleaning Targets (used if you have tried to compile before)
Description
clean
Remove partially Generated Files From Previous compile and refresh the code but keeps config file
mrproper
clean everything + config + backup
Configuration Targets(To configure desired kernel modules)
Description
config
line oriented program, take days (very hard tool)
nconfig
ncurses based menu program (hard tool) [need to nstall ncurses-devel]
menuconfig
menu base program (recommanded tool)
xconfig
QT-Based menu program, like menu config [need to install qt-devel]
oldconfig
use the current setting of current kernel for the next one
The thing we are going to do is making kernel image (zImage / BigzImage if you remember :) )and we need to make modules that should be available in the kernel. Final step is installation process. Because we need to put what we have made in proper place. Let take a look at make xconfig , make menuconfig:
No matter what you choose, a module can have different states:
Condition To choose
Description
<>:Not Available
not even compiled to the kernel
<M>:Loadable as module
compiled with the new kernel, but not loaded as default
<*>:available
Compiled and loaded , Built into the kernel
We are happy with current kernel configuration so lets try:
1
[[email protected] src]#make oldconfig
Copied!
Wow after answering tons of questions finall:
1
#
2
# configuration written to .config
3
#
Copied!

Make bzImage

1
[[email protected] linux]# make bzImage
2
scripts/kconfig/conf --silentoldconfig Kconfig
3
4
SYSTBL arch/x86/entry/syscalls/../../include/generated/asm/syscalls_32.h
5
SYSHDR arch/x86/entry/syscalls/../../include/generated/asm/unistd_32_ia32.h
6
SYSHDR arch/x86/entry/syscalls/../../include/generated/asm/unistd_64_x32.h
7
SYSTBL arch/x86/entry/syscalls/../../include/generated/asm/syscalls_64.h
8
HYPERCALLS arch/x86/entry/syscalls/../../include/generated/asm/xen-hypercalls.h
9
SYSHDR arch/x86/entry/syscalls/../../include/generated/uapi/asm/unistd_32.h
10
SYSHDR arch/x86/entry/syscalls/../../include/generated/uapi/asm/unistd_64.h
11
SYSHDR arch/x86/entry/syscalls/../../include/generated/uapi/asm/unistd_x32.h
12
HOSTCC scripts/basic/bin2c
13
HOSTCC arch/x86/tools/relocs_32.o
14
HOSTCC arch/x86/tools/relocs_64.o
15
HOSTCC arch/x86/tools/relocs_common.o
16
HOSTLD arch/x86/tools/relocs
17
CHK include/config/kernel.release
18
UPD include/config/kernel.release
19
WRAP arch/x86/include/generated/asm/clkdev.h
20
WRAP arch/x86/include/generated/asm/dma-contiguous.h
21
WRAP arch/x86/include/generated/asm/early_ioremap.h
22
WRAP arch/x86/include/generated/asm/mcs_spinlock.h
23
WRAP arch/x86/include/generated/asm/mm-arch-hooks.h
24
CHK include/generated/uapi/linux/version.h
25
UPD include/generated/uapi/linux/version.h
26
CHK include/generated/utsrelease.h
27
UPD include/generated/utsrelease.h
28
CC arch/x86/purgatory/purgatory.o
29
AS arch/x86/purgatory/stack.o
30
AS arch/x86/purgatory/setup-x86_64.o
31
CC arch/x86/purgatory/sha256.o
32
AS arch/x86/purgatory/entry64.o
33
CC arch/x86/purgatory/string.o
34
LD arch/x86/purgatory/purgatory.ro
35
BIN2C arch/x86/purgatory/kexec-purgatory.c
36
CC kernel/bounds.s
37
CHK include/generated/bounds.h
38
UPD include/generated/bounds.h
39
CHK include/generated/timeconst.h
40
UPD include/generated/timeconst.h
41
CC arch/x86/kernel/asm-offsets.s
42
CHK include/generated/asm-offsets.h
43
UPD include/generated/asm-offsets.h
44
CALL scripts/checksyscalls.sh
45
HOSTCC scripts/genksyms/genksyms.o
46
SHIPPED scripts/genksyms/parse.tab.c
47
HOSTCC scripts/genksyms/parse.tab.o
48
SHIPPED scripts/genksyms/lex.lex.c
49
SHIPPED scripts/genksyms/parse.tab.h
50
HOSTCC scripts/genksyms/lex.lex.o
51
HOSTLD scripts/genksyms/genksyms
52
CC scripts/mod/empty.o
53
HOSTCC scripts/mod/mk_elfconfig
54
MKELF scripts/mod/elfconfig.h
55
HOSTCC scripts/mod/modpost.o
56
CC scripts/mod/devicetable-offsets.s
57
CHK scripts/mod/devicetable-offsets.h
58
UPD scripts/mod/devicetable-offsets.h
59
HOSTCC scripts/mod/file2alias.o
60
HOSTCC scripts/mod/sumversion.o
61
HOSTLD scripts/mod/modpost
62
HOSTCC scripts/selinux/genheaders/genheaders
63
HOSTCC scripts/selinux/mdp/mdp
64
HOSTCC scripts/kallsyms
65
HOSTCC scripts/pnmtologo
66
HOSTCC scripts/conmakehash
67
HOSTCC scripts/recordmcount
68
HOSTCC scripts/sortextable
69
HOSTCC scripts/asn1_compiler
70
HOSTCC scripts/sign-file
71
scripts/sign-file.c:25:30: fatal error: openssl/opensslv.h: No such file or directory
72
#include <openssl/opensslv.h>
73
^
74
compilation terminated.
75
make[1]: *** [scripts/sign-file] Error 1
76
make: *** [scripts] Error 2
Copied!
ops we encounter a problem, lets resolve it:
1
[[email protected] linux]# yum install openssl-devel
Copied!
And Finally our bzImage is ready:
1
.....
2
...
3
..
4
Setup is 16860 bytes (padded to 16896 bytes).
5
System is 6386 kB
6
CRC e17db93b
7
Kernel: arch/x86/boot/bzImage is ready (#1)
Copied!

make modules

Modules need to be compiled too, so do the same thing for them:
1
[[email protected] linux]# make modules
2
........
3
....
4
..
5
CC sound/usb/snd-usbmidi-lib.mod.o
6
LD [M] sound/usb/snd-usbmidi-lib.ko
7
CC sound/usb/usx2y/snd-usb-us122l.mod.o
8
LD [M] sound/usb/usx2y/snd-usb-us122l.ko
9
CC sound/usb/usx2y/snd-usb-usx2y.mod.o
10
LD [M] sound/usb/usx2y/snd-usb-usx2y.ko
11
CC virt/lib/irqbypass.mod.o
12
LD [M] virt/lib/irqbypass.ko
Copied!

make modules_install

Now that every thing is prepared, its time to put all part to the their right places, First let put compiled modules to /lib/modules/
1
......
2
....
3
..
4
INSTALL sound/soc/snd-soc-core.ko
5
INSTALL sound/soundcore.ko
6
INSTALL sound/synth/emux/snd-emux-synth.ko
7
INSTALL sound/synth/snd-util-mem.ko
8
INSTALL sound/usb/6fire/snd-usb-6fire.ko
9
INSTALL sound/usb/bcd2000/snd-bcd2000.ko
10
INSTALL sound/usb/caiaq/snd-usb-caiaq.ko
11
INSTALL sound/usb/hiface/snd-usb-hiface.ko
12
INSTALL sound/usb/line6/snd-usb-line6.ko
13
INSTALL sound/usb/line6/snd-usb-pod.ko
14
INSTALL sound/usb/line6/snd-usb-podhd.ko
15
INSTALL sound/usb/line6/snd-usb-toneport.ko
16
INSTALL sound/usb/line6/snd-usb-variax.ko
17
INSTALL sound/usb/misc/snd-ua101.ko
18
INSTALL sound/usb/snd-usb-audio.ko
19
INSTALL sound/usb/snd-usbmidi-lib.ko
20
INSTALL sound/usb/usx2y/snd-usb-us122l.ko
21
INSTALL sound/usb/usx2y/snd-usb-usx2y.ko
22
INSTALL virt/lib/irqbypass.ko
23
DEPMOD 4.14.3
Copied!
to confirm what has been done:
1
[[email protected] linux]# ls -lrth /lib/modules
2
total 8.0K
3
drwxr-xr-x. 7 root root 4.0K Oct 28 11:25 3.10.0-693.el7.x86_64
4
drwxr-xr-x. 3 root root 4.0K Dec 5 07:14 4.14.3
Copied!

make install

make install write required files into the /boot and modified grub and set everything for us
1
[[email protected] linux]# make install
2
sh ./arch/x86/boot/install.sh 4.14.3 arch/x86/boot/bzImage \
3
System.map "/boot"
4
[[email protected] linux]# uname -r
5
3.10.0-693.el7.x86_64
Copied!
and reboot and enjoy your new kernel!
1
[[email protected] ~]# uname -r
2
4.14.3
Copied!

dracut

As we have seen kernel needs RAM to be populated with some drivers and modules.In old days each distro tries to implement its own taste of initrd/initramfs. It made hard for users and developers to work with each distro. dracut is a tool which has tried to standardize the process of making initrd/initramfs.
dracut uses udev deamon events (uevents) and based on them create general purpose initramfs. All we need to know is that dracut is a program wich is used behind kernel installation process to create initrd/initramfs. It considers current kernel and settings and generates desired initramfs/initrd base on them and put initramfs/initrd on the right place and modified grub.
dracut also can be used to just modifying initrd/initramfs:
1
###in ubuntu
3
The program 'dracut' is currently not installed. You can install it by typing:
4
apt install dracut-core
5
[email protected]:~# apt install dracut-core
Copied!
dracut reads its configurations from /etc/dracut.conf :
1
[[email protected] ~]# vi /etc/dracut.conf
Copied!
1
# PUT YOUR CONFIG HERE OR IN separate files named *.conf
2
# in /etc/dracut.conf.d
3
# SEE man dracut.conf(5)
4
5
# Sample dracut config file
6
7
#logfile=/var/log/dracut.log
8
#fileloglvl=6
9
10
# Exact list of dracut modules to use. Modules not listed here are not going
11
# to be included. If you only want to add some optional modules use
12
# add_dracutmodules option instead.
13
#dracutmodules+=""
14
15
# dracut modules to omit
16
#omit_dracutmodules+=""
17
18
# dracut modules to add to the default
19
#add_dracutmodules+=""
20
21
# additional kernel modules to the default
22
#add_drivers+=""
23
24
# list of kernel filesystem modules to be included in the generic initramfs
25
#filesystems+=""
26
27
# build initrd only to boot current hardware
28
#hostonly="yes"
29
#
30
31
# install local /etc/mdadm.conf
32
#mdadmconf="no"
33
34
# install local /etc/lvm/lvm.conf
35
#lvmconf="no"
36
37
# A list of fsck tools to install. If it's not specified, module's hardcoded
38
# default is used, currently: "umount mount /sbin/fsck* xfs_db xfs_check
39
# xfs_repair e2fsck jfs_fsck reiserfsck btrfsck". The installation is
40
# opportunistic, so non-existing tools are just ignored.
41
#fscks=""
42
43
# inhibit installation of any fsck tools
44
#nofscks="yes"
45
46
# mount / and /usr read-only by default
47
#ro_mnt="no"
48
49
# set the directory for temporary files
50
# default: /var/tmp
51
#tmpdir=/tmp
Copied!
in dracut.conf you can commented out module/driver that you like and then run dracut --force to make your falavor of initrd/initramfs.
.
.
.
Last modified 2yr ago