5

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.

  • Tried in another machine. Getting same error: # apt-get install linux-headers-$(uname -r) Reading package lists... Done Building dependency tree Reading state information... Done Package linux-headers-4.9.0-8-amd64 is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'linux-headers-4.9.0-8-amd64' has no installation candidate – Abhishek Verma Sep 25 '19 at 8:49
  • 1
    You should update your system first , apt update && apt upgrade , reboot then apt-get install linux-headers-$(uname -r) – GAD3R Sep 25 '19 at 9:44
  • 1
    @GAD3R: Thank you for answering. I used your approach and finally i found the kernal upgraded to 4.9.0-11-amd64. This output i got after running uname -r command. I don't want to upgrade the kernal. i want the kernal to be 4.9.0-3-amd64. Please suggest how to do this. – Abhishek Verma Sep 25 '19 at 10:09
6

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.

| improve this answer | |
  • Getting below error. Don't know the reason. Please help: # apt-get install linux-image-amd64 linux-headers-amd64 Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. The following information may help to resolve the situation: The following packages have unmet dependencies: linux-headers-amd64 : Depends: linux-headers-4.9.0-8-amd64 but it is not installable linux-image-amd64 : Depends: linux-image-4.9.0-8-amd64 but it is not installable E: Unable to correct problems, you have held broken packages. – Abhishek Verma Sep 25 '19 at 9:50
  • 2
    I missed a step, you need apt-get update first. – Stephen Kitt Sep 25 '19 at 10:33
  • I tried your solution this also worked for me. But i wanted to know if some how i can user same old kernal and its corresponding headers. Also i wanted to know if doing so have some drawbacks. If yes then what are those and why? You can also refer some link from where i can learn about all these concepts. Please help. Thank you. – Abhishek Verma Sep 26 '19 at 12:48
  • 2
    See GAD3R’s answer if you really want to use an older kernel. However there are quite a few drawbacks: older kernels have more known security issues... I highly recommend keeping up-to-date with distribution kernel releases. See Greg KH’s talk on the kernel release model at Kernel Recipes 2017 and his blog post on which stable kernel to use. – Stephen Kitt Sep 26 '19 at 21:26
3

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.

| improve this answer | |
  • Thank you. This is what i need. I will try this solution and update soon. – Abhishek Verma Sep 26 '19 at 13:02
  • 1
    I ran into this same issue. I'm using the Vagrant boxes published by Debian themselves for Puppet acceptance tests and both Stretch and Buster now can't find the linux-headers package that matches the kernel version installed in each Vagrant box. I don't have the ability (or desire) to be able to patch and reboot the box as part of the test process, plus the machines by definition aren't long-lived anyway. I figured Debian wouldn't delete the packages and that they're there somewhere in a source so thanks for this answer. – bodgit Sep 27 '19 at 9:45
0

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.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.