出于加密的需要,公司拉代码,指定要用 4.15.0-29 的内核才能拉代码,
而我当前的内核是 4.15.0-62 的内核。
ciellee@sh:~$ uname -a
Linux sh 4.15.0-62-generic #69~16.04.1-Ubuntu SMP Fri Sep 6 02:43:35 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
ciellee@sh:~$
通过 apt-cache search linux | grep linux-image 命令,可以看到 所有能下载的 内核镜像
ciellee@sh:~$ apt-cache search linux|grep linux-image
linux-image-4.4.0-21-generic - Linux kernel image for version 4.4.0 on 64 bit x86 SMP
linux-image-4.4.0-21-lowlatency - Linux kernel image for version 4.4.0 on 64 bit x86 SMP
linux-image-extra-4.4.0-21-generic - Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
接下来,搜索下我们要的镜像: apt-cache search linux | grep 15.0-29
ciellee@sh:~$ apt-cache search linux|grep 15.0-29
linux-cloud-tools-4.15.0-29-generic - Linux kernel version specific cloud tools for version 4.15.0-29
linux-cloud-tools-4.15.0-29-lowlatency - Linux kernel version specific cloud tools for version 4.15.0-29
linux-headers-4.15.0-29 - Header files related to Linux kernel version 4.15.0
linux-headers-4.15.0-29-generic - Linux kernel headers for version 4.15.0 on 64 bit x86 SMP
linux-headers-4.15.0-29-lowlatency - Linux kernel headers for version 4.15.0 on 64 bit x86 SMP
linux-hwe-cloud-tools-4.15.0-29 - Linux kernel version specific cloud tools for version 4.15.0-29
linux-hwe-tools-4.15.0-29 - Linux kernel version specific tools for version 4.15.0-29
linux-image-4.15.0-29-generic - Signed kernel image generic
linux-image-4.15.0-29-lowlatency - Signed kernel image lowlatency
linux-image-unsigned-4.15.0-29-generic - Linux kernel image for version 4.15.0 on 64 bit x86 SMP
linux-image-unsigned-4.15.0-29-lowlatency - Linux kernel image for version 4.15.0 on 64 bit x86 SMP
linux-modules-4.15.0-29-generic - Linux kernel extra modules for version 4.15.0 on 64 bit x86 SMP
linux-modules-4.15.0-29-lowlatency - Linux kernel extra modules for version 4.15.0 on 64 bit x86 SMP
linux-modules-extra-4.15.0-29-generic - Linux kernel extra modules for version 4.15.0 on 64 bit x86 SMP
linux-tools-4.15.0-29-generic - Linux kernel version specific tools for version 4.15.0-29
linux-tools-4.15.0-29-lowlatency - Linux kernel version specific tools for version 4.15.0-29
ciellee@sh:~$
下载镜像:sudo apt-get install linux-image-4.15.0-29-generic linux-headers-4.15.0-29-generic
注意 image 和 headers 都 要下载
如果出现这个错误,说明没有权限,要加sudo
ciellee@sh:~$ apt-get install linux-image-4.15.0-29-generic linux-headers-4.15.0-29-generic
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
ciellee@sh:~$
正式下载:
ciellee@sh:~$ sudo apt-get install linux-image-4.15.0-29-generic linux-headers-4.15.0-29-generic
[sudo] password for ciellee:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
fonts-dejavu fonts-sil-gentium fonts-sil-gentium-basic libhsqldb1.8.0-java libpng12-0:i386 libservlet3.1-java snapd-login-service
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
linux-headers-4.15.0-29 linux-modules-4.15.0-29-generic
Suggested packages:
fdutils linux-hwe-tools
The following NEW packages will be installed:
linux-headers-4.15.0-29 linux-headers-4.15.0-29-generic linux-image-4.15.0-29-generic linux-modules-4.15.0-29-generic
0 upgraded, 4 newly installed, 0 to remove and 71 not upgraded.
Need to get 32.9 MB of archives.
After this operation, 164 MB of additional disk space will be used.
Do you want to continue? [Y/n]
下载成功后,会自动更新ubuntu grub,直接重启即可
/etc/kernel/postinst.d/zz-update-grub:
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-62-generic
Found initrd image: /boot/initrd.img-4.15.0-62-generic
Found linux image: /boot/vmlinuz-4.15.0-58-generic
Found initrd image: /boot/initrd.img-4.15.0-58-generic
Found linux image: /boot/vmlinuz-4.15.0-29-generic
Found initrd image: /boot/initrd.img-4.15.0-29-generic
Found Windows Boot Manager on /dev/sda2@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for EFI firmware configuration
done
ciellee@sh:~$