如何在Fedora 30中设置内核命令行参数

 如何在Fedora 30中设置内核命令行参数

在调试或试验内核时,向内核命令行添加选项是一项常见任务。即将发布的 Fedora 30 版本改为使用 Bootloader 规范(BLS)。根据你修改内核命令行选项的方式,你的工作流可能会更改。继续阅读获取更多信息。

要确定你的系统是使用 BLS 还是旧的规范,请查看文件:

  1. <span class="str">/etc/</span><span class="kwd">default</span><span class="pun">/</span><span class="pln">grub</span>

如果你看到:

  1. <span class="pln">GRUB_ENABLE_BLSCFG</span><span class="pun">=</span><span class="kwd">true</span>

看到这个,你运行的是 BLS,你可能需要更改设置内核命令行参数的方式。

如果你只想修改单个内核条目(例如,暂时解决显示问题),可以使用 grubby 命令:

  1. <span class="pln">$ grubby </span><span class="pun">--</span><span class="pln">update</span><span class="pun">-</span><span class="pln">kernel </span><span class="pun">/</span><span class="pln">boot</span><span class="pun">/</span><span class="pln">vmlinuz</span><span class="pun">-</span><span class="lit">5.0</span><span class="pun">.</span><span class="lit">1</span><span class="pun">-</span><span class="lit">300.fc30.x86</span><span class="pln">_64 </span><span class="pun">--</span><span class="pln">args</span><span class="pun">=</span><span class="str">"amdgpu.dc=0"</span>

要删除内核参数,可以传递 --remove-args 参数给 grubby

  1. <span class="pln">$ grubby </span><span class="pun">--</span><span class="pln">update</span><span class="pun">-</span><span class="pln">kernel </span><span class="pun">/</span><span class="pln">boot</span><span class="pun">/</span><span class="pln">vmlinuz</span><span class="pun">-</span><span class="lit">5.0</span><span class="pun">.</span><span class="lit">1</span><span class="pun">-</span><span class="lit">300.fc30.x86</span><span class="pln">_64 </span><span class="pun">--</span><span class="pln">remove</span><span class="pun">-</span><span class="pln">args</span><span class="pun">=</span><span class="str">"amdgpu.dc=0"</span>

如果有应该添加到每个内核命令行的选项(例如,你希望禁用 rdrand 指令生成随机数),则可以运行 grubby 命令:

  1. <span class="pln">$ grubby </span><span class="pun">--</span><span class="pln">update</span><span class="pun">-</span><span class="pln">kernel</span><span class="pun">=</span><span class="pln">ALL </span><span class="pun">--</span><span class="pln">args</span><span class="pun">=</span><span class="str">"nordrand"</span>

这将更新所有内核条目的命令行,并保存作为将来条目的命令行选项。