9

记一次回滚 Arch 内核的过程

 3 years ago
source link: https://rapiz.me/2017/switch-linux-kernel/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

这回sudo pacman -Syu后发现 shutdown, suspend 这些操作都出问题了。我在#archlinux-cn里问了下,得知很有可能是新内核出了 Bug。所以我决定先回滚一下内核看问题能不能解决。

内核的安装和编译

首先安装LTS内核,当然你选择其他内核也行(记得要把我命令中的linux-lts换成对应的名称)

sudo pacman -S linux-lts

然后编译
sudo mkinitcpio -p linux-lts

这时候内核文件已经在/boot下了
可以看到
initramfs-linux-lts.img
vmlinuz-linux-lts

从新内核启动

如果你使用 Grub,在启动项里或许已经能看到了。当然我不用 Grub 所以我也不知道:)
我之前一直使用 EFISTUB 直接启动内核,并且装了一个 rEFInd 以防万一。
所以接下来我将修改这两项使之指向新内核。

efibootmgr

efibootmgr 可以设置从 EFISTUB 启动。
添加启动项的命令应该看起来像这样

sudo efibootmgr -d /dev/sdX -p Y -c -L "Arch Linux" -l /vmlinuz-linux -u "root=/dev/sdBZ rw initrd=/initramfs-linux.img"

/dev/sdX 和 Y 是 ESP 分区所在的硬盘名称和分区. 让 root= 指向你的root分区,如果你想用UUID指定可以写root=UUID=xxxxxxxx。-u 后面跟内核启动参数。
一般笔记本都会加一个 intel 微码的参数。如果你当时装过微码就肯定知道我在说什么。没有也无妨。
下面是我实际执行的命令。如果你不需要 intel 微码请把 initrd=/intel-ucode.img 删去。

sudo efibootmgr -d /dev/sda -p 1 -c -L "Arch Linux with LTS kernel" -l /vmlinuz-linux-lts -u "root=UUID=xxxxxxxxxx rw quiet initrd=/intel-ucode.img initrd=/initramfs-linux-lts.img"

rEFInd

只需要编辑 /boot/refind_linux.conf 把里面的 initramfs-linux 改成 initramfs-linux-lts 就好了。

重启就可以进入新内核了。
执行 uname -r 查看现在到底在运行哪个内核。

除了 linux-lts 外,还有众多的内核分支可供选择。打开了折腾的新天地


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK