Debian

無法在 debian stretch / Debian 9 上更新 Linux 標頭

  • January 19, 2021

執行以下命令後出現錯誤:

# 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'

為了排除故障,我檢查了以下內容:

# 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

執行 apt-cache search linux-image後,我得到了 linux-image-4.9.0-3-amd64核心版本,這也是我在apt-cache search linux-headers命令的結果中想要的。

很少有人建議更改 sources.list 然後嘗試。但由於我是新手,所以我不知道如何搜尋sources.list 的正確連結以及最適合解決我的問題的連結。

我在Google上搜尋但沒有找到解決方案。任何可以提供解決方案的連結或解決方案都會有很大幫助。

為了

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

要工作,您需要執行一個仍可從分發儲存庫中獲得的核心;在大多數情況下,這基本上意味著您需要為您的發行版執行最新支持的核心。

在 Debian 上,最簡單的選擇是

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

(根據您的架構調整)以獲取目前核心和匹配的標頭檔,然後重新啟動。

linux-headers-4.9.0-3-amd64過時,已將其刪除並替換為更新的軟體包linux-headers-4.9.0-11-amd64,這就是您無法從正常儲存庫安裝它的原因。

您可以linux-headers-4.9.0-3-amd64快照存檔儲存庫安裝:

編輯您的來源列表:

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

添加以下行:

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

然後:

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

要使用 Valid-Until 訪問超過十幾天的套件快照,有必要忽略 Release 文件中的 Valid-Until 標頭,以防止 apt 忽略快照條目(“發布文件已過期”)。為此目的使用aptitude -o Acquire::Check-Valid-Until=false update或更新。apt-get -o Acquire::Check-Valid-Until=false

引用自:https://unix.stackexchange.com/questions/543601