轻松拿下Bootsplash
时间:2004-01-05
来源:互联网
我的内核是2.4.23,LFS版本是5.0后的cvs1222。
1.下载所需内核补丁,工具和主题:
ftp://ftp.suse.com/pub/people/stepan....4.23.diff.bz2
ftp://ftp.suse.com/pub/people/stepan...-3.0.7.tar.bz2
ftp://ftp.suse.com/pub/people/stepan...-Linux.tar.bz2
2.给内核打补丁,并加上所需要的内核参数。
cd /usr/src/linux
make mrproper
patch -Np1 -i ../bootsplash-3.0.7-2.4.23.diff
make menuconfig
选上这几个参数:
Code maturity level options --->
Prompt for development and/or incomplete code/drivers
Block devices ---> RAM disk support
Block devices ---> Initial RAM disk (initrd) support
Console drivers ---> Video mode selection support
Console drivers ---> Frame-buffer support --->
Support for frame buffer devices
VESA VGA graphics console
Use splash screen instead of boot logo
然后是编译内核了:
make dep && make bzImage
再把生成的内核拷贝到/boot下:
cp arch/i386/boot/bzImage /boot/lfs-bootsplash
再在grub的配置文件/boot/grub/menu.lst里面增加一项:
title LFS Boot Splash
root (hd0,6)
kernel /boot/lfs-bootsplash root=/dev/hda7 ro
现在这个已经能启动了,不过还缺少一些boot splash
需要的参数,我们后面还要改的。
3.安装bootsplash-3.0.7里面的工具
解压,并进入bootsplash-3.0.7/Utilities目录。执行命令:
make
cp fbresolution fbmngplay fbtruetype splash /sbin/
4.把图片用splash程序写到ramdisk里,这样在启动的时候才能读到,因为这时候还没有加载分区呢。
建立目录/etc/bootsplash/themes,解压Theme-Linux.tar.bz2到这个目录下,现在的目录结构应该是:
/etc/bootsplash/themes/Linux
ln -s Linux current
再使用splash程序:
/sbin/splash -s -f /etc/bootsplash/themes/Linux/config/bootsplash-1024x768.cfg >> /boot/initrd.splash
这时候,就需要修改刚才的menu.lst文件了,改成:
title LFS Boot Splash
root (hd0,6)
kernel /boot/lfs-bootsplash root=/dev/hda7 ro vga=791 splash=silent
initrd /boot/initrd.splash
现在重启,就能看到可爱的小企鹅了,按F2,会变成verbose模式。
5.加个进度条。
这一步需要修改启动脚本。打开文件/etc/rc.d/init.d,在最后加入:
progressbar() { if [ $# != 1 ] then echo "Usage: progressbar {progress}" exit 1 fi echo "show $(( 65534 * $1 / 100 ))" > /proc/splash }
我一般是用运行级3的,这时的启动过程,需要经过rcsysinit.d和rc3.d两个目录。
我的这两个目录下面的链接是这样:
[root:/etc/rc.d/rc3.d]# ls /etc/rc.d/rcsysinit.d/
S10swap S30checkfs S50cleanfs S70loadkeys
S20mountproc S40mountfs S60setclock S80localnet
[root:/etc/rc.d/rc3.d]# ls /etc/rc.d/rc3.d/
S10sysklogd S25random S40alsa
现在就需要根据个人的情况,编辑相应的启动脚本。别忘了,所有的启动脚本都在/etc/rc.d/init.d下面。按照我的情况,需要编辑的脚本是:
checkfs mountfs cleanfs setclock loadkeys localnet
sysklogd random 和 alsa.
为什么不编辑前两个脚本swap和mountproc呢?这是因为,progressbar函数里用到了/proc/splash,而在mountproc之前,这个文件是不存在的。一共是10个脚本,在每个脚本的loadproc那一句(有些脚本没有loadproc的,这就需要根据情况来看了,反正都是在start参数后面,而在evaluate_retval前面的)前面,加上:
progressbar XXX
这个XXX是小于100的数字,也就是表示启动时进度条的百分比。要说明的是,这个数字按照启动顺序,只能增大,要不然,进度条就会反着走了。启动顺序就是我上面列出的从小到大,从rcsysinit.d到rc3.d。
举个例子,第一个要编辑的是S30checkfs,就进入/etc/rc.d/init.d目录,打开checkfs脚本,这个脚本不仅没有loadproc,而且连start参数也没有,但没关系,我们找到evaluate_retval,它前面的一句就是真正执行的语句,如下:
echo "Mounting root file system in read-only mode..."
mount -n -o remount,ro /
evaluate_retval
我把它改成:
echo "Mounting root file system in read-only mode..."
progressbar 10
mount -n -o remount,ro /
evaluate_retval
其他的也差不多。由于执行各个脚本的时间不太清楚,所以需要经过仔细调整,才能让进度条走得均匀。不过这个问题倒是不大,只要能从0走到100就差不多了吧:)
现在重启,就能看到进度条了。不过我做完了以后,发现意思不大,因为在checkfs之前,进度条不走,而开始走了以后,很快就到100%啦,呵呵,可能服务装多了以后,效果更明显吧。
6.动画效果
在前面的bootsplash-3.0.7.tar.bz2解压后,里面有个Scripts目录,这里提供了bootanim和splash.sh两个脚本,但它都是用于suse的,对于LFS不太适用,因此我做了两个脚本:
bootanim.sh:
#!/bin/bash # # splash.sh - This shell script triggers bootsplash actions during # system boot/shutdown. It can be run by the init scripts repeatedly # specifying the currently executed system script. # # This script is used to play animations/sounds/show text/move the # progress bar, etc. # # We call this function from /etc/rc.status:rc_splash() # # This program is free software; you may redistribute it under # the terms of the GNU General Public License. This program has # absolutely no warranty. # # written 2002-2003 Stefan Reinauer, <[email protected]> # # this script expects the following environment variables for an # operable # progress bar: # # sscripts = number of start scripts to be executed for runlevel change # kscripts = number of stop scripts to be executed for runlevel change # progress = number of currently executed start/stop script # RUNLEVEL = runlevel to be reached. # # To play animations, it's advised that you have an animations.cfg in # your # theme's config directory specifying the initscript name for an event # and # the command to be executed: # # fsck start:bootanim start bounce.mng # master:bootanim stop # # See http://www.bootsplash.org/ for more information. # _procsplash="`cat /proc/splash 2>/dev/null`" THEME="current" #test -f /etc/sysconfig/bootsplash && . /etc/sysconfig/bootsplash test ! -d "/etc/bootsplash/themes/$THEME" && exit 0 # parse animations.cfg. This part should not be handled by the # splash binary. function box() { true; } # ignore box descriptions in the config file test -f "/etc/bootsplash/themes/$THEME/config/bootsplash-`fbresolution`.cfg" && \ . /etc/bootsplash/themes/$THEME/config/bootsplash-`fbresolution`.cfg if [ -f /etc/bootsplash/themes/$THEME/config/animations.cfg ]; then COMMAND="`cat /etc/bootsplash/themes/$THEME/config/animations.cfg | grep "^$1"|cut -f2 -d\:`" eval $COMMAND fi
#!/bin/bash # # bootanim - boot animation wrapper script for fbmngplay # # This script parses /usr/share/splash/current/config/bootsplash-XxY.cfg # to determine the correct animation position. # # (C) 2002 SuSE AG. Written by Stefan Reinauer <[email protected]> # # modified by Michael Aichler <micha at aichler dot net> # usage() { echo "Usage: `basename $0` COMMAND [OPTIONS] mng1 [mng2 ...]" cat << EOF Available commands: start starts given animation stop fades out all running animations kill immediately stops all animations next kills current and starts next animation. Options for use with start command: EOF echo -e "`fbmngplay -h 2>&1 | grep -v \"usage:\" | grep \"-\"`\n" } if [ ! -x /sbin/splash ]; then echo "`basename $0`: can't find splash utility" exit 1 fi DIRECTORY=/etc/bootsplash/themes/current/animations OPTIONS="" FILES="" buffer="" console="" case "$1" in start) # We fall through here. ;; stop) killall -q -2 fbmngplay exit 0 ;; kill) killall -q fbmngplay exit 0 ;; next) killall -q -USR1 fbmngplay exit 0 ;; *) echo "`basename $0`: illegal parameter." usage exit 1 ;; esac shift # We end up in bootanim start for arg in $*; do if [ "${arg#*.}" == "mng" ]; then FILES="$FILES $arg" else test "$arg" == "-b" && buffer="true" test "$arg" == "-c" && console="true" OPTIONS="$OPTIONS $arg" fi done test -f "/etc/bootsplash/themes/current/config/bootsplash-`fbresolution`.cfg" && \ . /etc/bootsplash/themes/current/config/bootsplash-`fbresolution`.cfg test -z "$buffer" && OPTIONS="$OPTIONS -b" test -z "$console" && OPTIONS="$OPTIONS -c 1" echo $ax OPTIONS="$OPTIONS -x $ax -y $ay" CMDLINE="fbmngplay $OPTIONS" for file in $FILES; do CMDLINE="$CMDLINE ${DIRECTORY}/${file}" done eval "$CMDLINE &"
chmod 755 bootanim.sh bootanim &&
cp bootanim.sh bootanim /sbin
这两个脚本以及前面安装的fbmngplay程序是用来处理动画效果的。不过,动画效果还需要主题的支持。我前面下载的主题Linux,不支持动画效果。关于主题所支持的功能,参见:
http://bootsplash.org/themes.html
我下载了一个Redmond的主题,它能支持动画。
ftp://ftp.suse.com/pub/people/stepan...edmond.tar.bz2
与前面的做法一样,还是解压到/etc/bootsplash/themes目录下,并删除老的current链接,新建一个:
rm current
ln -s Redmond current
由于主题换了,自然就需要重新写initrd文件了:
/sbin/splash -s -f /etc/bootsplash/themes/current/config/bootsplash-1024x768.cfg >> /boot/initrd.splash
为了使用动画,还要在/etc/rc.d/init.d/functions里增加新的函数。
animate() { if [ $# = 0 ] then echo "Usage: animate {hook}" exit 1 fi /sbin/bootanim.sh "$*" }
animate HOOK
这个HOOK的值,要到/etc/bootsplash/themes/current/config/animations.cfg文件里找。
对于Redmond这个主题,这个文件的内容是:
fsck start:bootanim start bounce.mng
master:bootanim stop
shutdown: bootanim start bounce.mng
这里的格式是:
HOOK:command
冒号前面的,是需要增加到启动脚本里的内容,而后面的,是真正执行的命令。
我修改了三个脚本,第一个是checkfs(动画开始),第二个是alsa(动画结束),第三个是/etc/rc.d/rc6.d里面的第一个alsa(显示关机画面).
例:
checkfs脚本,修改后相关内容如下:
echo "Mounting root file system in read-only mode..."
progressbar 10
mount -n -o remount,ro /
animate fsck start
evaluate_retval
alsa脚本要修改两个地方,开机动画结束,应该在start参数里,而关机画面,则是在stop参数里。
如下:
start) echo "Starting ALSA... Restoring volumes..." progressbar 100 animate master loadproc /usr/sbin/alsactl restore #echo " Loading MIDI font..." #loadproc sfxload /path/to/soundfont ;; stop) echo "Stopping ALSA... Saving volumes......" animate shutdown loadproc /usr/sbin/alsactl store #echo " Removing MIDI font.........." #loadproc sfxload -i
7.关机画面。
在你关机执行的第一个脚本里加入
echo "silent" > /proc/splash
还没忘记吧,要在/etc/rc.d/rc6.d里面找以K打头,数字最小的链接。我的机子上是alsa
,改了以后,stop参数是:
stop) echo "Stopping ALSA... Saving volumes......" echo "silent" >> /proc/splash animate shutdown loadproc /usr/sbin/alsactl store #echo " Removing MIDI font.........." #loadproc sfxload -i ;;
同样,在关机的时候也可以显示进度条,只要按照上面所说的,在/etc/rc.d/rc6.d下的脚本里添加progressbar 1-100 就行了,注意要加到stop参数里。
8.不同控制台用不同的背景图片。
splash -n -s -u 1 \
/etc/bootsplash/themes/{任何主题}/config/bootsplash-1024x768.cfg
那个1表示第2个终端。为了一启动就每个控制台控制台都有背景,可以把这些语句加到你的启动脚本里。我是加到alsa脚本里了。如下:
start) echo "Starting ALSA... Restoring volumes..." progressbar 100 animate master splash -n -s -u 1 \ /etc/bootsplash/themes/Linux/config/bootsplash-1024x768.cfg splash -n -s -u 2 \ /etc/bootsplash/themes/SuSE-8.2/config/bootsplash-1024x768.cfg splash -n -s -u 3 \ /etc/bootsplash/themes/SuSE-8.2/config/bootsplash-1024x768.cfg loadproc /usr/sbin/alsactl restore #echo " Loading MIDI font..." #loadproc sfxload /path/to/soundfont ;;
splash -n -s -u 1
注意,有的主题是不能做背景的,比如Redmond,因为它只有silent模式,而normal模式的图片是全黑的,做背景的话,和正常的没什么区别,看不到图。但Linux主题是支持做背景的。
9.使用其他分辨率。
主要是主题要支持,我看下来,还是1024x768支持最好,不过方法都是一样的啦。下面给一个表,是vga模式与分辨率和色深的关系:
Colors-----640x480-----800x600-----1024x768-----1280x1024
256----------769---------771----------773----------775
32000--------784---------787----------790----------793
65000--------785---------788----------791----------794
16.7 Mill.---786---------789----------792----------795
我用的vga是791(没忘吧?在grub的menu.lst里面),也就是1024x768,65000种颜色。
10.定做自己的主题
bootsplash作为背景,应该是比较顺利的,做进度条稍麻烦,需要手工调整时间,做动画最麻烦,因为没有通用的脚本支持。我上面的脚本只是能在Redmond主题下使用,效果还不错,其他版本的主题,就不知道如何了。为什么没有一个既好看,又能支持所有特性的主题呢?最后我选择用Linux作为主题,因为不想让LFS背着个SuSE的名字。为了让Linux主题支持动画,我把Redmond下面的animation目录和config/animations文件拷贝到了Linux主题下,并且修改Linux主题下的config/bootsplash-1024x768.cfg文件,增加两个动画所需要的变量。ax和ay是动画显示的位置,我添加如下:
ax=420
ay=100
11.支持TrueType字体
可以在启动过程中显示TrueType字体,定制消息:)
首先要修改主题。Linux主题不支持TrueType字体。在/etc/bootsplash/themes/Linux/config/bootsplash-1024x768.cfg中添加:
# ttf message output parameters
text_x=204
text_y=544
text_size=36
text_color=0xeef4ff
这样就行了。
建立文件/sbin/bootttf:
#!/bin/bash -x # # bootanim - boot animation wrapper script for fbmngplay # # This script parses /usr/share/splash/current/config/bootsplash-XxY.cfg # to determine the correct animation position. # # (C) 2002 SuSE AG. Written by Stefan Reinauer <[email protected]> # # modified by Michael Aichler <micha at aichler dot net> # function box() { true; } # ignore box descriptions in the config file test -f "/etc/bootsplash/themes/current/config/bootsplash-`fbresolution`.cfg" && \ . /etc/bootsplash/themes/current/config/bootsplash-`fbresolution`.cfg STRING="What are you going to do?" case "$1" in start) STRING="Booting LFS...Press F2 for verbose mode" ;; shutdown) STRING="Shutting down...Press F2 if you want to" ;; *) ;; esac if [ "$text_x" != "" -a "$text_y" != "" \ -a "$text_color" != "" -a "$text_size" != "" ]; then fbtruetype -x $text_x -y $text_y -t $text_color -s $text_size \ "$_boot $STRING" fi
chmod 755 /sbin/bootttf
然后是在启动脚本里调用。我只用了两个消息,呵呵。在checkfs中:
/sbin/bootttf start
animate fsck start
echo "Checking file systems..."
#Note: -a option used to be -p; but this fails e.g. on fsck.minix
fsck $options -a -A -C -T
error_value=$?
animate fsck stop
第一行就是调用啦。在alsa中,显示关机消息:
stop) echo "Stopping ALSA... Saving volumes......" echo "silent" >> /proc/splash /sbin/bootttf shutdown progressbar 1 animate shutdown loadproc /usr/sbin/alsactl store #echo " Removing MIDI font.........." #loadproc sfxload -i ;;
更进一步的主题定制,需要阅读bootsplash.org上的文档。
参考:
http://bootsplash.org/index.html
bootsplash的官方网站。上面可以找到自定义主题的内容,以及其他版本内核的补丁。
http://www.linuxfromscratch.org/hint...bootsplash.txt
如果需要编译静态的fbmngplay,以便在没有加载/usr分区时使用,可以参考这里。
http://forums.gentoo.org/viewtopic.php?t=49036
作者: tram 发布时间: 2004-01-05
好文:)
对于启动脚本又多了一些了解,谢谢:)
作者: inness 发布时间: 2004-01-05
用bootsplash关键字搜索论坛,你会看到更多。
作者: kj501 发布时间: 2004-01-05
作者: i659 发布时间: 2004-01-06
作者: tram 发布时间: 2004-01-06
作者: i659 发布时间: 2004-01-06
fbmngplay是读mng文件,放动画。
fbtruetype是显示truetype字体。
fbresolution是检查分辨率。
splash程序是在framebuffer上显示图片。
其他的脚本,只是以不同参数来读取配置文件,调用所需程序。
作者: tram 发布时间: 2004-01-06
作者: dancefans 发布时间: 2004-01-06



不管怎么说,先谢了(收了以后再看吧!)
作者: hyoga 发布时间: 2004-01-06
title LFS Boot Splash
root (hd0,6)
kernel /boot/lfs-bootsplash root=/dev/hda7 ro vga=791 splash=silent
initrd /boot/initrd.splash
作者: xxx 发布时间: 2004-01-07
作者: tram 发布时间: 2004-01-07
是怎么启动的
kernel /boot/lfs-bootsplash root=/dev/hda7 ro vga=791 是什么意思
splash=silent是什么意思
initrd /boot/initrd.splash是什么意思
作者: xxx 发布时间: 2004-01-07
作者: dancefans 发布时间: 2004-01-07
最初由 xxx 发表 root (hd0,6) 是怎么启动的 kernel /boot/lfs-bootsplash root=/dev/hda7 ro vga=791 是什么意思 splash=silent是什么意思 initrd /boot/initrd.splash是什么意思 |
作者: tram 发布时间: 2004-01-07
最初由 dancefans 发表 2.6.0还要不要给bootsplash打相应的补丁? |
作者: tram 发布时间: 2004-01-07
作者: i659 发布时间: 2004-01-07
作者: tram 发布时间: 2004-01-08
作者: i659 发布时间: 2004-01-09
作者: tram 发布时间: 2004-01-10
作者: hyoga 发布时间: 2004-01-10
作者: tram 发布时间: 2004-01-10
作者: tram 发布时间: 2004-01-10
头大了三圈
作者: Parakeet 发布时间: 2004-01-15
咱们是不认rpm那套的。
作者: tram 发布时间: 2004-01-16
最初由 tram 发表 呵呵,are you joking? 咱们是不认rpm那套的。 |
巨费时间!


作者: hyoga 发布时间: 2004-01-17
作者: elmar 发布时间: 2004-02-22
谢谢
作者: 6692975 发布时间: 2004-12-12
作者: 6692975 发布时间: 2004-12-13
找不到补丁应该怎么办?请各位前辈给个意见!谢谢
作者: jinsaiuser 发布时间: 2008-06-25
这么老的帖子也翻出来了,没看到bootsplash.org主页上推介使用Splashy了么。
作者: zlbruce 发布时间: 2008-06-26
又要同时打开图片,怎么弄啊~!
grub中:
initrd /initd.splash这样可以启动图片
但是我同时还要启动
initrd /initd.img文件
这样不矛盾~!
因为initrd.img这文件是我自己做的,里面需要处理一些事情,所以必须要initd.img文件
但是我启动时又要开启图片,initrd.splash???
这怎么处理啊?
作者: prettydream 发布时间: 2009-02-10
安息吧。。。
作者: yarx 发布时间: 2009-06-12
编译bootsplash/Utitl...
make 失败,,全是ttf惹得祸,哪位大仙可帮忙解决下,不胜感激哦!
作者: bingdian304 发布时间: 2009-06-25
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28