Simple Graphical Boot For Slackware - Part 2
logo
Simple Graphical Boot For Slackware - Part 2
Apr 13, 2022

In part 1 we edited the grub.cfg file and added a couple of parameters to the kernel command line to turn off kernel messages being printed to the console and to redirect console the other output to  tty12. That takes care of the majority of the boot messages, but if that was all we did there will some messages that still manage to print to the terminal. For instance, there's the output generated by the initrd. We'll take care of that last, but it took me awhile to figure out where it was coming from because it comes and goes so fast.

I wrote wrapper scripts for /etc/rc.d/rc.S and /etc/rc.d/rc.M that display the splash screen and redirect stdout to a file so we can still log the output of the startup scripts. The kernel messages will still get sent to /var/log/messages and /var/log/syslog. I use busybox to run the commands, mainly because the fbsplash command that draws the splash image to the framebuffer is a busybox command, and the few commands I use for these scripts can be run from busybox. Before we get to scripts, we have to get our splash image set to the correct size for framebuffer, and fbsplash requires the image to be in .ppm format.

First we'll switch to the text console and find out what mode the framebuffer is running in so we can resize our splash image if necessary and convert it to .ppm format. Ctrl-Alt-F6 will take us to a terminal, log in and run these commands:

 


jkenobi@homebase:~$  fbset -v
Linux Frame Buffer Device Configuration Version 2.1 (23/06/1999)
(C) Copyright 1995-1999 by Geert Uytterhoeven

Opening frame buffer device `/dev/fb0'
Using current video mode from `/dev/fb0'

mode "1366x768"
    geometry 1366 768 1366 768 32
    timings 0 0 0 0 0 0 0
    accel true
    rgba 8/16,8/8,8/0,0/0
endmode

 

As you can see, my  terminal's mode is 1920x1080, so now I know what size my splash image needs to be. I use ImageMagick to take of resizing the my splash image and also to convert it to .ppm format. ImageMagick can convert pretty much any image format to any other image format using the 'convert' command. Nothing fancy just  convert  a.X b.Y. Simple, which is the Slackware Way. Some people feel that the more complex a system or method is the better, but simplicity is genius. Let's get the splash image ready.

 


# using the ImageMagick convert command we can resize and covert the 
# splash image in one command

jkenobi@homebase:~$ convert -resize 1920x1080 splash_screen.png splash_screen.ppm
jkenobi@homebase:~$ file splash_screen.ppm 
splash_screen.ppm: Netpbm image data, size = 1920 x 1080, rawbits, pixmap


 

Doesn't get much simpler than that. If you're into manipulating images take a look at ImageMagick. It is an extremely powerful tool and easy to use. Hard to believe a command line tool can do so much.  I put my splash image in the /boot directory, but where you put isn't important, as long as you can tell fbsplash where to find it. I use the same image for GrUB, the splash screen, and the display manager, which is sddm at the moment, except that GrUB and sddm use the .png formatted image.  Before we move to the next step, if you haven't already, now would be a good time to make sure you have a live linux usb that you can use to access your machine's partitions in the event something goes wrong and your machine won't boot. I have been running these scripts on my machine for a couple of years now, but I make no promises and offer no guarantees. And something as simple as a typo or a stray character you didn't realize you typed can break these scripts. Proceed at your own risk, and make sure your code is correct before you reboot, and have that usb ready and know how to use it to fix your machine. Got it? Great, let's get to it. Below is the wrapper for the system initializtion script.

 

#!/bin/bash
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#   /etc/rc.d/rc.S-gb
#   wrapper for rc.S init script - Simple Graphical Boot
#  
#   YOU ARE FREE TO USE THIS SCRIPT, HOWEVER BY DOING SO, YOU RELEASE THE 
#   AUTHOR FROM ANY LIABILITY  FOR ANY DAMAGES THAT MAY OCCUR AS A RESULT
#   OF ITS USE. IT IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY WARRANTIES 
#   WHETHER EXPRESS OR IMPLIED, ARE DISCLAIMED.
# 
#   © 2021 JuanKenobi  |  Dallas, TX USA                                  
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 

PATH=/opt/busybox/bin:/opt/busybox/sbin
IMG="/boot/splash.ppm"
RC_S="/etc/rc.d/rc.S"
MSGFIFO="/boot/GSplash/fbfifo"
BOOTLOG="/media/ramdisk/boot.log"
BOOTCONS="/dev/tty12"
LOGCONS='12'

# make a small ramdisk to log output to since
# partition is initially mounted read-only
dd if=/dev/zero of=/dev/ram0 bs=512 count=8192 &> /dev/null
mount -t tmpfs -o size=4m /dev/ram0 /media/ramdisk &> /dev/null

# redirect stdout to file descriptor 6, then send all stdout to boot.log
exec 6>&1
exec > $BOOTLOG

#timestamp for boot.log
echo "$(date)"

# clear terminal screen and turn off messages
/usr/bin/tput clear
/usr/bin/setterm -msg off

# draw splash image to framebuffer
/opt/busybox/sbin/fbsplash -s "$IMG"

# this isn't turning the cursor off
/usr/bin/setterm -cursor off

# start the system initialization script and send
# all out put to the fbfifo named pipe
exec $RC_S &> $MSGFIFO &

# this is necessary if you want to implement a progress bar
# and/or you would like to be able to see the boot messages

COUNT=1
while read KMESG; do
    echo "$KMESG -- $COUNT"  #>> $BOOTLOG
    COUNT=$(( $COUNT + 1 ))
done <$MSGFIFO 

# send stdout to console and close file descriptor 6
exec 1>&6 6>&-

echo "Total number of boot messages from rc.S:  $COUNT"  >> $BOOTLOG


# vim: sw=4 sts=4 expandtab:

 

< Prev                                                  Next >



October 2024
SunMonTueWedThuFriSat
  12345
6789101112
13141516171819
20212223242526
2728293031