为GRUB2添加背景图片

Linux大全评论400 views阅读模式

1.自己弄一张自己喜欢的,然后将它转化为xx.tga格式的.(只修改后缀名是没有用的,必须是要真正是tga格式的(建议使用tga),其他的我测试过会有问题,不知道是不是自己修改的问题还是其他问题,总之我的试过不行), 并且大小必须合乎你机子所支持的大小(可以在电脑启动时,进入grub命令行,输入:vebinfo查看自己的电脑所支持的分辨率.

2.将修改后的图片复制到/usr/share/images/grub/xx.tga, 最好顺便也复制一张到/boot/grub/目录下.

3.修改/etc/grub.d/05_debian_theme文件

  1. #!/bin/bash -e  
  2.   
  3. source /usr/lib/grub/grub-mkconfig_lib  
  4.   
  5. # this allows desktop-base to override our settings  
  6. f=/usr/share/desktop-base/grub_background.sh  
  7. if test -e ${f} ; then  
  8.   source ${f}  
  9. else  
  10.   #WALLPAPER="/usr/share/images/desktop-base/moreblue-orbit-grub.png"  
  11.   WALLPAPER="/usr/share/images/grub/<span style="color:#FF0000;">yangzhiyong.tga</span>"  
  12.   COLOR_NORMAL="<span style="color:#FF0000;">white/black</span>"  
  13.   COLOR_HIGHLIGHT="<span style="color:#FF0000;">green/brown</span>"  
  14. fi  
  15.   
  16. set_mono_theme()  
  17. {  
  18.   cat << EOF  
  19. set menu_color_normal=<span style="color:#FF0000;">white/black</span>  
  20. set menu_color_highlight=<span style="color:#FF0000;">green/brown</span>  
  21. EOF  
  22. }  
  23.   
  24. # check for usable backgrounds  
  25. use_bg=false  
  26. if [ "$GRUB_TERMINAL_OUTPUT" = "gfxterm" ] ; then  
  27.   for i in /boot/grub/`basename ${WALLPAPER}` ${WALLPAPER} ; do  
  28.     if is_path_readable_by_grub $i ; then   
  29.       bg=$i  
  30.       case ${bg} in  
  31.         *.png)      reader=png ;;  
  32.         *.tga)      reader=tga ;;  
  33.         *.jpg|*.jpeg)   reader=jpeg ;;  
  34.       esac  
  35.       if test -e /boot/grub/${reader}.mod ; then  
  36.         echo "Found background image: `basename ${bg}`" >&2  
  37.         use_bg=true  
  38.         break  
  39.       fi  
  40.     fi  
  41.   done  
  42. fi  
  43.   
  44. # set the background if possible  
  45. if ${use_bg} ; then  
  46.   prepare_grub_to_access_device `${grub_probe} --target=device ${bg}`  
  47.   cat << EOF  
  48. insmod ${reader}  
  49. if background_image `make_system_path_relative_to_its_root ${bg}` ; then  
  50.   set color_normal=${COLOR_NORMAL}  
  51.   set color_highlight=${COLOR_HIGHLIGHT}  
  52. else  
  53. EOF  
  54. fi  
  55.   
  56. # otherwise, set a monochromatic theme for Ubuntu  
  57. if ${use_bg} ; then  
  58.   set_mono_theme | sed -e "s/^/  /g"  
  59.   echo "fi"  
  60. else  
  61.   set_mono_theme  
  62. fi  

将上面那个

  1. WALLPAPER="/usr/share/images/grub/yangzhiyong.tga"中红色部分改为你刚才复制进入/usr/share/images/目录下的图片的文件名.  

4.最好记得要update-grub..

企鹅博客
  • 本文由 发表于 2019年9月9日 01:15:50
  • 转载请务必保留本文链接:https://www.qieseo.com/209518.html

发表评论