免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 6921 | 回复: 11
打印 上一主题 下一主题

[桌面系统] RedHat Linux9下用bootsplash制作全图形启动界面 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-05-28 21:41 |只看该作者 |倒序浏览

  1. 在red hat linux 9中使用BootSplash

  2.    Linux的各种发行版在启动时基本上都有两种模式:silent mode和verbose mode。verbose模式下会打印极为详尽的启动信息,比如挂载文件系统,加载光驱,激活网络服务等等,而silent模式则屏蔽掉这些信息。bootsplash工具可以将一张图片放在silent模式下的虚拟控制台上,从而使Linux用户看到一个全画面的启动过程。另外一个工具是gensplash,比bootsplash要稍微复杂一些,不过功能更为强大,设计也更为合理——它将一些非必要的元素从kernel space挪出来,放在user space来做。
  3.    网络上关于bootsplash(启动动画)的使用基本上是基于Linux的SuSe发行版进行讨论的——开发这组工具的作者说他们的工作平台是SuSe。gensplash则是基于Linux的Gentoo发行版进行讨论的。当然这些两组工具都可以通过适当的改动应用于Linux的其它发行版。
  4.    由于我的工作平台是red hat linux,此篇文章就讨论怎样在RH linux下使用bootsplash。下面先给出相关的一些网站:
  5. http://www.bootsplash.org (官方网站,基本使用及相关原理)
  6. http://www.bootsplash.com  (详尽的使用方法,基于SuSe发行版)
  7. http://www.bootsplash.de  (bootsplash的爱好者组织的网站,资料齐全)
  8. http://www.kernel.org (Linux内核下载)
  9. 本文严重参考http://www.linuxhall.org/modules.php?name=News&file=article&sid=201,哈哈,特此说明。

  10.    现在我们进入正题。

  11.    http://www.bootsplash.org网站上说,bootsplash的内核补丁针对2.4.18--2.4.22和2.6.0-test9,这个消息很旧了,可以到http://www.bootsplash.de站点查看bootsplash所提供的各个版本的内核补丁,然后确定你所用的Linux内核版本,选择一个补丁下载。
  12.    我的内核是2.4.20-8,下载补丁bootsplash-3.0.7-2.4.20.vanilla.diff。补丁中的3.0.7是bootsplash工具的版本号,我们下载bootsplash-3.0.7.tar.bz2,再下载所要用的主题Theme-NewLinux.tar.bz2,关于材料的准备就完成了。这些都可以在上面的提及的网站上找到。如果你的内核没有相应补丁,那么可以选择一个版本的内核源代码,打上补丁后,编译一个新的内核。
  13.    如果没有编译过内核,可以到网上查找相关资料,对照着练习一下。当然,我们需要root的权限。

  14.    第一步>;  修改/usr/include目录下的三个符号链接:asm,scsi,linux(mv asm asm.bak,mv scsi scsi.bak,mv linux linux.bak),如果没有,则要新建。在编译内核时,用到这些链接所指向的一些头文件。我在/usr/src目录下建了一个名为linux的链接指向同一层的内核源代码目录linux-2.4.20-8(这样以后再编译不同版本内核时,只需修改/usr/src目录下的linux符号链接就可以了)。(命令ln -s linux-2.4.20-8 linux),然后进入/usr/include目录,分别执行ln -s /usr/src/linux/include/asm-i386 asm;ln -s /usr/src/linux/include/linux linux;ln -s /usr/src/linux/include/scsi scsi。
  15.    第二步>;  打补丁,假设补丁在/usr/src/linux目录下(不在的话加上路径即可)。patch -p1<bootsplash-3.0.7-2.4.20.vanilla.diff
  16.    第三步>;  设定核心:make menuconfig。确定下列选项被编译进内核而不是被编译成模块。
  17.      对于2.4.x内核:
  18. Code maturity level options  --->;
  19.      [*] Prompt for development and/or incomplete code/drivers
  20. Processor type and features  --->;
  21.      [*] MTRR (Memory Type Range Register) support
  22. Block Devices ->;
  23.      [*] Loopback device support
  24.      [*] RAM disk support
  25.      (4096)   Default RAM disk size
  26.      [*] Initial RAM disk (initrd) support
  27. Console Drivers ->;
  28.      [*] VGA text console
  29.      [*] Video mode selection support
  30. Console Drivers ->; Frame-buffer support ->;
  31.      [*] Support for frame buffer devices
  32.      [*] VESA VGA graphics console
  33.      [*] Use splash screen instead of boot logo

  34.      对于2.6.x内核:
  35. Code maturity level options  --->;
  36.      [*] Prompt for development and/or incomplete code/drivers
  37. Processor type and features  --->;
  38.      [*] MTRR (Memory Type Range Register) support
  39. Device Drivers  --->;
  40.      Block devices  --->;
  41.          <*>; Loopback device support
  42.          <*>; RAM disk support
  43.          (4096) Default RAM disk size
  44.          [*]   Initial RAM disk (initrd) support
  45. Graphics support  --->;
  46.      [*] Support for frame buffer devices
  47.      [*]   VESA VGA graphics support
  48.      Console display driver support  --->;
  49.          [*]   Video mode selection support
  50.          <*>; Framebuffer Console support
  51.      Bootsplash configuration  --->;
  52.          [*] Bootup splash screen

  53.    第四步>;  
  54. a>;   make mkproper 清除旧的设定
  55. b>;   make dep      产生依赖
  56. c>;   make bzImage  编译内核
  57. d>;   make modules modules_install 编译模块
  58. e>;   cp /usr/src/linux/arch/i386/boot/bzImage /boot/bzImage-2.4.20

  59.    第五步>;  安装bootsplash的工具软件和主题图片
  60.   # tar jxvf /patch/bootsplash-3.0.7.tar.bz2
  61.   # tar jxvf /patch/Theme-NewLinux.tar.bz2
  62.   # cd bootsplash-3.0.7/Utilities
  63.   # make all
  64.   # cp fbmngplay fbresolution fbtruetype splash /sbin
  65.   # cd ../../
  66. 下面这几步必须要做,不然在用splash命令时就会出现类似下面的错误:splash:/etc/bootsplash/themes/Linux/images/silent-800x600.jpg不存在。这个其实是由于主题的配置文件中做了绝对路径设定。
  67.   # mkdir /etc/bootsplash
  68.   # mkdir /etc/bootsplash/themes
  69.   # cp -a NewLinux /etc/bootsplash/themes/
  70. 我们来看一个完整的主题配置文件,以800x600分辨率为例,文件名为bootsplash-800x600.cfg,可以用vi进行编辑,####开头的为笔者加的注释。
