Bootsplash (old)

From SlackWiki
Revision as of 13:34, 6 October 2009 by Fuli (talk | contribs) (moved Bootsplash (new) to Bootsplash (old): It had to be done some changes in the adding the splash to the initrd.gz section.)
Jump to navigation Jump to search


Prerequisites

  • kernel source
  • a bootsplash patch for your kernel version [1] bootsplash patch.
  • A bootsplash theme kde-look themes
  • Bootsplash utilites download

Setup

Start by patching and building a new kernel.

Assuming Stock kernel configuration/source. And all your downloads are in /home/username/Downloads.

  cd /usr/src/linux
       patch -p1</home/username/Downloads/bootsplash*.diff
       rm .config
       zcat /proc/config.gz > .config
       make menuconfig
  *Note: If you insist on using the generic kernel. And are currently using it.
       Check to see if the .config in your /usr/src/linux directory matches /proc/config.gz
          zdiff /proc/config.gz /usr/src/linux/.config 
       If they match, skip the "rm .config && zcat ..." part above
       You'll also want to converge your initrd.gz and bootsplash's initrd. More on that below.

Edit these 2 options:

   Device Drivers --->
            Graphics support --->
                 Logo configuration --->
                     [ ] Bootup logo
                 Bootsplash configuration --->
                     [*] Bootup splash screen
  • If you aren't using a stock kernel configuration, or on another distro check these settings whileyou are still in the kernel configuration dialog:
   Device Drivers --->
            Block devices --->
                   <*> RAM disk support
            Graphics support --->
                   <*> Support for frame buffer devices

Now to make the patched kernel and install it

  make ; cp /usr/src/linux/arch/i386/boot/bzImage /boot/vmlinuz-bootsplash

For slamd64, thats:

  make ; cp /usr/src/linux/arch/x86_64/boot/bzImage /boot/vmlinuz-bootsplash

On to making a new bootsplash initrd. Compile and install the splash utility.

  cd /home/username/Downloads
       tar xf bootsplash-3.0.7.tar.bz2
       cd bootsplash-3.0.7/Utilities/
       make splash
       cp splash /usr/bin/ 

And use it to build your new initrd. Untar the theme file you downloaded, and check to see if it has a config directory and an image/s directory. Look in the config directory for an appropriately sized config file (usually bootsplash-1024x768.cfg). Edit this file, changing the directory it looks for images in (jpeg= option and silentjpeg= option) to point to the correct directory of the images for that theme. Example: /home/username/Downloads/bootsplashtheme/images/foo-bar.jpg Finish by making the initrd with splash:

  splash -s -f /home/username/Downloads/bootsplashtheme/config/bootsplash-1024x768.cfg >> /boot/initrd.splash 
   For generic kernel users, you'll have to converge your stock initrd.gz and the bootsplash initrds.
      mkinitrd
           cp /boot/initrd.splash /boot/initrd-tree/
      

After putting the initrd-splash into the mkinitrd's initrd-tree you'll need to run mkinitrd again with some computer specific options. Example:

     mkinitrd -c -m reiserfs

Remember to do this every time you make a new initrd.splash. Now edit /etc/lilo.conf with your favorite editor, adding the new kernel and bootsplash options. Sample:

  boot = /dev/hda
       message = /boot/boot_message.txt
       prompt
       timeout = 300
       change-rules
        reset
       vga = 791
       image = /boot/vmlinuz
         root = /dev/hda1
         label = Linux
         read-only
       image = /boot/vmlinuz-bootsplash
         root = /dev/hda1
         label = Bootsplash
         initrd=/boot/initrd.splash
         append="splash=silent" 

Substitue "initrd=/boot/initrd.gz" if you had to run mkinitrd for a generic kernel, then run lilo to update and you're set.

 root@slackware:~# lilo
      Added Linux
      Added Bootsplash 

Now you can Reboot to test everything. If boot fails for some reason. You still have your stock kernel and entry in lilo to boot into without worries.

Progressbar - rc.progress

Theres no set way to do this, you just need init to update /proc/splash correctly. The way I do it (with help from LinuxQuestiosn forums): create a new file in /etc/rc.d/ named rc.progress

  cd /etc/rc.d/ ; touch rc.progress 

