删除 CentOS Stream 8 开机多余引导项及等待时间
刪除 CentOS Stream 8 開機多余引導項及等待時間
- 刪除"System setup"
- 刪除 CentOS (0-rescue-XXX)
- 去掉開機關于引導項的 5 秒等待時間
筆者的運行環(huán)境:
CentOS Stream 8 x86_64
??筆者的電腦在安裝 CentOS Stream 8 之后,開機一直出現(xiàn) 5 秒的開機引導項選擇等待。在該引導項中,除了無操作之后,系統(tǒng)默認選擇的 CentOS Stream 8,還有兩個多余項:
- CentOS (0-rescue-XXX) 8
- System setup
??它們總是延長開機時間,因此筆者決定去掉它們。
刪除"System setup"
進入目錄 /etc/。
[root@localhost ~]# cd /etc/輸入如下命令來查找與 grub 有關的文件。
[root@localhost etc]# ls -lF *grub* lrwxrwxrwx. 1 root root 31 3月 2 16:03 grub2-efi.cfg -> ../boot/efi/EFI/centos/grub.cfg*grub.d: 總用量 92 -rwxr-xr-x. 1 root root 8958 3月 2 16:03 00_header* -rwxr-xr-x. 1 root root 1043 7月 21 14:41 00_tuned* -rwxr-xr-x. 1 root root 232 3月 2 16:03 01_users* -rwxr-xr-x. 1 root root 832 3月 2 16:03 08_fallback_counting* -rwxr-xr-x. 1 root root 14088 3月 2 16:03 10_linux* -rwxr-xr-x. 1 root root 830 3月 2 16:03 10_reset_boot_success* -rwxr-xr-x. 1 root root 889 3月 2 16:03 12_menu_auto_hide* -rwxr-xr-x. 1 root root 11696 3月 2 16:03 20_linux_xen* -rwxr-xr-x. 1 root root 2559 3月 2 16:03 20_ppc_terminfo* -rwxr-xr-x. 1 root root 10670 3月 2 16:03 30_os-prober* -rwxr-xr-x. 1 root root 1412 3月 2 16:03 30_uefi-firmware* -rwxr-xr-x. 1 root root 214 3月 2 16:03 40_custom* -rwxr-xr-x. 1 root root 216 3月 2 16:03 41_custom* -rw-r--r--. 1 root root 483 3月 2 16:03 README可以看出,在上面列出的文件中,我們需要的文件為 grub2-efi.cfg。不過,這是一個符號鏈接文件,它指向文件 /boot/efi/EFI/centos/grub.cfg。可以選擇直接編輯文件 grub2-efi.cfg,也可以選擇編輯文件 grub.cfg。
以文本方式打開上述文件,找到與 menuentry 、System setup 有關的段落。
### BEGIN /etc/grub.d/30_uefi-firmware ### menuentry 'System setup' $menuentry_id_option 'uefi-firmware' {fwsetup } ### END /etc/grub.d/30_uefi-firmware ###將此段注釋或刪除。(注意:修改前最好先備份,以免發(fā)生誤修改)
### BEGIN /etc/grub.d/30_uefi-firmware ### # menuentry 'System setup' $menuentry_id_option 'uefi-firmware' { # fwsetup #} ### END /etc/grub.d/30_uefi-firmware ###現(xiàn)在,開機引導項 System setup 就被去掉了。重啟 CentOS Stream 8 即可看到效果。
刪除 CentOS (0-rescue-XXX)
與上面 刪除"System setup" 類似的方法,在文件 /boot/efi/EFI/centos/grub.cfg 中尋找與 menuentry 、CentOS (0-rescue-XXX) 有關的段落,并注釋掉。
如果沒有找到(筆者在 CentOS Stream 8 上沒有找到),說明上述的引導項沒有位于此文件中,不過也應該位于某個目錄中。于是擴大查找范圍,在目錄 /boot 中查找關鍵字 0-rescue。
(下面的 XXX 是被筆者替換過的序列號文本,不同電腦會有不同。)
[root@localhost ~]# grep -rn "0-rescue" /boot /boot/loader/entries/XXX-0-rescue.conf:1:title CentOS (0-rescue-XXX) 8 /boot/loader/entries/XXX-0-rescue.conf:2:version 0-rescue-XXX /boot/loader/entries/XXX-0-rescue.conf:3:linux /vmlinuz-0-rescue-XXX /boot/loader/entries/XXX-0-rescue.conf:4:initrd /initramfs-0-rescue-XXX.img /boot/loader/entries/XXX-0-rescue.conf:6:id centos-XXX-0-rescue-XXX /boot/System.map-4.18.0-326.el8.x86_64:9105:XXX T cgroup_rstat_exit /boot/System.map-4.18.0-326.el8.x86_64:26614:XXX T acpi_disable /boot/System.map-4.18.0-326.el8.x86_64:54743:XXX r __pci_fixup_resume_earlyricoh_mmc_fixup_XXX果然查找到了關鍵信息。上面的輸出表明,關鍵信息在文件 /boot/loader/entries/XXX-0-rescue.conf 中。打開目錄 /boot/loader/entries/,可以發(fā)現(xiàn)其中有兩個文件,正好對應著 CentOS Stream 8 開機的剩余兩個開機引導項。
[root@localhost ~]# ls /boot/loader/entries/ XXX-0-rescue.conf XXX-4.18.0-326.el8.x86_64.conf刪除上述的文件 XXX-0-rescue.conf 即可。重啟 CentOS Stream 8 即可看到效果。
(注意:刪除前最好先備份。不要刪除另外一個、當前系統(tǒng)的引導項!)
去掉開機關于引導項的 5 秒等待時間
與上面 刪除"System setup"類似的方法,打開文件 /boot/efi/EFI/centos/grub.cfg,找到如下段落:
(注意:一定要選擇如下段落。此文件中可能有與如下代碼相似的代碼,不要找錯了。)
terminal_output console if [ x$feature_timeout_style = xy ] ; thenset timeout_style=menuset timeout=5 # Fallback normal timeout code in case the timeout_style feature is # unavailable. elseset timeout=5 fi將上述段落中的時間改為 0。即,將 timeout=5 改為 timeout=0 。
(注意:修改前最好先備份,以免發(fā)生誤修改)
terminal_output console if [ x$feature_timeout_style = xy ] ; thenset timeout_style=menuset timeout=0 # Fallback normal timeout code in case the timeout_style feature is # unavailable. elseset timeout=0 fi現(xiàn)在,開機引導項的等待時間就被去掉了。重啟 CentOS Stream 8 即可看到效果。
總結(jié)
以上是生活随笔為你收集整理的删除 CentOS Stream 8 开机多余引导项及等待时间的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 如何在 Windows 主机上访问本地局
- 下一篇: 在 IntelliJ IDEA 中,如何