1、查看现在的内核版本
root@angel-MVP-6100:~# uname -r 5.4.0-109-generic
2、查看当前系统已安装的内核镜像
root@angel-MVP-6100:~# dpkg --get-selections |grep linux-image linux-image-5.4.0-109-generic install linux-image-5.4.0-110-generic deinstall linux-image-5.4.0-113-generic deinstall linux-image-5.4.0-42-generic deinstall
3、安装指定版本内核的 linux 系统头文件及镜像
root@angel-MVP-6100:/home/angel# sudo apt-get install linux-headers-5.4.0-109-generic linux-image-5.4.0-109-generic 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 将会同时安装下列软件: linux-modules-5.4.0-109-generic 建议安装: fdutils linux-hwe-5.4-doc-5.4.0 | linux-hwe-5.4-source-5.4.0 linux-hwe-5.4-tools 下列【新】软件包将被安装: linux-headers-5.4.0-109-generic linux-image-5.4.0-109-generic linux-modules-5.4.0-109-generic 升级了 0 个软件包,新安装了 3 个软件包,要卸载 0 个软件包,有 6 个软件包未被升级。 需要下载 0 B/26.7 MB 的归档。 解压缩后会消耗 102 MB 的额外空间。 您希望继续执行吗? [Y/n] y 正在选中未选择的软件包 linux-headers-5.4.0-109-generic。 (正在读取数据库 ... 系统当前共安装有 199523 个文件和目录。) 正准备解包 .../linux-headers-5.4.0-109-generic_5.4.0-109.123~18.04.1_amd64.deb ... 正在解包 linux-headers-5.4.0-109-generic (5.4.0-109.123~18.04.1) ... 正在选中未选择的软件包 linux-modules-5.4.0-109-generic。 正准备解包 .../linux-modules-5.4.0-109-generic_5.4.0-109.123~18.04.1_amd64.deb ... 正在解包 linux-modules-5.4.0-109-generic (5.4.0-109.123~18.04.1) ... 正在选中未选择的软件包 linux-image-5.4.0-109-generic。 正准备解包 .../linux-image-5.4.0-109-generic_5.4.0-109.123~18.04.1_amd64.deb ... 正在解包 linux-image-5.4.0-109-generic (5.4.0-109.123~18.04.1) ... 正在设置 linux-headers-5.4.0-109-generic (5.4.0-109.123~18.04.1) ... 正在设置 linux-modules-5.4.0-109-generic (5.4.0-109.123~18.04.1) ... 正在设置 linux-image-5.4.0-109-generic (5.4.0-109.123~18.04.1) ... I: /vmlinuz.old is now a symlink to boot/vmlinuz-5.4.0-113-generic I: /initrd.img.old is now a symlink to boot/initrd.img-5.4.0-113-generic I: /vmlinuz is now a symlink to boot/vmlinuz-5.4.0-109-generic I: /initrd.img is now a symlink to boot/initrd.img-5.4.0-109-generic 正在处理用于 linux-image-5.4.0-109-generic (5.4.0-109.123~18.04.1) 的触发器 ... /etc/kernel/postinst.d/initramfs-tools: update-initramfs: Generating /boot/initrd.img-5.4.0-109-generic /etc/kernel/postinst.d/zz-update-grub: Sourcing file `/etc/default/grub' Generating grub configuration file ... Found linux image: /boot/vmlinuz-5.4.0-113-generic Found initrd image: /boot/initrd.img-5.4.0-113-generic Found linux image: /boot/vmlinuz-5.4.0-110-generic Found initrd image: /boot/initrd.img-5.4.0-110-generic Found linux image: /boot/vmlinuz-5.4.0-109-generic Found initrd image: /boot/initrd.img-5.4.0-109-generic Adding boot menu entry for EFI firmware configuration done root@angel-MVP-6100:/home/angel#
4、查询已安装的包情况
root@angel-MVP-6100:/home/angel# dpkg --get-selections | grep linux-image linux-image-5.4.0-109-generic install linux-image-5.4.0-110-generic install linux-image-5.4.0-113-generic install linux-image-5.4.0-42-generic deinstall linux-image-generic-hwe-18.04 install root@angel-MVP-6100:/home/angel# sudo gedit /etc/default/grub
5、查看当前系统中内核的启动顺序
root@angel-MVP-6100:/home/angel# grep menuentry /boot/grub/grub.cfg if [ x"${feature_menuentry_id}" = xy ]; then menuentry_id_option="--id" menuentry_id_option="" export menuentry_id_option menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-bff94532-41bc-46c1-9d1e-ca7c25782d1d' { submenu 'Ubuntu 高级选项' $menuentry_id_option '<strong>gnulinux-advanced-bff94532-41bc-46c1-9d1e-ca7c25782d1d</strong>' { menuentry 'Ubuntu,Linux 5.4.0-113-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-113-generic-advanced-<strong>bff94532-41bc-46c1-9d1e-ca7c25782d1d</strong>' { menuentry 'Ubuntu, with Linux 5.4.0-113-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-113-generic-recovery-bff94532-41bc-46c1-9d1e-ca7c25782d1d' { menuentry 'Ubuntu,Linux 5.4.0-110-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-110-generic-advanced-bff94532-41bc-46c1-9d1e-ca7c25782d1d' { menuentry 'Ubuntu, with Linux 5.4.0-110-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-110-generic-recovery-bff94532-41bc-46c1-9d1e-ca7c25782d1d' { menuentry 'Ubuntu,Linux 5.4.0-109-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option '<strong>gnulinux-5.4.0-109-generic-advanced-bff94532-41bc-46c1-9d1e-ca7c25782d1d</strong>' { menuentry 'Ubuntu, with Linux 5.4.0-109-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-109-generic-recovery-bff94532-41bc-46c1-9d1e-ca7c25782d1d' { menuentry 'System setup' $menuentry_id_option 'uefi-firmware' { <strong>以上的加粗文本下面用的到!</strong>
6、修改 GRUB 为以下的内容
查看上面的加粗的文本,各个版本不同,需对应修改! 修改 GRUB_DEFAULT=""的选项
# info -f grub -n 'Simple configuration' #GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden GRUB_TIMEOUT=0 GRUB_DISTRIBUTOR=lsb_release -i -s 2> /dev/null || echo Debian
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" #GRUB_CMDLINE_LINUX_DEFAULT="txet" GRUB_CMDLINE_LINUX="" # Uncomment to enable BadRAM filtering, modify to suit your needs # This works with Linux (no patch required) and with any kernel that obtains # the memory map information from GRUB (GNU Mach, kernel of FreeBSD …) #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef" # Uncomment to disable graphical terminal (grub-pc only) #GRUB_TERMINAL=console # The resolution used on graphical terminal # note that you can use only modes which your graphic card supports via VBE # you can see them in real GRUB with the command `vbeinfo’ #GRUB_GFXMODE=1920×1080 # Uncomment if you don’t want GRUB to pass "root=UUID=xxx" parameter to Linux #GRUB_DISABLE_LINUX_UUID=true # Uncomment to disable generation of recovery mode menu entries #GRUB_DISABLE_RECOVERY="true" # Uncomment to get a beep at grub start #GRUB_INIT_TUNE="480 440 1" "/etc/default/grub" 35L, 1390C
7、更新 GRUB
sudo update-grub
8、重启
reboot
9、若是已经安装的内核版本太多,可以删除一些(以删除 4.15.0-140 和 4.15.0-143 为例),输入命令:
root@angel-MVP-6100:~# sudo apt-get remove linux-image-5.4.0-110-generic linux-image-5.4.0-113-generic
10、后续问题
按照上述过程重启后进行加载驱动,执行命令 sudo modprobe mtd 时出现错误提示如下所示: modprobe: FATAL: Module mtd not found in directory /lib/modules/5.4.0-109-generic 此时可以通过命令查看对比与过去高版本的缺少的内容:查看命令:
root@angel-MVP-6100:~# dpkg --get-selections | grep linux binutils-x86-64-linux-gnu install console-setup-linux install libselinux1:amd64 install libselinux1:i386 install linux-base install linux-firmware install linux-headers-5.4.0-109-generic install linux-headers-5.4.0-110-generic install linux-headers-5.4.0-113-generic install linux-headers-generic-hwe-18.04 install linux-hwe-5.4-headers-5.4.0-109 install linux-hwe-5.4-headers-5.4.0-110 install linux-hwe-5.4-headers-5.4.0-113 install linux-image-5.4.0-109-generic install linux-image-5.4.0-110-generic deinstall linux-image-5.4.0-113-generic deinstall linux-image-5.4.0-42-generic deinstall linux-libc-dev:amd64 install linux-modules-5.4.0-109-generic install linux-modules-5.4.0-110-generic install linux-modules-5.4.0-113-generic install linux-modules-5.4.0-42-generic deinstall linux-modules-extra-5.4.0-109-generic deinstall linux-modules-extra-5.4.0-110-generic deinstall linux-modules-extra-5.4.0-113-generic deinstall linux-modules-extra-5.4.0-42-generic deinstall linux-sound-base install pptp-linux install syslinux install syslinux-common install syslinux-legacy install util-linux install root@angel-MVP-6100:~#
此时缺少什么就安装对应安装的版本内容即可:
root@angel-MVP-6100:~# sudo apt-get install modules-extra-5.4.0-109-generic 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 注意,根据正则表达式 'modules-extra-5.4.0-109-generic' 选中了 'linux-modules-extra-5.4.0-109-generic' 下列软件包是自动安装的并且现在不需要了: amd64-microcode intel-microcode iucode-tool libbz2-1.0:i386 libcom-err2:i386 libdb5.3:i386 libgpm2:i386 liblz4-1:i386 libncursesw5:i386 libtinfo5:i386 libzstd1:i386 thermald 使用'sudo apt autoremove'来卸载它(它们)。 升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 1 个软件包未被升级。 root@angel-MVP-6100:~#
相关文章
- 使用Jetson_benchmark进行性能测试(0)
- win10远程桌面连接ubuntu20(RDP)(0)
- ubuntu中查看各种设备和资源的命令汇总(0)
- Ubuntu 如何实现用 root账户直接登陆(0)
- Smart card authentication with SSH(0)