目录😋
- 基本命令
- 查看目前的内核版本
- 查看目前已安装的内核
- 内核移除
- 内核离线安装
- deb依赖下载
- 内核安装
- 更新grub并重启
- 内核版本切换
- grub文件详解
- grub引导界面显示
基本命令
查看目前的内核版本
uname -r
查看目前已安装的内核
sudo dpkg --get-selections | grep linux-image
内核移除
注意:删除当前版本重启会使用低一级的已安装内核,如果是最后一个内核版本删除之后重启会进入BIOS界面。对于内核版本过多的情况,考虑删除若干旧版本内核。一般情况不删,移除失败可能会导致一些问题,例如:重启无法上网等。遇到这种情况,可通过更换内核版本。
sudo apt-get remove linux-image-内核版本
内核离线安装
参考:Ubuntu18.04 内核安装和Grub引导设置与修复
deb依赖下载
请点击传送门,比如我要下载5.8.0版本的内核资源,就下载如下的资源即可,64位则选择amd64,deb包中不需要下载含lowlatency的资源。
内核安装
将资源放置在同一个文件夹内,直接安装所有的依赖。
sudo dpkg -i linux*
对于我来说(此时我网卡废了),没有遇到需要下载其他依赖的情况,如果提示缺少依赖,则修复即可。如果不能上网,则需要在其他可上网设备上下载需要的deb文件。
sudo apt-get -f install
更新grub并重启
sudo update-grub
sudo reboot
重启完后,因为移除内核导致的网卡丢失问题也自动解决了。此时的内核版本为刚刚安装好的内核。
(base) yuanbaoqiang@yuanbaoqiang-911 ~$ uname -r
5.8.0-050800-generic
内核版本切换
内核版本切换可以参考:Linux 内核切换 grub (Ubuntu)。
除此之外做个补充,网页上的很多关于grub的设置都是比较老的,而每个版本的ubuntu进入grub界面的方式也是不同的,因此最好的方式就是查看自己电脑上的grub文件注释,官方写的很详细,over~
grub文件详解
info -f grub -n 'Simple configuration'
grub引导界面显示
其实只需要设置俩参数即可:
# 显示grub菜单
GRUB_TIMEOUT_STYLE=menu
# 0代表立即进系统,不会显示menu
# -1代表一直显示menu,直到用户做出选择
GRUB_TIMEOUT=-1
相关解释如下:
'GRUB_TIMEOUT_STYLE'
If this option is unset or set to 'menu', then GRUB will display
the menu and then wait for the timeout set by 'GRUB_TIMEOUT' to
expire before booting the default entry. Pressing a key interrupts
the timeout.
If this option is set to 'countdown' or 'hidden', then, before
displaying the menu, GRUB will wait for the timeout set by
'GRUB_TIMEOUT' to expire. If <ESC> is pressed during that time, it
will display the menu and wait for input. If a hotkey associated
with a menu entry is pressed, it will boot the associated menu
entry immediately. If the timeout expires before either of these
happens, it will boot the default entry. In the 'countdown' case,
it will show a one-line indication of the remaining time.
'GRUB_TIMEOUT'
Boot the default entry this many seconds after the menu is
displayed, unless a key is pressed. The default is '5'. Set to
'0' to boot immediately without displaying the menu, or to '-1' to
wait indefinitely.
If 'GRUB_TIMEOUT_STYLE' is set to 'countdown' or 'hidden', the
timeout is instead counted before the menu is displayed.
修改完后记得:
sudo update-grub