魔法师小曹儿 發表於 2023-5-24 16:46:00

Ubuntu安装/切换内核

<h2 id="查看当前已安装的内核">查看当前已安装的内核</h2>
<pre><code>$ sudo dpkg --get-selections |grep linux-image
linux-image-5.15.0-71-generic                   install
linux-image-5.15.0-72-generic                   install
linux-image-5.4.0-149-generic                   install
linux-image-generic-hwe-20.04                   install
</code></pre>
<h2 id="安装指定版本内核">安装指定版本内核</h2>
<p><strong>Install kernel-generic:通用内核,一般 PC 及 Server</strong></p>
<pre><code>sudo apt list linux-headers-5.15.*-*-generic linux-image-5.15.*-*-generic
sudo apt install linux-headers-5.15.*-*-generic linux-image-5.15.*-*-generic
</code></pre>
<p><strong>Install low-latency kernel:低延迟内核,适用于工业嵌入式系统(Industrial embedded systems)</strong></p>
<pre><code>sudo apt list linux-headers-5.15.*-*-lowlatency linux-image-5.15.*-*-lowlatency
sudo apt install linux-headers-5.15.*-*-lowlatency linux-image-5.15.*-*-lowlatency
</code></pre>
<h2 id="更新initramfs">更新initramfs</h2>
<pre><code>sudo update-initramfs -u -k all
</code></pre>
<h2 id="修改引导菜单">修改引导菜单</h2>
<p>/etc/default/grub</p>
<pre><code>GRUB_DEFAULT=0
# GRUB_TIMEOUT_STYLE=hidden    &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;注释该行 显示grub菜单
GRUB_TIMEOUT=20                &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;设置菜单超时时长
GRUB_DISTRIBUTOR=`lsb_release -i -s 2&gt; /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=""
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=640x480

# 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"
</code></pre>
<p>sudo update-grub</p>
<p>reboot<br>
通过grub菜单进入使用新内核的系统<br>
sudo apt autoremove<br>
卸载掉旧内核</p>
<pre><code>检查内核启动顺序

grep menuentry /boot/grub/grub.cfg

编辑默认启动内核

vim /etc/default/grub

GRUB_DEFAULT=0
# 改为
修改GRUB_DEFAULT的值为"1&gt;2"
# 或者
GRUB_DEFAULT="Advanced options for Ubuntu&gt;Ubuntu, with Linux 5.4.0-42-generic"

sudo update-grub

reboot

uname -r # 检查
</code></pre><br><br>
来源:https://www.cnblogs.com/ishmaelwanglin/p/17428837.html
頁: [1]
查看完整版本: Ubuntu安装/切换内核