From 9f0051263884783fa0f81a4800cbe0f30e856455 Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Thu, 17 Sep 2020 19:42:48 +0530 Subject: [PATCH 1/3] Add steps to compile a custom kernel and boot into it on coreos --- boot_custom_kernel.md | 57 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 boot_custom_kernel.md diff --git a/boot_custom_kernel.md b/boot_custom_kernel.md new file mode 100644 index 0000000..289a548 --- /dev/null +++ b/boot_custom_kernel.md @@ -0,0 +1,57 @@ +# Steps/Commands to compile and boot into a custom kernel on RHCOS node: + + # cd /var/home/core + + # cat dockfile + FROM fedora:latest + + RUN dnf install -y kexec-tools make gcc git openssl-devel bison flex autoconf automake bc + # + + *** Setup container image to build the kernel *** + # podman build -t fedora:build -f dockfile + + # cp /lib/modules/`uname -r`/config . + + # podman run -it -v /var/home/core:/root --privileged=true -- fedora:build bash + + *** Build the kernel in container *** + # cd /root + + # git clone --depth=1 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git + + # cp config linux/.config + + # cd linux + + # make oldconfig + + # make vmlinux; make modules + + # make INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=/root modules_install + + # cp vmlinux /root/vmlinux- + + # cp /sbin/kexec /root + + # exit + + *** Back to RHCOS host *** + + *** To build initrd image, pick dracut options from existing RHCOS initrd in /boot/ostree and use the same options, + *** plus "--kmoddir '/var/home/core/lib/modules/5.9.0-rc5'" to find the modules since we could not install kernel modules + *** at the usual place as /lib/modules directory is read-only. *** + # mkdir /tmp/dracut + # dracut --reproducible --gzip -v --add 'ostree' --tmpdir '/tmp/dracut' -f --add 'ignition' --no-hostonly --add-drivers 'mptspi vmw_pvscsi' --omit-drivers 'nouveau' --omit 'nfs' --add 'iscsi' --add 'ifcfg' --add 'fips' --kmoddir '/var/home/core/lib/modules/' initramfs-.img + + ** Ready to load and kexec into the just built kernel *** + # ./kexec -l --append="`cat /proc/cmdline`" --initrd=initramfs-.img vmlinux- + + # ./kexec -e + + Note: After booting past initrd, 'modprobe' would fail to find modules as the modules for the custom kernel could not be placed in + /lib/modules directory (read-only) where they are looks for. Three options to workaround it: + a. Use alias "modprobe -d /var/home/core" for "modprobe" + b. Build the missing kernel modules into the initrd with add-drivers option + c. Compile the modules into the kernel (=y instead of =m) + From b4bcc7282478281a97add01ea8f73987747c11d9 Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Thu, 17 Sep 2020 19:52:30 +0530 Subject: [PATCH 2/3] Format the file that talks about steps to boot a custom kernel --- boot_custom_kernel.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/boot_custom_kernel.md b/boot_custom_kernel.md index 289a548..a187e50 100644 --- a/boot_custom_kernel.md +++ b/boot_custom_kernel.md @@ -1,5 +1,6 @@ # Steps/Commands to compile and boot into a custom kernel on RHCOS node: - + +``` # cd /var/home/core # cat dockfile @@ -54,4 +55,5 @@ a. Use alias "modprobe -d /var/home/core" for "modprobe" b. Build the missing kernel modules into the initrd with add-drivers option c. Compile the modules into the kernel (=y instead of =m) +``` From 2606b3a13b0fc7300e28593219e2a2d4566696ec Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Mon, 28 Sep 2020 11:57:33 +0530 Subject: [PATCH 3/3] Use the conventional filename for Containerfile --- boot_custom_kernel.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boot_custom_kernel.md b/boot_custom_kernel.md index a187e50..34c14e0 100644 --- a/boot_custom_kernel.md +++ b/boot_custom_kernel.md @@ -3,14 +3,14 @@ ``` # cd /var/home/core - # cat dockfile + # cat Dockerfile FROM fedora:latest RUN dnf install -y kexec-tools make gcc git openssl-devel bison flex autoconf automake bc # *** Setup container image to build the kernel *** - # podman build -t fedora:build -f dockfile + # podman build -t fedora:build -f Dockerfile # cp /lib/modules/`uname -r`/config .