Press "Enter" to skip to content

fedora下应用grub主题

众所周知grub的默认命令行模式不美观。下面采用主题美化,以blur主题为例:

下载地址:https://www.gnome-look.org/p/1220920/

下载完成以后先解压:

miss@localhost:~$ cd ~/下载
miss@localhost:~/下载$ ls
atom.x86_64.rpm    blur-grub2_fullhd.tar             WeChatLinux_x86_64.rpm
blur-grub2_fullhd  com.obsproject.Studio.flatpakref
miss@localhost:~/下载$ tar -xvf blur-grub2_fullhd.tar
blur-grub2_fullhd/blur-grub2-fullhd/select_sw.png
blur-grub2_fullhd/blur-grub2-fullhd/theme.txt
blur-grub2_fullhd/blur-grub2-fullhd/select_nw.png
blur-grub2_fullhd/blur-grub2-fullhd/DejaVuSans-Regular-16.pf2
blur-grub2_fullhd/blur-grub2-fullhd/DejaVuSans-Regular-24.pf2
blur-grub2_fullhd/blur-grub2-fullhd/select_se.png
blur-grub2_fullhd/blur-grub2-fullhd/select_w.png
blur-grub2_fullhd/blur-grub2-fullhd/
blur-grub2_fullhd/blur-grub2-fullhd/select_s.png
blur-grub2_fullhd/blur-grub2-fullhd/select_ne.png
blur-grub2_fullhd/blur-grub2-fullhd/progress_highlight_c.png
blur-grub2_fullhd/blur-grub2-fullhd/select_e.png
blur-grub2_fullhd/blur-grub2-fullhd/select_c.png
blur-grub2_fullhd/install.sh
blur-grub2_fullhd/
blur-grub2_fullhd/blur-grub2-fullhd/progress_bar_c.png
blur-grub2_fullhd/blur-grub2-fullhd/select_n.png
blur-grub2_fullhd/blur-grub2-fullhd/background.png
miss@localhost:~$ cd ~/下载
miss@localhost:~/下载$ ls
atom.x86_64.rpm    blur-grub2_fullhd.tar             WeChatLinux_x86_64.rpm
blur-grub2_fullhd  com.obsproject.Studio.flatpakref
miss@localhost:~/下载$ tar -xvf blur-grub2_fullhd.tar
blur-grub2_fullhd/blur-grub2-fullhd/select_sw.png
blur-grub2_fullhd/blur-grub2-fullhd/theme.txt
blur-grub2_fullhd/blur-grub2-fullhd/select_nw.png
blur-grub2_fullhd/blur-grub2-fullhd/DejaVuSans-Regular-16.pf2
blur-grub2_fullhd/blur-grub2-fullhd/DejaVuSans-Regular-24.pf2
blur-grub2_fullhd/blur-grub2-fullhd/select_se.png
blur-grub2_fullhd/blur-grub2-fullhd/select_w.png
blur-grub2_fullhd/blur-grub2-fullhd/
blur-grub2_fullhd/blur-grub2-fullhd/select_s.png
blur-grub2_fullhd/blur-grub2-fullhd/select_ne.png
blur-grub2_fullhd/blur-grub2-fullhd/progress_highlight_c.png
blur-grub2_fullhd/blur-grub2-fullhd/select_e.png
blur-grub2_fullhd/blur-grub2-fullhd/select_c.png
blur-grub2_fullhd/install.sh
blur-grub2_fullhd/
blur-grub2_fullhd/blur-grub2-fullhd/progress_bar_c.png
blur-grub2_fullhd/blur-grub2-fullhd/select_n.png
blur-grub2_fullhd/blur-grub2-fullhd/background.png

可以看到解压后文件夹中有一个install.sh的安装文件,运行。

miss@localhost:~/下载/blur-grub2_fullhd$ sudo ./install.sh
[sudo] miss 的密码
==> Copying files...
  You must set the theme in your GRUB config file,
  Would you like to do it now? [y/n] y

==> Applying changes...
正在生成 grub 配置文件 ...
找到主题/boot/grub2/themes/blur-grub2-fullhd/theme.txt
发现了 Windows Boot Manager位于 /dev/nvme1n1p1@/efi/Microsoft/Boot/bootmgfw.efi
正在添加 UEFI 固件设置的引导菜单项……
完成
  -> Theme successfuly applied!
  -> Restart your PC to check it out.

但此时图形界面还不能生效,原因三配置中禁用了图形截面。