复制代码

  1. # This is the configuration file for the 800x600 bootsplash picture.
  2. #
  3. # This file is necessary to specify the coordinates of the text box on
  4. # the splash screen.
  5. #
  6. # Comments are welcome by oliver@dediziert.org

  7. # config file version
  8. version=3

  9. # should the picture be displayed?
  10. state=1

  11. # fgcolor is the text forground color.
  12. # bgcolor is the text background (i.e. transparent) color.
  13. fgcolor=7
  14. bgcolor=0

  15. # (tx, ty) are the (x, y) coordinates of the text window in pixels.
  16. # tw/th is the width/height of the text window in pixels.
  17. tx=0
  18. ty=0
  19. tw=800
  20. th=600

  21. ####predefine area for the text info
  22. text_x=260
  23. text_y=545
  24. text_size=20
  25. text_color=0xeef4ff
  26. ####

  27. # name of the picture file (full path recommended)
  28. jpeg=/etc/bootsplash/themes/NewLinux/images/bootsplash-800x600.jpg
  29. silentjpeg=/etc/bootsplash/themes/NewLinux/images/silent-800x600.jpg

  30. progress_enable=1

  31. # background
  32. box silent noover 160 520 642 538 #00000050
  33. box silent inter 160 520 160 537 #b77200 #b77200 #f2b700 #f2b700
  34. box silent  160 520 642 538 #b77200 #b77200 #f2b700 #f2b700

  35. # black border
  36. box silent  160 520 642 520 #b5b5b5
  37. box silent  160 538 642 538 #b5b5b5
  38. box silent  160 520 160 538 #b5b5b5
  39. box silent  642 520 642 538 #b5b5b5

  40. overpaintok=1
复制代码

