文章目录
- 前言
- 通过deb包安装内核头文件
前言
Ubuntu16.04部分内核版本无法通过 apt-get install linux-headers-$(uname -r) 来进行安装:
# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.5 LTS"
# uname -r
4.15.0-29-generic
# apt-get install linux-headers-$(uname -r)
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package linux-headers-4.15.0-29-generic 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.15.0-29-generic' has no installation candidate
# dpkg-query -s linux-headers-$(uname -r)
dpkg-query: package 'linux-headers-4.15.0-29-generic' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
# dpkg-query -l "linux-headers*"
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=====================================-=======================-=======================-===============================================================
un linux-headers <none> <none> (no description available)
un linux-headers-3.0 <none> <none> (no description available)
ii linux-headers-4.15.0-29 4.15.0-29.31 all Header files related to Linux kernel version 4.15.0
un linux-headers-4.15.0-29-generic <none> <none> (no description available)
ii linux-headers-4.4.0-131 4.4.0-131.157 all Header files related to Linux kernel version 4.4.0
ii linux-headers-4.4.0-131-generic 4.4.0-131.157 amd64 Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
ii linux-headers-generic 4.4.0.131.137 amd64 Generic Linux kernel headers
因此我们得去对应的官网找.deb来进行安装。
通过deb包安装内核头文件
官网找.deb来进行安装:
阿里云官网:https://mirrors.aliyun.com/ubuntu/pool/main/l/linux/找到以下安装包:
# dpkg -i *.deb
(Reading database ... 83994 files and directories currently installed.)
Preparing to unpack linux-headers-4.15.0-29_4.15.0-29.31_all.deb ...
Unpacking linux-headers-4.15.0-29 (4.15.0-29.31) over (4.15.0-29.31) ...
Selecting previously unselected package linux-headers-4.15.0-29-generic.
Preparing to unpack linux-headers-4.15.0-29-generic_4.15.0-29.31_amd64.deb ...
Unpacking linux-headers-4.15.0-29-generic (4.15.0-29.31) ...
Preparing to unpack linux-image-unsigned-4.15.0-29-generic_4.15.0-29.31_amd64.deb ...
Unpacking linux-image-unsigned-4.15.0-29-generic (4.15.0-29.31) over (4.15.0-29.31) ...
Preparing to unpack linux-modules-4.15.0-29-generic_4.15.0-29.31_amd64.deb ...
Unpacking linux-modules-4.15.0-29-generic (4.15.0-29.31) over (4.15.0-29.31) ...
Setting up linux-headers-4.15.0-29 (4.15.0-29.31) ...
dpkg: dependency problems prevent configuration of linux-headers-4.15.0-29-generic:
linux-headers-4.15.0-29-generic depends on libssl1.1 (>= 1.1.0); however:
Package libssl1.1 is not installed.
dpkg: error processing package linux-headers-4.15.0-29-generic (--install):
dependency problems - leaving unconfigured
Setting up linux-modules-4.15.0-29-generic (4.15.0-29.31) ...
Setting up linux-image-unsigned-4.15.0-29-generic (4.15.0-29.31) ...
Processing triggers for linux-image-unsigned-4.15.0-29-generic (4.15.0-29.31) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-4.15.0-29-generic
出现:
dpkg: dependency problems prevent configuration of linux-headers-4.15.0-29-generic:
linux-headers-4.15.0-29-generic depends on libssl1.1 (>= 1.1.0); however:
Package libssl1.1 is not installed.
去下载 libssl1.1 deb安装包进行安装:
http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/
# dpkg -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb
# dpkg -i *.deb
......
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /vmlinuz-4.15.0-29-generic
Found kernel: /vmlinuz-4.4.0-131-generic
Found kernel: /vmlinuz-4.15.0-29-generic
Found kernel: /vmlinuz-4.4.0-131-generic
Updating /boot/grub/menu.lst ... done
/etc/kernel/postinst.d/zz-update-grub:
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-29-generic
Found initrd image: /boot/initrd.img-4.15.0-29-generic
Found linux image: /boot/vmlinuz-4.4.0-131-generic
Found initrd image: /boot/initrd.img-4.4.0-131-generic
done
# dpkg-query -l "linux-headers*"
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==================================-======================-======================-==========================================================================
un linux-headers <none> <none> (no description available)
un linux-headers-3.0 <none> <none> (no description available)
ii linux-headers-4.15.0-29 4.15.0-29.31 all Header files related to Linux kernel version 4.15.0
ii linux-headers-4.15.0-29-generic 4.15.0-29.31 amd64 Linux kernel headers for version 4.15.0 on 64 bit x86 SMP
ii linux-headers-4.4.0-131 4.4.0-131.157 all Header files related to Linux kernel version 4.4.0
ii linux-headers-4.4.0-131-generic 4.4.0-131.157 amd64 Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
ii linux-headers-generic 4.4.0.131.137 amd64 Generic Linux kernel headers
# dpkg --get-selections |grep linux
console-setup-linux install
libselinux1:amd64 install
linux-base install
linux-firmware install
linux-generic install
linux-headers-4.15.0-29 install
linux-headers-4.15.0-29-generic install
linux-headers-4.4.0-131 install
linux-headers-4.4.0-131-generic install
......
安装成功。