Slackware-Guides-Graphical Boot

From LQWiki
Jump to: navigation, search

Slackware-Guides-Graphical_Boot

Original LQ post can be found here. All credit goes to LQ member Keith Hedger. This guide was adapted for wiki format from his LQ post.

This guide will asist in helping Slackers enable the graphical boot capabilities of BusyBox. BusyBox is what Slackware uses with it's custom mkinitrd scripts to make an initrd image for booting the generic kernel and any special setups like LUKS/LVM partitions.

It is very IMPORTANT to make backups of everything involved and to know how to recover your system with a live cd or the Slackware install cd. We will be making some small but important changes to some system scripts, if you get it wrong you may find that your system is unbootable. If you do not know how to recover from an unbootable system or you do not know how to make an initrd image, you should stop now.

This guide is a summary and assumes you already know how to edit the config file for your boot loader, make an initrd image, and edit scripts.


Setup the frame buffer

We need to have an appropriate frame buffer for the size of the boot image and the amount of colors we want to use. This is done by setting the 'vga' configure option for your boot loader. An example is "vga=773" or "vga=779". If you would like to see list of detected options for your system, you can set it to "vga=ask" and reboot.

For more reading on the subject:

  • usr/src/linux/Documentation/svga.txt
  • man lilo.conf

Obtain splash image

You can use any image you want as long as it's the correct size and color depth of your framebuffer settings and you convert it to ppm format. This can be done using Gimp or Imagemagic.

Testing your picture

To make sure your picture matches your framebuffer settings, you can reboot your computer and test it at the command prompt.

  • Switch to a virtual terminal outside of xorg. CTRL-ALT-F6
  • Run /boot/initrd-tree/bin/busybox fbsplash -s /path/to/splash_image.ppm

If busybox displays an image, you are good to proceed. If not, check your framebuffer settings and the image format.

Note: If busybox isn't available at the path specified, you can run "mkinitrd -c" to create a generic initrd image and the files it was created from.

Create the wrapper scripts

We need to create three new system scripts to have the boot process give the proper feedback to busybox. Don't forget to make them executable using chmod.

/etc/rc.d/rc.S-Wrap

#!/bin/sh

#rc.S-Wrap
#This is the wrapper for rc.S
#

if [ -f /etc/output.conf ];then
   . /etc/output.conf
else
#1st time so guess
   OUT_S=40
   OUT_M=40
fi

TOTAL=$((OUT_S+OUT_M))
MULTI=$(echo "scale=2; 100/$TOTAL" | bc -l)
COUNT=1

OUT_S_CHECK=0

#size of term
COLOUMNS=$(tput cols)
BOX=$(($(tput lines)-3))
TEXTLINE=$(($(tput lines)-2))


#log output
S_LOG="Starting rc.S\n"

STARTUP=/etc/rc.d/rc.S

#no kerenel messages
setterm -msg off -cursor off -foreground green
tput clear

/boot/initrd-tree/bin/busybox fbsplash -i /boot/GSplash/fb.config -f /boot/GSplash/fbfifo -s /boot/GSplash/startup.ppm &

"$STARTUP" &> /boot/GSplash/fifo &

