# START =============================================================
# VARIABLES
STABLE=$(wget -O - -o /dev/null https://www.kernel.org/finger_banner | awk '/stable/ {print $NF; exit}')
MAJOR=$(echo $STABLE | cut -d. -f1)
URL="https://kernel.org/pub/linux/kernel/v$MAJOR.x"
KERNEL="linux-$STABLE.tar.xz"
TARBALL="linux-$STABLE.tar"
PGP="linux-$STABLE.tar.sign"
KURL="$URL/$KERNEL"
PURL="$URL/$PGP"
# ===================================================================
# Download the latest stable kernel tarball
wget -c $KURL
# ===================================================================
# Download the signature
wget -c $PURL
# ===================================================================
# Locate and import the PGP keys for verification
gpg --locate-keys torvalds@kernel.org gregkh@kernel.org
gpg --sign-key gregkh@kernel.org
# ===================================================================
# Uncompress the kernel tarball
unxz $KERNEL
# Verify the tarball signature
gpg --verify $PGP $TARBALL
# ===================================================================
# Extract the kernel tarball
tar xf $TARBALL
# ===================================================================
# Enter the kernel source directory
cd linux-$STABLE
Once in a while, someone will ask about why not “make distclean,” or “make mrproper,” or “make clean.” Ok, this is the way! ℼ
make distclean; make mrproper; make clean;
yes "" | make oldconfig
cp arch/arm64/configs/defconfig .
yes "" | make oldconfig
make menuconfig
General setup --->
(-cbkadal-10) Local version - append to kernel release
(cbkadal) Default hostname
[*] Support initial ramdisk/ramfs compressed using XZ
<*> Kernel .config support
[*] Enable access to .config through /proc/config.gz
<*> Enable kernel headers through /sys/kernel/kheaders.tar.xz
Boot options --->
[*] UEFI runtime support
File systems --->
<*> FUSE (Filesystem in Userspace) support
<*> Character device in Userspace support
<*> Virtio Filesystem
[*] FUSE passthrough operations support
Kernel hacking --->
printk and dmesg option --->
[*] Enable dynamic printk() support
Compile-time checks and compiler options --->
[*] Install uapi headers to usr/include
time make
# USER: ROOT ============
# Install the modules
sudo make modules_install
# Install the kernel
sudo make install
# Install the headers
sudo make headers_install INSTALL_HDR_PATH=/usr
You need to keep some parts of the Linux kernel source. You can delete the rest.
make clean
rm -rf arch/{alpha, arc, [c-x]*} block/ certs/ crypto/ Documentation/
rm -rf drivers/ fs/ init/ io_uring/ ipc/ kernel/ lib/ lib/
rm -rf mm/ net/ rust/ samples/ security/ sound/ virt/ usr/
cp -r i915/ /lib/firmware/
cp -r tigon/ /lib/firmware/
cp -r e100/ /lib/firmware/
cp -r rtl_nic/ /lib/firmware/
cd /lib/modules/
ls -al
cd /boot/
ls -al