edit it, and add this script:

  
#!/bin/sh
#
#rc.progress  This file has a common subroutine used to update a
#             bootsplash progress bar.
#

# Count the number of times the progress bar is likely to gbe increased
numu=$((`cat /etc/rc.d/rc.* | grep -c "^progressup"`));
numd=$((`cat /etc/rc.d/rc.* | grep -c "^progressdown"`));

function progressup(){
 progress=$((`cat /var/run/progressbar`));
 progress=$(($progress+1));
 echo $progress > /var/run/progressbar
 echo "show $(( 65523 * $progress / $numu ))" > /proc/splash
}

function progressdown(){
 progress=$((`cat /var/run/progressbar`));
 progress=$(($progress-1));
 echo $progress > /var/run/progressbar
 echo "show $(( 65523 * $progress / $numd ))" > /proc/splash
}


Now *CAREFULLY* edit /etc/rc.d/rc.S at the top add the line (a new line by itself) . /etc/rc.d/rc.progress The . tells your system to include the functionality described in /etc/rc.d/rc.progress. Now scroll through and add "progressup" (the defined trigger in rc.progress) on a new line at the end of every subroutine where you want the progressbar to incriment up. Example section of my rc.S:

  
#!/bin/sh
#
# /etc/rc.d/rc.S:  System initialization script.
#
# Mostly written by:  Patrick J. Volkerding, <volkerdi@slackware.com>
#
. /etc/rc.d/rc.progress
PATH=/sbin:/usr/sbin:/bin:/usr/bin

# Mount /proc right away: 
  

Don't add progressup till after your partition is mounted read/write it'll be at the end of a long segment of echo .. echo.. echo like this.

   echo -n "Press ENTER to continue. "
  read junk;
fi # Done checking root filesystem
progressup
  

Do the same for /etc/rc.d/rc.6 adding progressdown instead of progressup. After you've finished that, you need to delete your temporary progressbar output cache. Since rc.local is run last during startup, it's best to accomplish this here. Edit rc.local:

  
#!/bin/sh
#
# /etc/rc.d/rc.local:  Local system initialization script.
#
# Put any local startup commands in here.  Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.

rm -fr /var/run/progressbar 

Progressbar - rc.bootsplash

An alternate script can also be used if you should have problems implementing the rc.progress script. In my case the prior script was not able to delete its progressbar file, and adding progressdown entries to rc.6 resulted in odd behaviors even during bootup when rc.6 should not of been a factor. Create a new file in /etc/rc.d/ named rc.bootsplash

  cd /etc/rc.d/ ; touch rc.bootsplash 

edit it, and add this script:

 
#! /bin/sh
#
# /etc/rc.d/rc.bootsplash: bootsplash functions.
# This file does nothing if run, and is called by other rc.
# files in order to make the progress bar and animations works.

function progressbar()
{
        if [ $# != 1 ]
                then
                echo "Usage: progressbar {progress}"
                exit 1
        fi
        if [ -a /proc/splash ] ; then
                echo "show $(( 65534 * $1 / 100 ))" > /proc/splash
        fi
}
#
function animate()
{
        if [ $# = 0 ]
                then
                echo "Usage: animate {hook}"
                exit 1
        fi
        splash "$*"
}


Now *CAREFULLY* edit /etc/rc.d/rc.S at the top add the line (a new line by itself) . /etc/rc.d/rc.bootsplash Now scroll through and add "progressbar X" (where X is a number representing the percent to incriment to) on a new line at the end of every subroutine where you want the progressbar to incriment up. 0 is not a valid incriment. Only 1 - 100 are valid.

Example rc.S

 
# Scan for new volume groups:
  /sbin/vgscan --mknodes --ignorelockingfailure 2> /dev/null
  if [ $? = 0 ]; then
    # Make volume groups available to the kernel.
    # This should also make logical volumes available.
    /sbin/vgchange -ay --ignorelockingfailure
  fi
fi
progressbar 5

# Open any volumes created by cryptsetup:
if [ -f /etc/crypttab -a -x /sbin/cryptsetup.static ]; then
  # First, check for device-mapper support.
  if ! grep -wq device-mapper /proc/devices ; then
    # If device-mapper exists as a module, try to load it.
    # Try to load a device-mapper kernel module:
    /sbin/modprobe -q dm-mod
  fi
  cat /etc/crypttab | grep -v "^#" | grep -v "^$" | while read line; do
    LUKS=$(echo $line | tr '\t' ' ' | tr -s ' ' | cut -f1 -d' ')
    DEV=$(echo $line | tr '\t' ' ' | tr -s ' ' | cut -f2 -d' ')
    PASS=$(echo $line | tr '\t' ' ' | tr -s ' ' | cut -f3 -d' ')
    OPTS=$(echo $line | tr '\t' ' ' | tr -s ' ' | cut -f4 -d' ')
    LUKSOPTS=""
    if echo $OPTS | grep -wq ro ; then LUKSOPTS="${LUKSOPTS} --readonly" ; fi

    # NOTE: we only support LUKS formatted volumes (except for swap)!
    if /sbin/cryptsetup.static isLuks $DEV 2>/dev/null ; then
      echo "Unlocking LUKS crypt volume '${LUKS}' on device '$DEV':"
      if [ -n "${PASS}" ]; then
        if [ -f ${PASS} ]; then
          /sbin/cryptsetup.static ${LUKSOPTS} --key-file=${PASS} luksOpen $DEV $LUKS
        elif [ "${PASS}" != "none" ]; then
          echo "${PASS}" | /sbin/cryptsetup.static ${LUKSOPTS} luksOpen $DEV $LUKS
        fi
      else
        for i in seq 1 3 ; do
          /sbin/cryptsetup.static ${LUKSOPTS} luksOpen $DEV $LUKS </dev/tty0 >/dev/tty0 2>&1
          [ $? -eq 0 ] && break
        done
      fi
    elif echo $OPTS | grep -wq swap ; then
      # If any of the volumes is to be used as encrypted swap,
      # then encrypt it using a random key and run mkswap:
      echo "Creating encrypted swap on device '$DEV' mapped to '${LUKS}':"
      /sbin/cryptsetup.static --cipher=aes --key-file=/dev/urandom --key-size=256 create $LUKS $DEV
      mkswap /dev/mapper/$LUKS
    fi
  done
fi

# Enable swapping:
/sbin/swapon -a
progressbar 10

Continue adding "progressbar X" entries in both rc.S and rc.M

Do the same for rc.6 but instead incrimenting down 'X'.

Example rc.6

 
#! /bin/sh
#
# rc.6          This file is executed by init when it goes into runlevel
#               0 (halt) or runlevel 6 (reboot). It kills all processes,
#               unmounts file systems and then either halts or reboots.
#
# Version:      @(#)/etc/rc.d/rc.6      2.47 Sat Jan 13 13:37:26 PST 2001
#
# Author:       Miquel van Smoorenburg <miquels@drinkel.nl.mugnet.org>
# Modified by:  Patrick J. Volkerding, <volkerdi@slackware.com>
#
. /etc/rc.d/rc.bootsplash

# Set the path.
PATH=/sbin:/etc:/bin:/usr/bin
progressbar 100

# If there are SystemV init scripts for this runlevel, run them.
if [ -x /etc/rc.d/rc.sysvinit ]; then
  . /etc/rc.d/rc.sysvinit
fi
progressbar 90

# Set linefeed mode to avoid staircase effect.
/bin/stty onlcr

echo "Running shutdown script $0:"

# Find out how we were called.
case "$0" in
        *0)
                command="halt"
                ;;
        *6)
                command=reboot
                ;;
        *)
                echo "$0: call me as \"rc.0\" or \"rc.6\" please!"
                exit 1
                ;;
esac

# Save the system time to the hardware clock using hwclock --systohc.
if [ -x /sbin/hwclock ]; then
  # Check for a broken motherboard RTC clock (where ioports for rtc are
  # unknown) to prevent hwclock causing a hang:
  if ! grep -q -w rtc /proc/ioports ; then
    CLOCK_OPT="--directisa"
  fi
  if grep -q "^UTC" /etc/hardwareclock 2> /dev/null ; then
    echo "Saving system time to the hardware clock (UTC)."
    /sbin/hwclock $CLOCK_OPT --utc --systohc
  else
    echo "Saving system time to the hardware clock (localtime)."
    /sbin/hwclock  $CLOCK_OPT --localtime --systohc
  fi
fi
progressbar 80