How do I use apt-get to update to the latest kernel?
My current kernel is 3.2.0-26 (my main computer) while on another of my Ubuntu computers, with which I didn't fiddle with unofficial updates, it's 3.2.0-30. Yet the Update manager on my main computer doesn't show available kernel updates. It shows other updates though.
I suspect is due to the fact that in the past I installed multiple mainline kernel versions (not recommended versions), up to 3.5* series.
What I'm after: Either: Fix automatic kernel updates. Or: Learn about a way to check for the latest official ubuntu kernel version and get it manually (I know how to install kernels from debs)
What I have already tried: Uninstalled unused kernels including "the generic one without a number" as per and then also
03 Answers
Your problem with automatic updates may be because of the mainline kernels or because you removed the "generic" package.
You can update to the latest kernel via apt-get as follows:
sudo apt-get update sudo apt-get install linux-image-`uname -r`
If you also need the headers (to compile kernel modules such as wireless drivers):
sudo apt-get install linux-headers-`uname -r`2
In case you only want to update the default kernel you should be able to fix it with:
sudo apt-get install linux-image-genericSince linux-image-generic always depends on the newest default kernel of your distribution, the kernel gets upgraded with the rest of the packages when you run apt-get upgrade.
When you want to update a non default kernel you can do this by running this script:
#!/usr/bin/env bash
sudo apt-get update
kernel_release="$(uname -r | cut --complement -d'.' -f3)"
kernel_release_versions="$(apt-cache search linux-image-${kernel_release})"
kernel_release_versions_generic="$(grep linux-image-"${kernel_release_version}".*-generic <<< "$kernel_release_versions")"
newest_kernel_of_release="$(echo "$kernel_release_versions_generic" | tail -n1 | cut -d' ' -f1 )"
sudo apt-get install $newest_kernel_of_release
sudo apt-get dist-upgradeIf you also need the header files, additionally run the following:
newest_kernel_of_release_headers=${newest_kernel_of_release/image/headers}
sudo apt-get install $newest_kernel_of_release_headers 4 "You should be able to use any of the listed mirrors by adding a line to your /etc/apt/sources.list like this:
deb raring-security main
"
via