Linux update/install new kernel

All questions related to servers
Post Reply
mister_v
Posts: 188
Joined: Thu Mar 04, 2010 9:19 pm

Linux update/install new kernel

Post by mister_v »

Hi,

I want to upgrade my linux box with a new kernel.
how do I do that?
chris
Site Admin
Posts: 194
Joined: Mon Jul 21, 2008 9:52 am

Re: Linux update/install new kernel

Post by chris »

Well most of the time your linux flavor has some automatic upgrade tools.
gentoo : emerge
debian/ubuntu : apt-get

I recommend you use those.

But if you want to do it manually,
you can download the latest kernel from https://www.kernel.org/

Code: Select all

wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.10.tar.xz
Extract it to /usr/src

Code: Select all

tar -xjvf linux-3.10.tar.xz -C /usr/src
/usr/src holds all the "source" files.
I always create a symbolic link linux to the current version (I have several version of linux kernels)

Code: Select all

ln -s linux-3.10 linux
You need a complier gcc. Make sure it is installed.

Configure Kernel
You need to configure the kernel so it has everything to support your hardware.
This really depends on your system and is unique to your system,
So I can't help you with that.
For most option you can choose to compile it in the kernel or as module.
Modules get only loaded when needed, so if you are not sure if you need an option, set it as module.

First go to the directory

Code: Select all

cd /usr/src/linux-3.10
make menuconfig
Compile kernel
Now you can start to compile the kernel and the modules.
(This can take a while so use screen)

Code: Select all

make && make modules
Install kernel
To install the kernel and the modules, you need to be root.

Code: Select all

su -
make modules_install
make install
Alternative you can do it manually:

Code: Select all

cp .config /boot/config-3.10
cp arch/x86/boot/bzImage /boot/vmlinuz-3.10
Create initrd image
Optional you can create a initrd image, some computers need it.
initrd images contains device driver which needed to load rest of the operating system later on.

Code: Select all

cd /boot
mkinitrd -o initrd.img-3.10 3.10
Modify Grub configuration file (GRUB 0.97)
/boot/grub/grub.conf or if you use another bootloader, change that one.

Code: Select all

nano /boot/grub/grub.conf

default 0
timeout 5

title Linux 3.10
root (hd0,0)
kernel /boot/vmlinuz-3.10 root=/dev/sda3
I copy a section of the file and modify it. Just make sure it is the first section.
Or adapt default to the correct section (0 = first section)

Always leave, at least one old working kernel in boot.
So when the new kernel doesn't boot, (Which happened to me several times)
you can still boot by selecting a old kernel.

Now you can reboot your system to start using the new kernel.
Post Reply