Fedora / Redhat / Centos7 / Centos8 - Compiling The Latest Kernel - Updated 2020-01
Fedora / Redhat / Centos7 / Centos8 - Compiling The Latest Kernel - Updated 2020-01
https://www.youtube.com/watch?v=MShbP3OpASA
… one also likes beauty and simplicity… this tutorial has not exactly grown into beauty –
rather the beauty has grown into a beast and just as with software beyond a certain point –
it needs to be split into separate CentOS7 and CentOS8 articles and rewrite from scratch.
(if one wants the latest kernel for Debian: debian9 stretch go here)
it seems very relevant to have the late as possible kernel up and
running: https://googleprojectzero.blogspot.com/2018/09/a-cache-invalidation-bug-in-
linux.html
first: backup
one’s system!
on boot time (under „Advanced“ for Debian) one can chose to boot the old kernel – never
the less – backup one’s system completely before progressing.
hardware requirements:
one will need AT LEAST 15GB of free disk space, better 20GB. (yes one can free disk
space again after compilation…)
also:
it works, but one should not compile as root. (says Owl River Company)
while installing dependencies and „make install“ the new kernel requires root.
One should not compile as root so we create a new non-root user: (across distribution
Debian8, RedHat(CentOS7), Suse12)
# add user and create home directory
useradd -m username;
# one will have to asign a password for the user straight afterwards
passwd username;
# probably would also want to change default-login-shell of username
to bash
usermod -s /bin/bash username;
# change permissions, so non-root user may do things
chown -R username:username /usr/src/linux*
# become this new user when one needs to
su username;
the installation of the kernel and modules needs to be done as root (of course one are
modifying the system) but not the compilation itself.
du -h --max-depth=0 /usr/src/linux-4.17.12
12G /usr/src/linux-4.17.12
du -hs /usr/src/linux-5.4.11
14G /usr/src/linux-5.4.11
if one wants the LATEST Kernel ( above 4.17.19) one will need also gcc version > 4.5 or
one might run into
arch/x86/Makefile:184: *** Compiler lacks asm-goto support.. Stop.
(src)
about x86: Force asm-goto: „We want to start using asm-goto to guarantee the absence of
dynamic branches (and thus speculation).
A primary prerequisite for this is of course that the compiler supports asm-goto.
This effecively lifts the minimum GCC version to build an x86 kernel to gcc-4.5. Signed-off-
by: Peter Zijlstra (Intel) <peterz@xxxxx.org> Signed-off-by: Thomas Gleixner
of: linutronix.de
Link: https://lkml.kernel.org/r/20180319201327.GJ4043@hirez.programming.kicks-ass.net
in this case we install the old version and override with the new one, you could probably
also just softlink to it. (untested)
# under Centos7/Redhat/Fedora this seems to be done like this: (src)
# become root
su
# install the old gcc 4.X
yum install gcc
which gcc
/usr/bin/gcc
gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
WorkFlow:
it seems to pretty much be always the same process:
hit ESC or other keys to see the verbose kernel output instead of the loading bar…
hostnamectl; # tested on
Static hostname: CentOS7
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-514.26.1.el7.x86_64
Architecture: x86-64
# also tested on
Kernel: Linux 3.10.0-693.11.6.el7.x86_64
# also tested 2018-02-06 on
Kernel: Linux 3.10.0-693.17.1.el7.x86_64
# also tested on 2018-07
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-862.6.3.el7.x86_64
# also tested on:
hostnamectl
Operating System: CentOS Linux 8 (Core)
CPE OS Name: cpe:/o:centos:centos:8
Kernel: Linux 4.18.0-80.11.2.el8_0.x86_64
Architecture: x86-64
su; # become root
yum update; # update system
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.12.tar.xz
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.12.tar.sign
# or in case of kernel 5.4.11
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.4.11.tar.xz
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-
5.4.11.tar.sign
# unpack step1
unxz linux-5.4.11.tar.xz
# verify the file
gpg --verify linux-5.4.11.tar.sign
# it will say that it can not verify because key with id
647F28654894E3BD457199BE38DBBDC86092693E is missing
# get the key (from gpg default keyserver)
gpg --recv-keys 647F28654894E3BD457199BE38DBBDC86092693E
gpg: key 38DBBDC86092693E: 179 signatures not checked due to missing
keys
gpg: key 38DBBDC86092693E: "Greg Kroah-Hartman" not changed
gpg: Total number processed: 1
gpg: unchanged: 1
# Good signature means: nobody but Greg inserted any backdoors (just
kidding X-D)
# so one may proceed safely
# unpack step2
tar fxv linux-5.4.11.tar
tar fxvJ linux-4.12.tar.xz
ln -sv linux-4.12 linux
cd linux
uname -r;
# this is our current kernel version
3.10.0-862.6.3.el7.x86_64
# before:
# after:
https://wiki.gentoo.org/wiki/Signed_kernel_module_support
http://www.kroah.com/log/blog/2013/09/02/booting-a-self-signed-linux-kernel/
luckily when one comments out those two lines in .config, the build process will just auto-
generate keys for signing.
# CentOS8 when modules make_install succeeds, followed by make install
(install kernel)
# CentOS8 comes with gcc 8, so one does not need to upgrade to gcc 7.X
gcc --version
gcc (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3)
# rerun
su username
make menuconfig
# now finally worked:
# kernel5
# usually i do not modify anything here
# just hit exit and save the .config
watching kernel 4.12.13 compiling under centos7 with 8x xeon E5504 at 2.00GHz cores on supermicro X8DT3
server (2018-01) good way to stress test one’s system 😀 real: 24m48.755s … not too bad 😀
make install
grub2-set-default 0
# if that worked one might want to make it boot the new kernel per
default
hostnamectl
Static hostname: hostname
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 5.2.9 (recent in 2019-08)
Architecture: x86-64
CONGRATULATIONS! 🙂
cleaning up:
# to avoid overwriting one's custom compiled kernel with the next
update add this
vim /etc/yum.conf
exclude=kernel*
# if it is a desktop workstation one might also want to
exclude=icedove* firefox* libreoffice*
benchmark:
a quadcore Intel(R) Core(TM) i5-3470T CPU @ 2.90GHz needs real 36m58.294s to
compile linux-4.15.1
If sie berprfen wollen, ob Domne diesen Zugriff bentigt oder Sie eine
Datei mit den falschen Berechtigungen auf Ihrem System haben
Then aktivieren Sie die vollstndige Audit-Funktion, um die Pfad-
Information der problematischen Datei zu erhalten. Dann reproduzieren
Sie den Fehler erneut.
Do
Additional Information:
Source Context system_u:system_r:accountsd_t:s0
Target Context system_u:system_r:accountsd_t:s0
Target Objects Unknown [ capability ]
Source accounts-daemon
Source Path /usr/libexec/accounts-daemon
Port
Host CentOS7
Source RPM Packages
Target RPM Packages
Policy RPM selinux-policy-3.13.1-
102.el7_3.16.noarch
Selinux Enabled True
Policy Type targeted
Enforcing Mode Enforcing
Host Name CentOS7
Platform Linux CentOS7 4.12.0cuztom #1 SMP Mon
Jul 3
12:01:05 CEST 2017 x86_64 x86_64
Alert Count 6
First Seen 2017-07-03 15:13:18 CEST
Last Seen 2017-07-03 15:13:52 CEST
Local ID 286945cd-6cfc-4233-a5b4-747cfe5afe79
Raw Audit Messages
type=AVC msg=audit(1499087632.710:111): avc: denied
{ dac_read_search } for pid=782 comm="accounts-daemon" capability=2
scontext=system_u:system_r:accountsd_t:s0
tcontext=system_u:system_r:accountsd_t:s0 tclass=capability
permissive=0
Hash: accounts-
daemon,accountsd_t,accountsd_t,capability,dac_read_search
– Initial AMD Raven Ridge graphics support (sans no display due to no DC/DAL yet), Vega
fixes, and other updates.
– Many Allwinner DRM changes.
– DRM sync objects are landing.
– Raspberry Pi / VC4 improvements.
– Various updates to the Intel DRM driver.
– Large directory support for EXT4.
– XPad updates and Google Rose Touchpad support.
– AES-128-CBC support in Fscrypt, the file-system generic crypto code currently utilized by
EXT4 and F2FS.
– Possibly the AMD SME/SEV security features supported by new EPYC CPUs.
– Continued push for more HDMI CEC drivers.
Stay tuned for thorough Linux 4.13 kernel feature coverage once the merge window opens
following the 4.12 debut.
src: http://www.phoronix.com/scan.php?page=news_item&px=Linux-4.13-Early-Look