Ubuntu: How can I ensure the linux-headers-x.xx.x-xx package is automatically installed when the kernel is upgraded?


Every few weeks/months the kernel on my Ubuntu 16.04.3 (x86_64) installation is automatically updated. That's fine, except that the corresponding kernel headers are not automatically installed at the same time and so the VirtualBox kernel modules are not rebuilt automatically. I have to manually do:

sudo apt-get install linux-headers-`uname -r`  

in order to trigger the rebuild. (I got that command from the answer to: VirtualBox '/etc/init.d/vboxdrv setup' issue)

How can I arrange for the linux headers to be automatically updated as well? Or, alternatively, how can I ensure that the VirtualBox modules are automatically rebuilt when the kernel is upgraded?

I have the linux-headers-generic package installed as suggested in the answer to How to get Software Update to automatically grab kernel source along with kernel update?:

$ sudo apt-get install linux-headers-generic  Reading package lists... Done  Building dependency tree         Reading state information... Done  linux-headers-generic is already the newest version (  linux-headers-generic set to manually installed.  

Edited to add: The output of uname -a is

Linux riemann 4.10.0-35-generic #39~16.04.1-Ubuntu SMP Wed Sep 13 09:02:42 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux  


Most likely the meta linux-headers-generic-hwe-16.04 is not installed.

The linux-headers-generic is installing headers for the 4.4 kernel, but you are using a HWE kernel, like 4.10.


sudo apt install linux-headers-generic-hwe-16.04  

and you should get headers updates.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »