現時 Fedora Core 所用的圖形介面登入名為 RedHat Graphical Boot (簡稱為 rhgb),圖形介面在啟動系統中段才出現。如果見過 Mandrake 或 SuSE 的朋友,會知道他們的圖形介面啟動是完全的覆蓋整過啟動過種,十分美觀耀目。這種技術是 SuSE 所開發再傳出來,現在可在網站 上找到有關技術的源碼和使用手冊。不過並沒有支援 Red Hat 或 Fedora 的資料。近日在網上找到一則由日本人寫出的 RedHat 修改文章,跟據原文在此寫出技術要點。
範例選用的是 RedHat 9,而使用了核心 2.4.23,有關的核心修補檔案需要在 上下載,核心源碼當然在 那處下載了。
2.4.23 Kernel Source : |
|
bootsplash :
| |
|
Theme-Linux.tar.bz2(Default Linux) |
下載回來的核心源碼需要的修補,步驟如下:
將核心源碼放置在 /usr/src 目錄之內,並將之解壓:
# cd /usr/src
# tar jxvf linux-2.4.23.tar.bz2
將 bootsplash-3.0.7-2.4.23.diff.bz2 放置在 /usr/src 目錄之內,並將之解壓:
# bzip2 -d bootsplash-3.0.7-2.4.23.diff.bz2
進入核心源碼目錄進行修補:
# cd linux-2.4.23
# patch -p1 < .. /bootsplash-3.0.7-2.4.23..diff
清除核心可能存在舊的設定:
# make mrproper
使用 make menuconfig 來設定核心支援 bootsplash 如下圖:
Console drivers --->
[*] VGA text console
[*] Video mode selection support
Frame-buffer support --->
[*] Support for frame buffer devices
[*] VESA VGA graphics console
[*] Use splash screen instead of boot logo
|
完成設定之後,儲存及離開介面進行編譯。
# make dep
# make bzImage
# cp arch/i386/boot/bzImage /boot/vmlinuz-2.4.23
# make modules
# make modules_install
# cp System.map /boot/System.map-2.4.23
# mkinitrd -f /boot/initrd-2.4.23.img 2.4.23
修改 /etc/lilo.cong 加入 vga=788 (800x600) 或 vga=791 (1024x768) 使啟動時支援顯示彩色。另外 splash=silent 是令到 Bootsplash 不顯示啟動時的系統訊息。
default=1
timeout=10
splashimage=(hd0,6)/grub/splash.xpm.gz
title Windows 98/XP
rootnoverify (hd0,0)
chainloader +1
title Red Hat Linux (2.4.23)
root (hd0,6)
kernel /vmlinuz-2.4.23 ro root=LABEL=/ vga=791 splash=silent
initrd /initrd-2.4.23.img
完成切勿忙重灌 LILO # lilo -v
之後將 bootsplash 的軟件及佈景主題安裝入系統之內。
# tar jxvf /patch/bootsplash-3.0.7.tar.bz2
# tar jxvf /patch/Theme-Linux.tar.bz2
# cd bootsplash-3.0.7/Utilities
# make all
# cp fbmngplay fbresolution fbtruetype splash /sbin
# cd ../../
# mkdir /etc/bootsplash
# mkdir /etc/bootsplash/themes
# cp -a Linux /etc/bootsplash/themes
|
跟著使用將圖片灌入 init Ram Disk 之內.,再將啟動的腳本放入 /etc/rc.d 目錄之內。下面是作者修改過的 splash.sh。
# splash -s -f /etc/bootsplash/themes/Linux/config/bootsplash-1024x768.cfg >> /boot/initrd-2.4.23.img
# cp bootsplash-3.0.7/Scripts/splash.sh /etc/rc.d
|
#!/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,
#
# 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:/// for more information.
#
_procsplash="`cat /proc/splash 2>/dev/null`"
############################### BootSplash Start ###############################
THEME="Linux"
############################### BootSplash End ###############################
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.
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
# assertions
test -r /proc/splash || exit 0
############################### BootSplash Start ###############################
#test -z "$progress" -a -z "$num" && exit 0
############################### BootSplash End ###############################
test -z "`echo $_procsplash|grep on`" && exit 0
test "$1" == "bootnetwork stop" -o "$1" == "YaST" && exit 0 # no progress
# We chose verbose in grub
test "`cat /proc/cmdline |grep "splash=silent"`" == "" && exit 0
if [ "$PREVLEVEL" == "3" -o "$PREVLEVEL" == "5" ] ; then
if [ "$RUNLEVEL" = "3" -o "$RUNLEVEL" == "5" ] ; then
exit 0
fi
fi
# acquire data
#
############################### BootSplash Start ###############################
#num=$(( $sscripts + 2 ))
num=$sscripts
############################### BootSplash End ###############################
_shutdown="no"
_silent="no"
test "`cat /proc/splash |grep silent`" && _silent="yes"
test "$RUNLEVEL" == "6" -o "$RUNLEVEL" == "0" && _shutdown="yes"
############################### BootSplash Start ###############################
#test "$_shutdown" == "yes" && num=$(( $kscripts + 2 ))
test "$_shutdown" == "yes" && num=$kscripts
test -z "$progress" -a -z "$num" && exit 0
############################### BootSplash End ###############################
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
#
# Print text string. (Booting/Shutting down the system. Press
# F2 for verbose mode)
#
if [ "$progress" == 1 -o "$1" == "splash start" ]; then
############################### BootSplash Start ###############################
# test "$_shutdown" == "yes" && ( echo "silent" >/proc/splash; chvt 1 )
test "$_shutdown" == "yes" && (
/sbin/splash -s /etc/bootsplash/themes/$THEME/config/bootsplash-`fbresolution`.cfg ;
echo "silent" >/proc/splash; chvt 1
)
############################### BootSplash End ###############################
_boot="Booting"; test "$_shutdown" == "yes" && _boot="Shutting down"
if [ "$text_x" != "" -a "$text_y" != ""
-a "$text_color" != "" -a "$text_size" != "" -a "$_silent" == "yes" ];
then
fbtruetype -x $text_x -y $text_y -t $text_color -s $text_size
"$_boot the system... Press F2 for verbose mode"
fi
fi
#
# Now paint the progressbar. This is done via the proc
# interface of the bootsplash.
#
test -z "$progress_enable" && exit 0
echo "show $(( 65534 * ( $progress + 1 ) / $num ))" > /proc/splash
|
最後的一個步驟是要令系統啟動時顯示進度,這個需要修改 /etc/rc.d/rc 這個檔案。
#! /bin/bash
#
# rc This file is responsible for starting/stopping
# services when the runlevel changes.
#
# Original Author:
# Miquel van Smoorenburg,
#
# check a file to be a correct runlevel script
check_runlevel ()
{
# Check if the file exists at all.
[ -x "$1" ] || return 1
# Reject backup files and files generated by rpm.
case "$1" in
*.rpmsave|*.rpmorig|*.rpmnew|*~|*.orig)
return 1
;;
esac
return 0
}
# Now find out what the current and what the previous runlevel are.
argv1="$1"
set `/sbin/runlevel`
runlevel=$2
previous=$1
export runlevel previous
. /etc/init.d/functions
############################### BootSplash Start ###############################
RUNLEVEL=$runlevel
PREVLEVEL=$previous
export progress=0
SSC=(/etc/rc.d/rc$runlevel.d/S*)
case "$SSC" in
**) sscripts=0 ;;
*) sscripts=${#SSC[*]}
esac
export sscripts
#if test "$PREVLEVEL" != "N" ; then
KSC=(/etc/rc.d/rc$runlevel.d/K*)
case "$KSC" in
**) kscripts=0 ;;
*) kscripts=${#KSC[*]}
esac
export kscripts
#fi
sscripts=$(( $sscripts + $kscripts ))
kscripts=$sscripts
############################### BootSplash End ###############################
# See if we want to be in user confirmation mode
if [ "$previous" = "N" ]; then
if [ -f /var/run/confirm ]
|| grep -i confirm /proc/cmdline >/dev/null ; then
rm -f /var/run/confirm
CONFIRM=yes
export CONFIRM
echo $"Entering interactive startup"
else
echo $"Entering non-interactive startup"
fi
fi
# Get first argument. Set new runlevel to this argument.
[ -n "$argv1" ] && runlevel="$argv1"
# Is there an rc directory for this new runlevel?
[ -d /etc/rc$runlevel.d ] || exit 0
# First, run the KILL scripts.
for i in /etc/rc$runlevel.d/K* ; do
############################### BootSplash Start ###############################
progress=$(( $progress + 1 ))
/etc/rc.d/splash.sh
############################### BootSplash End ###############################
check_runlevel "$i" || continue
# Check if the subsystem is already up.
subsys=${i#/etc/rc$runlevel.d/K??}
[ -f /var/lock/subsys/$subsys -o -f /var/lock/subsys/$subsys.init ]
|| continue
# Bring the subsystem down.
if egrep -q "(killproc |action )" $i ; then
$i stop
else
action $"Stopping $subsys: " $i stop
fi
done
# Now run the START scripts.
for i in /etc/rc$runlevel.d/S* ; do
############################### BootSplash Start ###############################
progress=$(( $progress + 1 ))
/etc/rc.d/splash.sh
############################### BootSplash End ###############################
check_runlevel "$i" || continue
# Check if the subsystem is already up.
subsys=${i#/etc/rc$runlevel.d/S??}
[ -f /var/lock/subsys/$subsys -o -f /var/lock/subsys/$subsys.init ]
&& continue
# If we're in confirmation mode, get user confirmation
if [ -n "$CONFIRM" ]; then
confirm $subsys
case $? in
0) :;;
2) CONFIRM=;;
*) continue;;
esac
fi
# Bring the subsystem up.
if [ "$subsys" = "halt" -o "$subsys" = "reboot" ]; then
export LC_ALL=C
exec $i start
fi
if egrep -q "(daemon |action |success |failure )" $i 2>/dev/null
|| [ "$subsys" = "single" -o "$subsys" = "local" ]; then
$i start
else
action $"Starting $subsys: " $i start
fi
done
|
後記:譯者可以成功的將上面的方法使用在 Fedora Core 1 之上。而在上面例子中的 Bootsplash Utilities 可能會編譯不了。那麼最快的方法是上網找個現成的套件來用。筆者用上了 Mandrake 9.2 的 bootsplash 套件。在安裝時會遇到沒法找到 Perl-abse 這個套件,其實在 Fedora 之來是有 Perl 的,只是名字不同,方法一是以不理會的方法處理 (rpm -ivh --nodeps)。另一個方法是使用 src.rpm 重新的編譯,在 spec 中註明正確的 perl 套件名稱。最也要記得在 /etc/sysconfig/bootspash 內的 bootsplash 參數改為 auto,最好同時將 theme 的名字加上。
日文原文