Failed to update Linux headers on debian stretch / Debian 9

After running below command i got error:

# apt-get install linux-headers-$(uname -r)
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-headers-4.9.0-3-amd64
E: Couldn't find any package by glob 'linux-headers-4.9.0-3-amd64'
E: Couldn't find any package by regex 'linux-headers-4.9.0-3-amd64'

To troubleshoot i checked following:

# apt-cache search linux-headers
aufs-dkms - DKMS files to build and install aufs
linux-libc-dev-arm64-cross - Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-armel-cross - Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-armhf-cross - Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-mips-cross - Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-mips64el-cross - Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-mipsel-cross - Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-ppc64el-cross - Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-s390x-cross - Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-alpha-cross - Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-hppa-cross - Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-m68k-cross - Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-mips64-cross - Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-powerpc-cross - Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-powerpcspe-cross - Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-ppc64-cross - Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-sh4-cross - Linux Kernel Headers for development (for cross-compiling)
linux-libc-dev-sparc64-cross - Linux Kernel Headers for development (for cross-compiling)
linux-headers-4.9.0-11-all - All header files for Linux 4.9 (meta-package)
linux-headers-4.9.0-11-all-amd64 - All header files for Linux 4.9 (meta-package)
linux-headers-4.9.0-11-amd64 - Header files for Linux 4.9.0-11-amd64
linux-headers-4.9.0-11-common - Common header files for Linux 4.9.0-11
linux-headers-4.9.0-11-common-rt - Common header files for Linux 4.9.0-11-rt
linux-headers-4.9.0-11-rt-amd64 - Header files for Linux 4.9.0-11-rt-amd64
linux-headers-amd64 - Header files for Linux amd64 configuration (meta-package)
linux-headers-rt-amd64 - Header files for Linux rt-amd64 configuration (meta-package)```


and 

# apt-cache search linux-image
linux-headers-4.9.0-11-amd64 - Header files for Linux 4.9.0-11-amd64
linux-headers-4.9.0-11-rt-amd64 - Header files for Linux 4.9.0-11-rt-amd64
linux-image-4.9.0-11-amd64 - Linux 4.9 for 64-bit PCs
linux-image-4.9.0-11-amd64-dbg - Debug symbols for linux-image-4.9.0-11-amd64
linux-image-4.9.0-11-rt-amd64 - Linux 4.9 for 64-bit PCs, PREEMPT_RT
linux-image-4.9.0-11-rt-amd64-dbg - Debug symbols for linux-image-4.9.0-11-rt-amd64
linux-image-amd64 - Linux for 64-bit PCs (meta-package)
linux-image-amd64-dbg - Debugging symbols for Linux amd64 configuration (meta-package)
linux-image-rt-amd64 - Linux for 64-bit PCs (meta-package), PREEMPT_RT
linux-image-rt-amd64-dbg - Debugging symbols for Linux rt-amd64 configuration (meta-package)
linux-image-4.9.0-3-amd64 - Linux 4.9 for 64-bit PCs

After running apt-cache search linux-image i get linux-image-4.9.0-3-amd64 kernal version which i want in the result of apt-cache search linux-headers command also.

Few people suggested to change sources.list and then try. But as i am new to this i don’t have idea how to search proper link for sources.list and what will be best suited to resolve my problem.

I did search on google but did not find solution. Any link or solution which can provide solution will be of great help.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

For

apt-get install linux-headers-$(uname -r)

to work, you need to be running a kernel which is still available from the distribution repositories; in most cases, this basically means you need to be running the latest supported kernel for your distribution.

On Debian, the simplest option is

apt-get update
apt-get install linux-image-amd64 linux-headers-amd64

(adjust to your architecture) to get the current kernel and matching headers, then reboot.

Method 2

The linux-headers-4.9.0-3-amd64 is outdated , it is removed and replaced with the more recent package linux-headers-4.9.0-11-amd64 that’s why you can’t install it from the regular repository.

You can install the linux-headers-4.9.0-3-amd64 from the snapshot archive repository:

edit your sources list:

nano /etc/apt/sources.list.d/snapshot.list

Add the following lines:

deb http://snapshot.debian.org/archive/debian/20170609T034604Z stretch main
deb http://snapshot.debian.org/archive/debian/20170609T034604Z stretch-updates main
deb http://snapshot.debian.org/archive/debian-security/20170920T221221Z stretch/updates main

then:

apt -o Acquire::Check-Valid-Until=false update
apt install linux-headers-4.9.0-3-amd64

To access snapshots of suites using Valid-Until that are older than a dozen days, it is necessary to ignore the Valid-Until header within Release files, in order to prevent apt from disregarding snapshot entries (“Release file expired”). Use aptitude -o Acquire::Check-Valid-Until=false update or apt-get -o Acquire::Check-Valid-Until=false update for this purpose.

Method 3

This worked for me after I submitted the command: apt-cache search linux-headers. I chose linux-headers-5.4.0-1009-oracle from the list. I’m using Windows 10 Professional!

sudo apt-get install linux-headers-5.4.0-1009-oracle
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  linux-oracle-headers-5.4.0-1009
The following NEW packages will be installed:
  linux-headers-5.4.0-1009-oracle linux-oracle-headers-5.4.0-1009
0 upgraded, 2 newly installed, 0 to remove and 21 not upgraded.
Need to get 12.2 MB of archives.
After this operation, 87.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 linux-oracle-headers-5.4.0-1009 all 5.4.0-1009.9 [11.0 MB]Get:2 http://archive.ubuntu.com/ubuntu focal/main amd64 linux-headers-5.4.0-1009-oracle amd64 5.4.0-1009.9 [1244 kB]
Fetched 12.2 MB in 1min 12s (170 kB/s)
Selecting previously unselected package linux-oracle-headers-5.4.0-1009.
(Reading database ... 99989 files and directories currently installed.)
Preparing to unpack .../linux-oracle-headers-5.4.0-1009_5.4.0-1009.9_all.deb ...
Unpacking linux-oracle-headers-5.4.0-1009 (5.4.0-1009.9) ...

Selecting previously unselected package linux-headers-5.4.0-1009-oracle.
Preparing to unpack .../linux-headers-5.4.0-1009-oracle_5.4.0-1009.9_amd64.deb ...
Unpacking linux-headers-5.4.0-1009-oracle (5.4.0-1009.9) ...
Setting up linux-oracle-headers-5.4.0-1009 (5.4.0-1009.9) ...
Setting up linux-headers-5.4.0-1009-oracle (5.4.0-1009.9) ...
/etc/kernel/header_postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.4.0-1009-oracle

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...
make -j8 KERNELRELEASE=5.4.0-1009-oracle -C /lib/modules/5.4.0-1009-oracle/build M=/var/lib/dkms/virtualbox/6.1.10/build................
cleaning build area...

DKMS: build completed.

vboxdrv.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.4.0-1009-oracle/updates/dkms/

vboxnetadp.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.4.0-1009-oracle/updates/dkms/

vboxnetflt.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.4.0-1009-oracle/updates/dkms/

depmod...

DKMS: install completed.
   ...done.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x