4

I see that only kernel version 5.4 is available for Ubuntu 18.04 LTS by HWE package named linux-image-generic-hwe-18.04.

It is known that Mainline kernels will not work with Nvidia drivers from Ubuntu repository.

How can I obtain newer kernel version?

0

1 Answer 1

7

It is possible by downloading kernel sources from newer Ubuntu release - say Ubuntu 21.10 (impish) using relevant Docker container and then compile kernel on target 18.04 LTS system with small modifications as follows:

mkdir -p ~/Downloads/impish-kernel

Then place below code into compile-impish-kernel.sh script inside ~/Downloads/impish-kernel directory by using any text-editor:

#!/bin/bash
# prepare download script
cat << EOF > script.sh
set -x

sed -i "s/# deb-src/deb-src/g" /etc/apt/sources.list
apt-get update && \
apt-get install -y dpkg-dev
cd && apt-get source linux
chown -R 1000:1000 linux* 
EOF

# run script inside container
docker run --rm -v ${PWD}:/root -it ubuntu:impish sh /root/script.sh

cd linux-5.13.0
echo 9 > debian/compat
LANG=C fakeroot debian/rules clean

sed -i "s/^CONFIG_KASAN/#CONFIG_KASAN/" debian.master/config/annotations
sed -i "s/^CONFIG_KCSAN/#CONFIG_KCSAN/" debian.master/config/annotations
LANG=C fakeroot debian/rules binary-headers binary-generic binary-perarch

ls ../linux-headers-5.13*.deb ../linux-image-unsigned-5.13*.deb ../linux-modules-*.deb

Run the script by

chmod +x compile-impish-kernel.sh
./compile-impish-kernel.sh

and finally install 5.13 kernel packages by

sudo apt-get install ./linux-headers-5.13*.deb ./linux-image-unsigned-5.13*.deb ./linux-modules-*.deb

As the result the 5.13 kernel will be installed. Nvidia driver will operate normally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.