
因为工具的需求,因此需要在Ubuntu 16.04下安装指定版本的内核,因此需要将新版本的内核删除掉,然后重新安装,这里记录下操作过程
查看当前使用的内核版本:
1 2 |
root@ubuntu:~# uname -a Linux ubuntu 4.4.0-142-generic #168-Ubuntu SMP Wed Jan 16 21:00:45 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux |
安装需要使用的对应版本的Ubuntu linux内核:
1 |
root@ubuntu:~# apt-get install linux-image-4.4.0-97-generic |
然后查看系统中已经安装的所有内核
1 2 3 4 5 6 |
root@ubuntu:~# dpkg --get-selections |grep linux-image linux-image-4.4.0-142-generic install linux-image-4.4.0-62-generic install linux-image-extra-4.4.0-142-generic install linux-image-extra-4.4.0-62-generic install linux-image-generic install |
卸载不需要的内核。
1 2 |
root@ubuntu:~# apt-get remove linux-image-4.4.0-62-generic root@ubuntu:~# apt-get remove linux-image-4.4.0-142-generic |
需要注意的是,这里的linux-image-4.4.0-142-generic是当前正在使用的内核,卸载之后Ubuntu16.04会提示用户升级升级grub
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
root@ubuntu:~# apt-get remove linux-image-4.4.0-142-generic Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: amd64-microcode crda intel-microcode iucode-tool iw libnl-3-200 libnl-genl-3-200 wireless-regdb Use 'apt autoremove' to remove them. The following packages will be REMOVED: linux-generic linux-image-4.4.0-142-generic linux-image-extra-4.4.0-142-generic linux-image-generic 0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded. After this operation, 224 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 87633 files and directories currently installed.) Removing linux-generic (4.4.0.142.148) ... Removing linux-image-generic (4.4.0.142.148) ... Removing linux-image-extra-4.4.0-142-generic (4.4.0-142.168) ... run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-142-generic /boot/vmlinuz-4.4.0-142-generic run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-142-generic /boot/vmlinuz-4.4.0-142-generic update-initramfs: Generating /boot/initrd.img-4.4.0-142-generic W: mdadm: /etc/mdadm/mdadm.conf defines no arrays. run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-142-generic /boot/vmlinuz-4.4.0-142-generic run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-142-generic /boot/vmlinuz-4.4.0-142-generic run-parts: executing /etc/kernel/postinst.d/x-grub-legacy-ec2 4.4.0-142-generic /boot/vmlinuz-4.4.0-142-generic 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.4.0-142-generic Found kernel: /vmlinuz-4.4.0-97-generic Found kernel: /vmlinuz-4.4.0-142-generic Found kernel: /vmlinuz-4.4.0-97-generic Updating /boot/grub/menu.lst ... done run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.0-142-generic /boot/vmlinuz-4.4.0-142-generic Generating grub configuration file ... Found linux image: /boot/vmlinuz-4.4.0-142-generic Found initrd image: /boot/initrd.img-4.4.0-142-generic Found linux image: /boot/vmlinuz-4.4.0-97-generic Found initrd image: /boot/initrd.img-4.4.0-97-generic done Removing linux-image-4.4.0-142-generic (4.4.0-142.168) ... WARN: Proceeding with removing running kernel image. Examining /etc/kernel/postrm.d . run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.4.0-142-generic /boot/vmlinuz-4.4.0-142-generic update-initramfs: Deleting /boot/initrd.img-4.4.0-142-generic run-parts: executing /etc/kernel/postrm.d/x-grub-legacy-ec2 4.4.0-142-generic /boot/vmlinuz-4.4.0-142-generic 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.4.0-142-generic Found kernel: /vmlinuz-4.4.0-97-generic Replacing config file /run/grub/menu.lst with new version Found kernel: /vmlinuz-4.4.0-97-generic Replacing config file /run/grub/menu.lst with new version Updating /boot/grub/menu.lst ... done run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.4.0-142-generic /boot/vmlinuz-4.4.0-142-generic Generating grub configuration file ... Found linux image: /boot/vmlinuz-4.4.0-97-generic Found initrd image: /boot/initrd.img-4.4.0-97-generic done The link /vmlinuz.old is a damaged link Removing symbolic link vmlinuz.old you may need to re-run your boot loader[grub] The link /initrd.img.old is a damaged link Removing symbolic link initrd.img.old you may need to re-run your boot loader[grub] |
因此我们需要更新下grub
1 2 3 4 5 |
root@ubuntu:~# update-grub Generating grub configuration file ... Found linux image: /boot/vmlinuz-4.4.0-97-generic Found initrd image: /boot/initrd.img-4.4.0-97-generic done |
搞定之后重启系统,然后确定系统使用了我们制定版本的内核
1 2 3 |
root@ubuntu:~# reboot root@ubuntu:~# uname -a Linux ubuntu 4.4.0-97-generic #120-Ubuntu SMP Tue Sep 19 17:28:18 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux |
下一步,我们锁定当前内核版本使之在apt dist-upgrade时也不会被升级
1 2 |
root@ubuntu:~# apt-mark hold linux-image-4.4.0-97-generic linux-image-4.4.0-97-generic set on hold. |
测试下,果然不会被升级了。至此,可以安心的去安装软件了