我们可以修改这个文件中的一些选项来得到自己想要的效果。具体选项的含义可以查看:http://www.bootsplash.org/config.html
# name of the picture file (full path recommended)
jpeg=/etc/bootsplash/themes/NewLinux/images/bootsplash-800x600.jpg
silentjpeg=/etc/bootsplash/themes/NewLinux/images/silent-800x600.jpg
这两行指定了作为启动动画的图片和控制台背景的图片的名字和绝对路径,我们只需把自己制作的图片命名为这里指定的图片,并且放在这个路径下,就可以应用自己的主题了。(想想看,制作themes是相当简单的。不明白为什么网上没有redhat linux的主题图片。)
我修改了/etc/bootsplash/themes/NewLinux/config/bootsplash-800x600.cfg文件,定义显示文本信息区域。###部分是我添加的内容。



  1.    第六步>;  将图片与 init Ram Disk 绑定
  2. splash -s -f /etc/bootsplash/themes/Linux/config/bootsplash-800x600.cfg >; /boot/initrd-splash.img
  3. 对于ide硬盘,我们可以直接用splash工具生成initrd*.img文件,这个文件对ide硬盘来说没什么用,我们在这里只是通过它来使用启动画面。
  4. 如果你只想看到一副静态的画面,跳过第七步,看第八步,不用修改脚本文件。

  5.    第七步>;  将脚本splash.sh拷入/etc/rc.d/下,并修改splash.sh和rc,建议在修改rc脚本文件前进行备份(cp rc rc.bak)
  6. # cp bootsplash-3.0.7/Scripts/splash.sh   /etc/rc.d
  7. 下面来看完整的splash.sh脚本文件,要想这个脚本起作用,必须修改rc脚本,通过rc脚本调用splash.sh脚本,需要赋予splash.sh脚本可执行权限。需要一些shell script的知识。网上很多,google吧。
  8.     我现在的/etc/rc.d/splash.sh脚本,删除了原来放在这个脚本中的绘制进度条部分(调试不成功)和播放动画部分(还没有实验),以及不适用于red hat linux的一些命令。这个脚本现在只打印类似“booting the system"和"shutting down the system"的信息和实现关机时的silent mode。

  9. #!/bin/bash
  10. #
  11. # splash.sh - This shell script triggers bootsplash actions during
  12. # system boot/shutdown. It can be run by the init scripts repeatedly
  13. # specifying the currently executed system script.
  14. #
  15. #rewrite this script at the base of offered by http://www.bootsplash.org
  16. #line with ### added by me

  17. _procsplash="`cat /proc/splash 2>;/dev/null`"

  18. ###give the variable "THEME" the name of the directory which the current
  19. ###silent mode picture stored
  20. THEME="NewLinux"

  21. test ! -d "/etc/bootsplash/themes/$THEME" && exit 0

  22. # assertions
  23. test -r /proc/splash || exit 0
  24. test -z "`echo $_procsplash|grep on`" && exit 0

  25. ####"Yast" is a utilies for SuSE Linux,no for RedHat Linux
  26. ####maybe we can erase it
  27. test "$1" == "bootnetwork stop" -o "$1" == "YaST" && exit 0 # no progress

  28. # We chose verbose in grub
  29. test "`cat /proc/cmdline |grep \"splash=silent\"`" == "" && exit 0

  30. if [ "$PREVLEVEL" == "3" -o "$PREVLEVEL" == "5" ]; then
  31. ###no below ,no silent mode when shutting down
  32. if [ "$RUNLEVEL"  = "3" -o "$RUNLEVEL" == "5" ]; then
  33.    exit 0
  34. fi
  35. ### but why ?
  36. fi

  37. # acquire data
  38. #
  39. _shutdown="no"
  40. _silent="no"
  41. test "`cat /proc/splash |grep silent`" && _silent="yes"
  42. test "$RUNLEVEL" == "6" -o "$RUNLEVEL" == "0" && _shutdown="yes"

  43. test -f "/etc/bootsplash/themes/$THEME/config/bootsplash-`fbresolution`.cfg" && \
  44. . /etc/bootsplash/themes/$THEME/config/bootsplash-`fbresolution`.cfg

  45. #
  46. # Print text string. (Booting/Shutting down the system. Press
  47. # F2 for verbose mode)
  48. #
  49. ###switch to slient mode when shutdown or reboot the system
  50. test "$_shutdown" == "yes" && ( echo "silent" >;/proc/splash; chvt 1)

  51. ###print infomation at the area predifined by config file "bootsplash-800x600.cfg"
  52. _boot="Booting"; test "$_shutdown" == "yes" && _boot="Shutting down"

  53. ###is the area for infomation defined? yes ,print info, no,run on
  54. if [ "$text_x" != "" -a "$text_y" != "" \
  55.       -a "$text_color" != "" -a "$text_size" != "" -a "$_silent" == "yes" ];
  56. then
  57.    fbtruetype -x $text_x -y $text_y -t $text_color -s $text_size \
  58.     "$_boot the system ..."
  59. fi

