Gentoo Kernel Auto Updater

Ask questions about dedicated servers here and we and other users will do our best to answer them. Please also refer to the self-help section for tutorials and answers to the most commonly asked questions.
Post Reply
User avatar
hakkuo23
This is my homepage
This is my homepage
Posts: 88
https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
Joined: Thu Aug 05, 2010 5:04 pm

Gentoo Kernel Auto Updater

Post by hakkuo23 »

Since I always wanted to be on the latest version of the available Gentoo kernel, but I wasn't making changes to the config, I wrote this.

It automatically finds the newest version available in your src directory and updates to that. Might cause issues but since I don't touch the folder it works just fine for me.

Note: IT REQUIRES GRUB2 AND GENTOO!

Code: Select all

#! /bin/bash
# kernel-update.sh  version 1.0
# Copyright (c)2014 XenoGamers.com <silence@xenogamers.org>
# This program is licensed under the terms of the GPL version 3.

# This is for GENTOO only!

# Current version of linux kernel
LKVERSION=`uname -r`

# Latest version of linux kernel available
# NOTE: `ls` isn't the best way to do this.
#       Will only work correctly if you
#       aren't modifying /usr/src/.
LKNEWEST=`ls -t /usr/src/ | head -1 | sed -r 's/^.{5}-//'`

# Processor count for optimising build process
PROCTOTAL=`nproc`

# Prints the current version to the end user
echo "The current version of your Linux kernel is $LKVERSION"
echo "The version that will be installed is $LKNEWEST"

# Sets the symlink manually
rm -rf /usr/src/linux
ln -sf /usr/src/linux-$LKNEWEST /usr/src/linux

# Copies the old version of the kernel config to the new directory
cp /usr/src/linux-$LKVERSION/.config /usr/src/linux/

# Updates the config to the new version
cd /usr/src/linux
make oldconfig <<EOF
EOF

# Reinstall external kernel modules
make modules_prepare
emerge --ask @module-rebuild

# Build the new kernel
make -j$((PROCTOTAL + 1))

# Build the modules
make modules && make modules_install

# Install the new kernel
make install

# Rebuild Grub2 with new kernel
grub2-mkconfig -o /boot/grub/grub.cfg
Hope it helps out someone since it's make my life a little easier and I wish it does the same for you!
Post Reply