vim /etc/default/grub

按i进入编辑模式,把其中的:

GRUB_TERMINAL_INPUT=console

这一行注释掉或者删掉。esc退出编辑模式,然后:wq保存退出。

最后更新grub配置:

miss@localhost:~$ sudo grub2-mkconfig -o /boot/efi/EFI/fedora.cfg
[sudo] miss 的密码
正在生成 grub 配置文件 ...
找到主题/boot/grub2/themes/blur-grub2-fullhd/theme.txt
发现了 Windows Boot Manager位于 /dev/nvme1n1p1@/efi/Microsoft/Boot/bootmgfw.efi
正在添加 UEFI 固件设置的引导菜单项……
完成
reboot

reboot重启后可以看到主题已经应用成功了。

另附:设置grub默认启动项

miss@localhost:~$ sudo cat /boot/grub2/grub.cfg | grep Windows
[sudo] miss 的密码
menuentry 'Windows Boot Manager (位于 /dev/nvme1n1p1)' --class windows --class os $menuentry_id_option 'osprober-efi-1F5F-3E29' {
miss@localhost:~$ 

复制 Windows Boot Manager (位于 /dev/nvme1n1p1)

sudo grub2-set-default "Windows Boot Manager (位于 /dev/nvme1n1p1)"

记得更新grub配置。

删除多余的Grub启动项

在每次系统更新内核后grub引导界面都会多出一个启动项,下面来删除它。

(注:包含探索的过程,看方法建议拉到下面)

查看内核版本:

miss@localhost:~$ rpm -qa kernel
kernel-6.14.11-300.fc42.x86_64
kernel-6.15.9-201.fc42.x86_64

删除内核:

miss@localhost:~$ sudo dnf remove kernel-6.14.11-300.fc42.x86_64
Package Arch Version Repository Size
Removing:
kernel x86_64 6.14.11-300.fc42 updates 0.0 B

Transaction Summary:
Removing: 1 package

此次操作完成之后,0 B 额外的空间被使用 (安装 0 B, 删除 0 B)
Is this ok [y/N]: y
执行事务
[1/2] 准备事务 100% | 8.0 B/s | 1.0 B | 00m00s
[2/2] 删除 kernel-0:6.14.11-300.fc42.x86_64 100% | 775.0 B/s | 100.0 B | 00m00s
完成!

最后更新grub2配置:

sudo grub2-mkconfig -o /boot/efi/EFI/fedora.cfg

重启后却发现启动项依然没变。

原因是启用了BLS。在/etc/default/grub目录下有一行如下:

GRUB_ENABLE_BLSCFG=true

Fedora 默认启用了 BLS (Boot Loader Specification),也就是说 grub 菜单里的内核项并不是直接写在 /boot/grub2/grub.cfg 里,而是来自 /boot/loader/entries/ 目录里的配置文件。

接下来的操作请看终端日志:

miss@localhost:~$ sudo -i
root@localhost:~# cd /boot/loader/entries/
root@localhost:/boot/loader/entries# ls
c7d8dce890644ca1abfa3a807c69fbe2-0-rescue.conf
c7d8dce890644ca1abfa3a807c69fbe2-6.14.0-63.fc42.x86_64.conf
c7d8dce890644ca1abfa3a807c69fbe2-6.14.11-300.fc42.x86_64.conf
c7d8dce890644ca1abfa3a807c69fbe2-6.15.9-201.fc42.x86_64.conf
root@localhost:/boot/loader/entries# rm c7d8dce890644ca1abfa3a807c69fbe2-6.14.0-63.fc42.x86_64.conf
rm: 是否删除regular file 'c7d8dce890644ca1abfa3a807c69fbe2-6.14.0-63.fc42.x86_64.conf'?y
root@localhost:/boot/loader/entries# ls
c7d8dce890644ca1abfa3a807c69fbe2-0-rescue.conf
c7d8dce890644ca1abfa3a807c69fbe2-6.14.11-300.fc42.x86_64.conf
c7d8dce890644ca1abfa3a807c69fbe2-6.15.9-201.fc42.x86_64.conf
root@localhost:/boot/loader/entries# rm c7d8dce890644ca1abfa3a807c69fbe2-6.14.11-300.fc42.x86_64.conf
rm: 是否删除regular file 'c7d8dce890644ca1abfa3a807c69fbe2-6.14.11-300.fc42.x86_64.conf'?y

重启即可生效。

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注