复制代码

下面来看rc脚本(此为系统脚本,决定runlevel和kill or start services,修改前要备份一下,到时要改回来只要覆盖一下就好了cp rc.bak rc)。下面是我现在的/etc/rc.d/rc脚本,定义一个函数,for循环中调用它,以绘制启动进度。重新写了几行代码,绘制进度条。以运行级下的服务总个数和已经启动的服务个数之比作为progress bar的进度,这样进度条显得均匀了一些。
现在这个可以实现以下功能,开机silent模式,有开始画面,有进度条,进度条下有booting system 提示。关机时切换到silent模式,有画面。提示shutting down the system.

不过在开机的时候,有一半时间进度条是空的(系统在加载内核,检测硬件),在关机的时候,进度条一下子就满了,然后又变空,直到关机。呵呵,回头再改,告一段落了先。

  1. #! /bin/bash
  2. #
  3. # rc            This file is responsible for starting/stopping
  4. #               services when the runlevel changes.
  5. #
  6. # Original Author:      
  7. #               Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>;
  8. #

  9. # check a file to be a correct runlevel script

  10. ###########################Bootsplash start##############
  11. ####function progressbar
  12. function progressbar ()
  13. {
  14. _progress=$1
  15. _num=$num
  16. echo show "$(( 65534*($_progress + 1)/$_num ))">;/proc/splash 2>;/dev/null
  17. }
  18. ####end fuction
  19. ##########################Bootsplash End###############
  20. check_runlevel ()
  21. {
  22. # Check if the file exists at all.
  23. [ -x "$1" ] || return 1

  24. # Reject backup files and files generated by rpm.
  25. case "$1" in
  26. *.rpmsave|*.rpmorig|*.rpmnew|*~|*.orig)
  27.   return 1
  28. ;;
  29. esac
  30. return 0
  31. }

  32. # Now find out what the current and what the previous runlevel are.
  33. argv1="$1"
  34. set `/sbin/runlevel`
  35. runlevel=$2
  36. previous=$1
  37. export runlevel previous

  38. . /etc/init.d/functions

  39. # See if we want to be in user confirmation mode
  40. if [ "$previous" = "N" ]; then
  41. if [ -f /var/run/confirm ] \
  42.   || grep -i confirm /proc/cmdline >;/dev/null; then
  43. rm -f /var/run/confirm
  44. CONFIRM=yes
  45. export CONFIRM
  46. echo $"Entering interactive startup"
  47. else
  48. echo $"Entering non-interactive startup"
  49. fi
  50. fi

  51. # Get first argument. Set new runlevel to this argument.
  52. [ -n "$argv1" ] && runlevel="$argv1"

  53. ####################Bootsplash start###############
  54. progress=0
  55. num=0
  56. ###count the services for progressbar
  57. for countservices in /etc/rc$runlevel.d/*;do
  58. num=$(( $num + 1 ))
  59. done
  60. ###################Bootsplash End##################

  61. # Is there an rc directory for this new runlevel?
  62. [ -d /etc/rc$runlevel.d ] || exit 0

  63. # First, run the KILL scripts.
  64. for i in /etc/rc$runlevel.d/K*; do
  65. ###################Bootsplash start#################
  66. progress=$(( $progress + 1 ))
  67. /etc/rc.d/splash.sh 2>;/dev/null
  68. progressbar $progress
  69. ##################Bootsplash End####################
  70. check_runlevel "$i" || continue

  71. # Check if the subsystem is already up.
  72. subsys=${i#/etc/rc$runlevel.d/K??}
  73. [ -f /var/lock/subsys/$subsys -o -f /var/lock/subsys/$subsys.init ] \
  74. || continue

  75. # Bring the subsystem down.
  76. if egrep -q "(killproc |action )" $i; then
  77. $i stop
  78. else
  79. action $"Stopping $subsys: " $i stop
  80. fi
  81. done

  82. # Now run the START scripts.
  83. for i in /etc/rc$runlevel.d/S*; do
  84. ###################Bootsplash start#################
  85. progress=$(( $progress + 1 ))
  86. /etc/rc.d/splash.sh 2>;/dev/null
  87. progressbar $progress
  88. ##################Bootsplash End####################
  89. check_runlevel "$i" || continue

  90. # Check if the subsystem is already up.
  91. subsys=${i#/etc/rc$runlevel.d/S??}
  92. [ -f /var/lock/subsys/$subsys -o -f /var/lock/subsys/$subsys.init ] \
  93. && continue
  94.      
  95. # If we're in confirmation mode, get user confirmation
  96. if [ -n "$CONFIRM" ]; then
  97. confirm $subsys
  98. case $? in
  99.   0) :;;
  100.   2) CONFIRM=;;
  101.   *) continue;;
  102. esac
  103. fi

  104. # Bring the subsystem up.
  105. if [ "$subsys" = "halt" -o "$subsys" = "reboot" ]; then
  106. export LC_ALL=C
  107. exec $i start
  108. fi
  109. if egrep -q "(daemon |action |success |failure )" $i 2>;/dev/null \
  110.   || [ "$subsys" = "single" -o "$subsys" = "local" ]; then
  111. $i start
  112. else
  113. action $"Starting $subsys: " $i start
  114. fi
  115. done
复制代码

  1.    第八步>;  修改(bootloader)  grub(或者lilo)。我用的是grub,硬盘是ide的。只列出需要修改的部分。我的硬盘分区swap,boot,/。

  2. title Red Hat Linux (2.4.20+bootsplash)
  3. root (hd0,0)
  4. kernel /bzImage-2.4.20 ro root=/dev/hda3 vga=788 splash=silent  
  5. initrd /initrd-splash.img
  6. title Red Hat Linux (2.4.23)
  7. root (hd0,0)
  8. kernel /vmlinuz-2.4.20-8 ro root=LABEL=/  
  9. initrd /initrd-2.4.20-8.img
  10.    788为800x600模式,791为1024x768模式。这里的模式选择要与图片的大小一致。


  11.    到这里就可以重新启动了。呵呵,大功告成。赶紧实验一下,享受自己的全画面Linux启动吧。


  12. ********遇到的问题*******

  13. 启动不了内核
  14. 1/  提示Kernel panic: VFS: Unable to mount root fs on 00:00
  15.     这个大概是因为没有指定根分区,确定你的根分区编号,修改root=LABEL=/为root=/hda* 或者root=/sda*
  16. 2/  error 15:can't find file
  17.     这个应该是initrd*.img文件找不到,确认grub.conf中指定的文件在/boot目录下。
  18. ***********说明********
复制代码
[/code]

论坛徽章:
0
2 [报告]
发表于 2005-05-28 21:46 |只看该作者

RedHat Linux9下用bootsplash制作全图形启动界面

现在这个可以实现以下功能,开机silent模式,有开始画面,有进度条,进度条下有booting system 提示。关机时切换到silent模式,有画面。提示shutting down the system.

不过在开机的时候,有一半时间进度条是空的(系统在加载内核,检测硬件),在关机的时候,进度条一下子就满了,然后又变空,直到关机。呵呵,回头再改,告一段落了先.

论坛徽章:
0
3 [报告]
发表于 2005-05-29 09:10 |只看该作者

RedHat Linux9下用bootsplash制作全图形启动界面

呵呵,感兴趣的朋友实验一下。

论坛徽章:
0
4 [报告]
发表于 2005-05-29 10:50 |只看该作者

RedHat Linux9下用bootsplash制作全图形启动界面

我实验了几天,终于弄出来了,绝对可行哦,哪位要是按照这个办法来弄,有什么问题可以问我.

论坛徽章:
0
5 [报告]
发表于 2005-05-30 08:20 |只看该作者

RedHat Linux9下用bootsplash制作全图形启动界面

up

论坛徽章:
0
6 [报告]
发表于 2005-05-30 09:41 |只看该作者

RedHat Linux9下用bootsplash制作全图形启动界面

upup
顶上,等我回去try try!!

论坛徽章:
0
7 [报告]
发表于 2005-05-31 16:01 |只看该作者

RedHat Linux9下用bootsplash制作全图形启动界面

呵呵,终于可以作个像Gentoo这样的漂亮启动界面了
_Unix_ 该用户已被删除
8 [报告]
发表于 2005-06-01 09:00 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
9 [报告]
发表于 2005-06-02 19:25 |只看该作者

RedHat Linux9下用bootsplash制作全图形启动界面

好啊,回去试试先。谢谢楼主分享

论坛徽章:
0
10 [报告]
发表于 2005-06-03 00:03 |只看该作者

RedHat Linux9下用bootsplash制作全图形启动界面

学习一下.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP