How to debug rc.sysinit (puppy boot problems)

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
kethd
Posts: 451
Joined: Thu 20 Oct 2005, 12:54
Location: Boston MA USA

How to debug rc.sysinit (puppy boot problems)

#1 Post by kethd »

How to debug Puppy boot

What are you going to do if your new Puppy installation won't boot? Start by having some success; use the LiveCD version on good working computers, do some easy/simple Puppies first!

But when you decide to dig in and do hard advanced installs:
You probably want to start by searching the Forum for other people with the same problems. Make sure what you are trying should work, and that you are following all relevant instructions.

Try to figure out which phase of the boot process is failing, and concentrate on learning more about that aspect. You may have to learn as much as possible about how Puppy works; use the Wiki.

The messages that scroll by on the screen might help, but there is no easy way to study them. If your pup gets far enough, the command line that is passed from the bootloader should be in /proc/cmdline, and the log from the kernel/init process in /var/log/messages.

It might be possible to set the boot to serial console and capture the startup messages on another computer.

If you decide that the core kernel/init is starting OK and suspect the problem is in the Puppy-specific part of the boot process, you are facing quite a challenge. You must get comfortable with the Linux command line interface and learn general ash/bash shell troubleshooting:
http://www.murga.org/%7Epuppy/viewtopic.php?t=4808
How to debug ash/bash shell scripts

You will have to learn how to modify the rc.sysinit script, the first part of Puppy proper that is run. To make changes in this and try them, you will have to remaster image.gz. This is one way to do that:

Code: Select all

# cd /
# mkdir mountdir
# cp /mnt/home/image.gz ./
# gunzip image.gz
# mount -o loop image mountdir
### edit rc.sysinit here ###
# umount mountdir
# gzip image
### copy image.gz back to where it belongs, with the name you want to give it
You have to learn to walk before you can run; you will need to work with the Linux CLI a while before you are likely to succeed at this.

But debugging requires trying many many things. Often you have to make hundreds of tests. You don't want to have to go through the whole image.gz remastering hundreds of times -- what to do?

The answer is to make powerful general purpose modifications in sysinit. Ideally they would not interfere with normal operation, and could be included in future standard versions of Puppy.

This is what I added onto the front of sysinit:

Code: Select all

#!/bin/sh
echo "22dec05 rc.sysinit kd"
ln -s /bin/busybox /bin/tee
ln -s /bin/busybox /bin/mkfifo
ln -s /bin/busybox /bin/hexdump

#if [[ -n "$1" ]]; then $1 = "="; fi #prevent problems with null string

SBUG=${SBUG}= #prevent problems with null string
echo $SBUG
if ( expr index $SBUG v ); then set -v ; fi
if ( expr index $SBUG x ); then set -x ; fi
if ( expr index $SBUG 1 ); then exec 1>sysinit.log ; fi
if ( expr index $SBUG 2 ); then exec 2>sysinit2.log ; fi
if ( expr index $SBUG 3 ); then exec 1>sysinit.log 2>&1 ; fi

if ( expr index $SBUG D ); then
#DEBUGFUNC()
#{ 
xxcc=debug
while [ "$xxcc" ]; do
 echo -n $LINENO "DEBUG: ENTER or type a command: "
 read xxcc
 eval $xxcc
done
#}
fi

echo $SBUG processed
Under normal conditions this added code has no effect. But you can now add SBUG=vx123D parameter flags to your bootloader command line. The -vx flags let you see what the shell is doing step by step. The 123 switches would let you create log files, but the D switch is by far the most important, and far overshadows the rest. This lets you use the shell interactively right at the start of sysinit, and you can do almost anything at that point. When you are finished, just enter a blank line and the standard Puppy sysinit will continue.

Using this tool, you can easily dump all the current variables with the set command, and manually enter/change any Puppy parameters, such as PHOME=hda1. You can turn the flags on and off with set -vx. And you can try to redirect output into log files with exec 2>logfile2. But attempts to redirect both stdout and stderr into files at the same time seems to malfunction, presumably because of the primitive/delicate state of Puppy at this point. And whatever you redirect will not show up on the screen, leaving you blind. But turning on -sx and sending it to a logfile is very powerful, gives you reams of detailed info to study. And if you can get a similar dump of a successful boot, and then run a diff comparison, you can quickly spot key differences.

It would be great if someone could figure out how to have sysint debug always available and invokable without requiring any changes in the bootloader parameters, some kind of live check on the keyboard for a special key combination at the start of sysinit, that quickly continues automatically under normal conditions. And wonderful if there were some way to automatically add/overlay code to sysinit dynamically at boot time, or even replace sysinit entirely if certain files were present/provided in certain places, without ever having to remaster image.gz.

My hope is to someday understand Puppy sysinit well enough to be able to add options to completely manually control the boot process, if that is appropriate.

*** See also: ***

http://www.murga.org/%7Epuppy/viewtopic.php?t=4812
What are the possible Puppy boot parameters (to be passed from the Gujin/tiny command line, or GRUB or LILO)?

http://www.murga.org/%7Epuppy/viewtopic.php?t=4823
Gujin command line length problems

http://www.murga.org/%7Epuppy/viewtopic.php?t=4692
How to give birth to puppy by hand -- doing things the hard way

http://www.murga.org/%7Epuppy/viewtopic.php?t=4825
Change Gujin from CONFIG.SYS to AUTOEXEC.BAT

http://www.murga.org/%7Epuppy/viewtopic.php?t=4801
How to pass named variables to ash/bash shell scripts

http://www.murga.org/%7Epuppy/viewtopic.php?t=4679
Kernel panic

http://www.murga.org/%7Epuppy/viewtopic.php?t=4626
How to force mount usr_cram.fs

http://www.murga.org/%7Epuppy/viewtopic.php?t=4627
How to force load alternate text editor mp - Minimum Profit

http://www.murga.org/%7Epuppy/viewtopic.php?t=4638
BusyBox Suggestions

http://www.murga.org/%7Epuppy/viewtopic.php?t=4802
How to capture command line screen text output in a logfile and still have it show on the screen

http://www.murga.org/%7Epuppy/viewtopic.php?t=4305
ash/bash shells: which does Puppy use?

http://www.murga.org/%7Epuppy/viewtopic.php?t=4403
What is the best general purpose Linux wiki?

http://puppylinux.org/wikka/BootParms
http://www.goosee.com/puppy/config-puppy.htm
http://gujin.sourceforge.net/

Post Reply