centos7删除开机动画及修改启动菜单

2,189 阅读2分钟

删除开机动画

编辑vi /etc/default/grub 文件,找到 GRUB_CMDLINE_LINUX 一行,将“rhgb quiet” 改为 “quiet” (去掉rhgb)

修改前:

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

修改后:

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap quiet"
GRUB_DISABLE_RECOVERY="true"

最后执行命令:

grub2-mkconfig --output=/boot/grub2/grub.cfg  

重启就可以看到效果了

卸载开机启动画面(GUI)

sudo yum autoremove plymouth

修改启动等待时间

编辑vi /boot/grub2/grub.cfg 文件,修改timeout属性,如开机等待5秒修改为2秒

修改前:

terminal_output console
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi

修改后:

terminal_output console
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=2
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=2
fi

注意: 这个文件是由模板/etc/grub.d和配置文件/etc/default/grub通过命令grub2-mkconfig生成的

删除多余开机菜单

编辑vi /boot/grub2/grub.cfg 文件,删除menuentry开头的段落,menuentry后面的就是菜单名

修改前:

### BEGIN /etc/grub.d/10_linux ###
menuentry 'CentOS Linux (3.10.0-957.27.2.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-957.27.2.el7.x86_64-advanced-4e334e31-4461-4c13-9c08-93af5da320ea' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod xfs
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  9cffe801-9abf-4403-805e-e92b604005d2
        else
          search --no-floppy --fs-uuid --set=root 9cffe801-9abf-4403-805e-e92b604005d2
        fi
        linux16 /vmlinuz-3.10.0-957.27.2.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap quiet 
        initrd16 /initramfs-3.10.0-957.27.2.el7.x86_64.img
}

menuentry 'CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-957.el7.x86_64-advanced-4e334e31-4461-4c13-9c08-93af5da320ea' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod xfs
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  9cffe801-9abf-4403-805e-e92b604005d2
        else
          search --no-floppy --fs-uuid --set=root 9cffe801-9abf-4403-805e-e92b604005d2
        fi
        linux16 /vmlinuz-3.10.0-957.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap quiet 
        initrd16 /initramfs-3.10.0-957.el7.x86_64.img
}

if [ "x$default" = 'CentOS Linux (3.10.0-957.27.2.el7.x86_64) 7 (Core)' ]; then default='Advanced options for CentOS Linux>CentOS Linux (3.10.0-957.27.2.el7.x86_64) 7 (Core)'; fi;

修改后:

### BEGIN /etc/grub.d/10_linux ###
menuentry 'CentOS Linux (3.10.0-957.27.2.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-957.27.2.el7.x86_64-advanced-4e334e31-4461-4c13-9c08-93af5da320ea' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod xfs
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  9cffe801-9abf-4403-805e-e92b604005d2
        else
          search --no-floppy --fs-uuid --set=root 9cffe801-9abf-4403-805e-e92b604005d2
        fi
        linux16 /vmlinuz-3.10.0-957.27.2.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap quiet 
        initrd16 /initramfs-3.10.0-957.27.2.el7.x86_64.img
}

if [ "x$default" = 'CentOS Linux (3.10.0-957.27.2.el7.x86_64) 7 (Core)' ]; then default='Advanced options for CentOS Linux>CentOS Linux (3.10.0-957.27.2.el7.x86_64) 7 (Core)'; fi;

重启就可以看到效果了