Ubuntu-内核安装及版本切换


基本命令

查看目前的内核版本

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
  • 2
    点赞
  • 35
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
Ubuntu内核中,死锁是指当多个线程或进程同时持有资源,并且互相等待对方释放资源时发生的一种情况。死锁通常是由于资源分配的顺序不当或者互斥锁的使用不正确引起的。当死锁发生时,系统的进程或线程将无法继续执行,导致系统无响应。 在Linux内核中,为了避免死锁的发生,使用了自旋锁和非自旋锁(如semaphore或mutex)两种锁机制。自旋锁是一种忙等待的锁,当一个线程无法获取锁时,它会一直在一个循环中自旋等待,直到获取到锁为止。而非自旋锁在获取不到锁的时候会进入阻塞状态,从而进入内核态。然而,使用非自旋锁会导致线程从用户态和内核态之间频繁切换,影响锁的性能。 因此,在Ubuntu内核中,为了避免死锁并提高锁的性能,可以考虑使用自旋锁来保护共享数据。自旋锁适合用于只有进程上下文访问的场景,而在同时涉及中断上下文和进程上下文的场景下,则需要谨慎选择适当的锁机制,以避免死锁的发生。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Linux驱动之 内核最常见的自旋锁及死锁示例](https://blog.csdn.net/qq_52858062/article/details/116397144)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [Linux内核 自旋锁spin lock,教你如何用自旋锁让ubuntu死锁](https://blog.csdn.net/daocaokafei/article/details/108266526)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

YuanbaoQiang

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

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

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

打赏作者

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

抵扣说明:

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

余额充值