Ubuntu下载指定内核镜像

出于加密的需要,公司拉代码,指定要用 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:~$ 

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
Ubuntu编译Linux内核的步骤如下: 1. 下载内核源码 首先需要从官网下载Linux内核源码,并解压缩到一个目录中。可以使用以下命令下载最新版的内核源码: ``` wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.14.tar.xz ``` 然后解压缩: ``` tar xvf linux-5.14.tar.xz ``` 2. 安装编译工具 Ubuntu默认不包含内核编译所需的工具,需要先安装以下依赖包: ``` sudo apt-get install build-essential libncurses-dev bison flex libssl-dev libelf-dev ``` 3. 配置内核 进入内核源码目录,执行以下命令进行内核配置: ``` make menuconfig ``` 这个命令会打开一个配置界面,可以根据需要进行配置,比如选择需要编译的驱动、文件系统等。如果不需要进行配置,可以跳过这一步。 4. 编译内核 配置完成后,执行以下命令进行内核编译: ``` make -j8 ``` 这个命令会使用默认的配置进行编译,其中-j8表示使用8个线程并行编译。如果想使用之前配置过的选项,可以执行以下命令: ``` make oldconfig ``` 5. 安装内核 编译完成后,执行以下命令安装内核: ``` sudo make modules_install sudo make install ``` 这个命令会把编译好的内核镜像和模块安装到系统中。 6. 更新引导程序 安装完成后,需要更新引导程序,以便系统能够启动新的内核。具体方法可以根据不同的引导程序进行操作,一般来说,可以执行以下命令: ``` sudo update-grub ``` 7. 重启系统 更新引导程序完成后,重启系统即可启动新的内核

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

"小夜猫&小懒虫&小财迷"的男人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值