while read DATA
   do
      OUT_S_CHECK=$((OUT_S_CHECK+1))
      #count number of echos for next time round
      echo "$COUNT\n" > /boot/GSplash/fbfifo
      COUNT=$(echo "scale=2; $COUNT+$MULTI" | bc -l)
      S_LOG=$(echo "${S_LOG}\n${DATA}")

      if [ ${#DATA} -lt $COLOUMNS ];then
         XPOS=$((COLOUMNS/2-${#DATA}/2))
      else
         XPOS=0
         DATA=${DATA:0:$COLOUMNS};
      fi
      tput cup $BOX 0
      setterm -clear rest
      tput cup $TEXTLINE $XPOS
      echo -en "$DATA"
   done < /boot/GSplash/fifo

#number of echos has changed
if (( OUT_S != OUT_S_CHECK ));then
   echo "OUT_S=$OUT_S_CHECK" > /boot/GSplash/output.conf.temp
fi
echo -e "$S_LOG" > /tmp/S_LOG

/etc/rc.d/rc.M-Wrap

#!/bin/sh

#rc.M-Wrap
#This is the wrapper for rc.M
#


if [ -f /etc/output.conf ];then
   . /etc/output.conf
else
#1st time so guess
   OUT_S=40
   OUT_M=40
fi

TOTAL=$((OUT_S+OUT_M))
MULTI=$(echo "scale=2; 100/$TOTAL" | bc -l)
COUNT=$(echo "scale=2; ($OUT_S*$MULTI)" | bc -l)

OUT_M_CHECK=0

#size of term
COLOUMNS=$(tput cols)
BOX=$(($(tput lines)-3))
TEXTLINE=$(($(tput lines)-2))

#log output
S_LOG="Starting rc.M\n"

STARTUP=/etc/rc.d/rc.M

( "$STARTUP";echo "EOFEOF" ) &> /boot/GSplash/fifo &

while read DATA
      do
      S_LOG=$(echo "${S_LOG}\n${DATA}")
      #we need this because rc.local don't exit ??
      if [ "X$DATA" != "XEOFEOF" ];then
         OUT_M_CHECK=$((OUT_M_CHECK+1))
         #count number of echos for next time round
         echo "$COUNT\n" > /boot/GSplash/fbfifo
         COUNT=$(echo "scale=2; $COUNT+$MULTI" | bc -l)
         #make it touch the end ( i'm anal that way )
         if [ $(echo "scale=2; $COUNT > 100 " | bc -l) = 1 ];then
            COUNT=100
         fi

         if (( ${#DATA} < COLOUMNS ));then
            XPOS=$((COLOUMNS/2-${#DATA}/2))
         else
            XPOS=0
            DATA=${DATA:0:$COLOUMNS}
         fi

         tput cup $BOX 0
         setterm -clear rest
         tput cup $TEXTLINE $XPOS
         echo -en "$DATA" 
      else
         break;
      fi
   done < /boot/GSplash/fifo

if [ -f /boot/GSplash/output.conf.temp ];then
   #count changed
   mv /boot/GSplash/output.conf.temp /etc/output.conf
   echo "OUT_M=$OUT_M_CHECK" >> /etc/output.conf

elif (( OUT_M != OUT_M_CHECK ));then
   echo "OUT_S=$OUT_S" > /etc/output.conf
   echo "OUT_M=$OUT_M_CHECK" >> /etc/output.conf
fi

#log it and tdy up
echo -e "$S_LOG" >> /tmp/S_LOG
echo "exit\n" > /boot/GSplash/fbfifo
clear
setterm -default

exit 0

/etc/rc.d/rc.6-Wrap

#!/bin/sh

#rc.6-Wrap
#This is the wrapper for rc.6
#

# stop the GPM mouse server so it doesnt interfere with our pic
if [ -x /etc/rc.d/rc.gpm ]; then 
	/etc/rc.d/rc.gpm stop &> /dev/null
fi

if [ -f /etc/outputsd.conf ];then
	. /etc/outputsd.conf
else
#1st time so guess
	OUT_6=400
fi

TOTAL=$OUT_6
MULTI=$(echo "scale=2; 100/$TOTAL" | bc -l)
COUNT=100

OUT_6_CHECK=0

#size of term
COLOUMNS=$(tput cols)
BOX=$(($(tput lines)-3))
TEXTLINE=$(($(tput lines)-2))

#scurrilously robbed from rc.6 ;)
# Find out how we were called.
case "$0" in
	*0-Wrap)
		STARTUP=/etc/rc.d/rc.0
		;;
	*6-Wrap)
		STARTUP=/etc/rc.d/rc.6
		;;
	*)
		echo "$0: call me as \"rc.0\" or \"rc.6\" please!"
		exit 1
		;;
esac

#no kerenel messages
setterm -msg off -cursor off -foreground green
tput clear

/boot/initrd-tree/bin/busybox fbsplash -i /boot/GSplash/fbsd.config -f /boot/GSplash/fbfifo -s /boot/GSplash/shutdown.ppm &

"$STARTUP" &> /boot/GSplash/fifo &

while read DATA
	do
		OUT_6_CHECK=$((OUT_6_CHECK+1))
		if [ "X$DATA" = "XUnmounting local file systems." ];then
		#number of echos has changed
			if (( OUT_6 != OUT_6_CHECK ));then
				OUT_6_CHECK=$((OUT_6_CHECK+1))
				echo "OUT_6=$OUT_6_CHECK" > /etc/outputsd.conf
			fi
		fi
		#count number of echos for next time round
		echo "$COUNT\n" > /boot/GSplash/fbfifo
		COUNT=$(echo "scale=2; $COUNT-$MULTI" | bc -l)

		if [ ${#DATA} -lt $COLOUMNS ];then
			XPOS=$((COLOUMNS/2-${#DATA}/2))
		else
			XPOS=0
			DATA=${DATA:0:$COLOUMNS};
		fi
		tput cup $BOX 0
		setterm -clear rest
		tput cup $TEXTLINE $XPOS
		echo -en "$DATA"

	done < /boot/GSplash/fifo

Edit /etc/inittab

We need to change /etc/inittab to use our wrapper scripts in place of rc.S and rc.M. Remember what was said about making backups?

  • Change "si:S:sysinit:/etc/rc.d/rc.S" -- to --> "si:S:sysinit:/etc/rc.d/rc.S-Wrap"
  • Change "rc:2345:wait:/etc/rc.d/rc.M" -- to --> "rc:2345:wait:/etc/rc.d/rc.M-Wrap"
  • Change "l0:0:wait:/etc/rc.d/rc.0" -- to --> "l0:0:wait:/etc/rc.d/rc.0-Wrap"
  • Change "l6:6:wait:/etc/rc.d/rc.6" -- to --> "l6:6:wait:/etc/rc.d/rc.6-Wrap"
  • Make a symlink from rc.0-Wrap > rc.6-Wrap like so:
ln -sf /etc/rc.d/rc.6-Wrap /etc/rc.d/rc.0-Wrap

Copy/Create Configuration Files

We need to create the configuration file, the fifo buffer files and copy our splash screen to the location our wrapper scripts expect them to be.

  • mkdir /boot/GSplash
  • mkfifo /boot/GSplash/fbfifo
  • mkfifo /boot/GSplash/fifo
  • cp /path/to/startup_splash_image.ppm /boot/GSplash/startup.ppm
  • cp /path/to/shutdown_splash_image.ppm /boot/GSplash/shutdown.ppm

You can if you want the same shutdown and startup picture just symlink them together

  • vim /boot/GSplash/fb.config ( the config file to place the start up progress bar )
BAR_LEFT=312
BAR_TOP=550
BAR_WIDTH=400
BAR_HEIGHT=11
BAR_R=64
BAR_G=64
BAR_B=64
  • vim /boot/GSplash/fbsd.config ( the config file to place the shut down progress bar )
BAR_LEFT=312
BAR_TOP=704
BAR_WIDTH=400
BAR_HEIGHT=11
BAR_R=64
BAR_G=64
BAR_B=64

These two config files are for illustration purposes only and you should change them to suit your own splash screens

Rerun lilo, Reboot and ( hopefully! ) you will now have a nice graphical boot!

Extra Notes

On the first boot, the progress bar will not acuratly represent the progress of the system boot. This is because the progress bar is dependent on a saved value of the total number of lines echoed to your screen during a normal text boot. When you modify the number of things that launch at start up, the scripts will update this value again.

The scripts create a log file at /tmp/S_LOG in case you want to examine the details of the boot up. If you don't want a log file, just comment out the appropriate lines in rc.S-Wrap and rc.M-Wrap.

What you can customize:

  • The startup splash pic, just create a new one at /boot/GSplash/startup.ppm making sure that the size and type is set correctly.
  • The shutdown splash pic, just create a new one at /boot/GSplash/shutdown.ppm making sure that the size and type is set correctly.
  • The size, shape and background colour of the progress bar as defined in /boot/GSplash/fb.config
  • The text colour can be changed at line 33 of /etc/rc.d/rc.S-Wrap, see the setterm man page for details.