PuppyLinux : BootingPuppyLinuxSpanish

PuppyLinuxMainPage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register

Booting Puppy Linux


The following is obtained from an outdated page of Barry's: http://pupweb.org/puppy/puppy-startup.htm
How Puppy Works is more up to date.


On this page I have documented the steps that Puppy goes through while booting. I have attempted to put it in steps that a normal Linux distribution would go through, with notes to show how Puppy deviates from (simplifies) those steps.

STEP 1.
/initrd/
Provides capability to load a ramdisk by the boot loader. This has a temporary filesystem used during the boot process. Puppy Linux does not have this directory.

Puppy loads the "real" root filesystem from Compact Flash without need for a temporary filesystem.
For normal Linux systems, a small filesystem has to load into ramdisk prior to to loading the kernel, then the rest of the Linux filesystem can be mounted. In the case of Puppy, that preliminary small filesystem is also all of Puppy, there's nothing more.

STEP 2.
/sbin/init*
This is on the real root filesystem and is now executed. This is actually a symbolic link to busybox, which is located in /bin. Busybox is a master program that contains all the main Linux commands (such as ls*, cp*, df*, etc.).

STEP 3.
The temporary initrd filesystem in ramdisk is removed. Not applicable to Puppy.

STEP 4.
/etc/init.d/
All scripts executed by the init stage are located here. Puppy doesn't use this, and the directory doesn't exist.

STEP 5.
/etc/inittab
init stage goes here to set the default run-level, plus the initial processes to start running.
For Puppy this is what the file "inittab" looks like:
FOR ILLUSTRATION PURPOSES ONLY: NOT NECESSARILY EXACTLY THE SAME IN PUPPY

::sysinit:/etc/rc.d/rc.sysinit
tty1::respawn:/sbin/getty 38400 tty1
tty2::respawn:/sbin/getty 38400 tty2
tty3::respawn:/sbin/getty 38400 tty3
tty4::respawn:/sbin/getty 38400 tty4
::shutdown:/etc/rc.d/rc.reboot
::ctrlaltdel:/sbin/reboot
One common use of inittab is to specify the runlevel, for example "id:2:initdefault". This sets the runlevel to 2. Note that runlevel=0 usually means halt, =1 means single-user, 2-5 means multi-user, =6 means reboot. The action or meaning of each level is determined by scripts inside /etc/init.d/ that are executed on a change of runlevel.
With Puppy, I haven't bothered about using runlevels -- I don't know why we need the extra hassle of using them.

getty* is an application that waits for user login, then runs /bin/login* which reads and verifies username and password, then executes /bin/sh* (the Ash shell). Actual startup of Ash is described at STEP 8.
(Ash is a commandline shell, like command.com in DOS).

On normal shutdown, the script /etc/rc.d/rc.reboot* will get executed.
If you type ctrl-alt-del on the keybord, the /sbin/reboot* application will execute.

Notice the first line in the above file. This is described in Step 6:

STEP 6.
/etc/rc.d/rc.sysinit*
This is a script file that is executed during boot, usually to perform some initialisation and cleanup, such as cleaning out the /tmp directory. The script location is specified in inittab -- see above, it's in /etc/rc.d/rc.sysinit*. Here is the content of rc.sysinit*:
FOR ILLUSTRATION PURPOSES ONLY: NOT NECESSARILY EXACTLY THE SAME IN PUPPY

#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin
. /etc/rc.d/rc.functions
mount /proc;check_status

. /etc/rc.d/rc.modules
echo -n "Remounting root rw: ";mount -o remount,rw /;check_status
echo -n "Mounting devpts: ";mount /dev/pts;check_status

echo "loading keyboard map for your country... (choices are:"
echo "be br cf de dk es fi fr gr hu it jp no pl ru se uk us)"
/bin/gzip -dcf /lib/keymaps/us.gz | /sbin/loadkmap
echo "so, I guess we can delete them now..."
rm -f /lib/keymaps/*

echo -n "Setting hostname: ";hostname -F /etc/hostname;check_status

echo -n "Cleaning up system: "
> /var/run/utmp
rm -rf /tmp/*
check_status

echo "Setting up interface lo..."
ifconfig lo 127.0.0.1
route add -net 127.0.0.0 netmask 255.0.0.0 lo

echo -n "Starting syslogd: ";syslogd -m 0 -L;check_status
echo -n "Starting klogd: ";klogd;check_status

echo -e "puppy 0.1\n`uname -s` `uname -r` [`uname -m` arch]\n\n" > /etc/issue

echo "BK Scan for fonts. Part of fontconfig, references fonts.conf for"
echo "font path, generates fonts.cache-1 in each font directory"
fc-cache --verbose

echo "usb storage device replies async, need to sleep..."
sleep 30

echo "Puppy wants to mount the flash device..."
#remove everything from /root temporarily, so can mount on it...
cp -a /root /tmp/root
rm -rf /root/*
mount -t umsdos /dev/sda1 /root
if [ "$?" -eq 0 ];then
echo "SUCCESS: ALL PERSONAL FILES WILL BE AUTO SAVED IN FLASH DEVICE"
#sync the umsdos/msdos filesystems...
umssync /root
#Busybpx cp doesn't have -u option, so do it hard way (best anyway)...
if [ ! -e /root/.app-defaults ];then
cp -a /tmp/root/.app-defaults /root
fi
if [ ! -e /root/.endeavour ];then
cp -a /tmp/root/.endeavour /root
fi
if [ ! -e /root/.etc ];then
cp -a /tmp/root/.etc /root
fi
else
echo "CANNOT MOUNT FLASH DEVICE. CANNOT SAVE PERSONAL FILES"
#put everything back again...
cp -a /tmp/root/* /root
fi
rm -rf /tmp/root
sync
Wow, what does all that do? Here are some of the Linux commands that are executed by sysinit:

ifconfig* TCP/IP command. Assign an address to a network interface and/or configure network interface parameters. ifconfig is typically used at boot time to define the network address of each interface on a machine. It may be used at a later time to redefine an interface's address or other parameters. Without arguments, ifconfig displays the current configuration for a network interface. Used with a single interface argument, ifconfig displays that particular interface's current configuration.
Reference: http://www.oreillynet.com/linux/cmd/i/ifconfig.html
route* TCP/IP command. Manually manipulate the routing tables normally maintained by routed. route accepts two commands: add, to add a route, and del, to delete a route.
Reference: http://www.oreillynet.com/linux/cmd/r/route.html

STEP 7.
/etc/rc.d/rc.modules*
This is a file that is called and executed by rc.sysinit*. You can see it near the top of the previous file listing (STEP 6). I have placed all the steps to load kernel driver modules in this file. Here is the content:
FOR ILLUSTRATION PURPOSES ONLY: NOT NECESSARILY EXACTLY THE SAME IN PUPPY

#!/bin/sh
#BK if I want to access my Compact Flash card (plugged into
#first USB socket), need these...
modprobe usb-storage
modprobe usb-uhci
#...note, you may need usb-ohci instead, I think.
#...now available at /dev/sda1 ...maybe...
#...problem, delay before device replies. have put sleep.

#BK modprobe reads /etc/modules.conf, where I
#have placed path to sound drivers.
#...NOT necessary, defaults to /lib/modules/2.4.18-14custom/
#this will try each sound driver until one works...
# -v means verbose
#modprobe -v -t sound
#...no, haven't got this working. Just do this for
#my sound card:
modprobe -v via82cxxx_audio

#BK msdos and vfat filesystems are loadable modules
#(see /lib/modules/README.txt)...
modprobe -v msdos
modprobe -v vfat

#BK I reckon we will want to print...
modprobe -v parport_pc

#BK need filesystem access to the cdrom drive...
#modprobe cdrom
#...not working, need to look into this some more.
#aah, need this, which also loads cdrom.o...
modprobe ide-cd
#now does work. my cdrom is /dev/hdc.

#BK also need to access cdrom as scsi device, for burning...
#modprobe ide-scsi
#...so, is it then /dev/scd0?

modprobe -v iptable_filter
#BK need to choose your network card here..."
modprobe -v 8139too
You may need to modify this file to suit your own system. If you look in /lib/modules/ you will see the selection of driver modules available in Puppy. I have provided the complete set of modules available for the kernel as a separate download, and I will need to describe elsewhere how you can add any of these to Puppy.

STEP 8.
syslogd*, klogd*, etc.
syslogd* and klogd* are programs that run continuously in the background, started by the rc.sysinit file introduced at STEP 7. They are called daemons. Notice that the filenames end with the letter "d" -- this is a naming convention.

syslogd* This daemon takes care of logging information from various programs, and stores them to the correct place. It’s configuration file, /etc/syslog.conf, makes it possible to have logs from pppd in one file, and logs from sendmail in another (pppd and sendmail are applications).
Puppy doesn't have syslog.conf, and all logged info goes into one file, /var/log/messages.
klogd* Takes care of messages from the kernel. The kernel sends various alert and information messages, and these are categorised into levels of seriousness, from 0 to 7, the lowest number being the most serious. If you start klogd without any parameters, then the kernel messages are just swallowed. They can be logged to file, but with Puppy Linux we don't want log files growing and taking up space. A useful parameter is "klogd -c 4", which causes levels 0-3 to be printed on the console, ie, the most serious (umm, no, I think the version of klogd supplied with Busybox doesn't allow this option).
Reference: http://www.oreillynet.com/linux/cmd/k/klogd.html

STEP 9.
/etc/profile*
We have finally got to the point of getting a command-prompt, where you can type in commands. If you are familiar with MSDOS, you will know about AUTOEXEC.BAT, that executes just before giving you control of the commandline. That is, the program COMMAND.COM starts up, giving you a "commandline shell", but first executes the batch file AUTOEXEC.BAT.
The equivalent here is the script (batch file) called profile*, that executes just before handing over the "Ash shell" to you. This needs its own special section...

Ash startup
"/etc/profile*" or "/etc/bashrc*" sets various configurations at startup of Ash. Note that most Linux distribution use a shell called Bash -- Puppy uses Ash, which is similar. Puppy Linux does not have /etc/bashrc*, only /etc/profile*, and this is what is in it:
FOR ILLUSTRATION PURPOSES ONLY: NOT NECESSARILY EXACTLY THE SAME IN PUPPY

PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin"
exec `set -o vi`
ulimit -c 0
if [ `id -gn` = `id -un` -a `id -u` -gt 14 ]; then
umask 002
else
umask 022
fi
USER=`id -un`
PS1="# "
LOGNAME=$USER
HISTSIZE=1000
HISTFILE="$HOME/.history"
EDITOR=mp
INPUTRC=/etc/inputrc
TERM=linux
NNTPSERVER="news.dodo.com.au"
# GS_FONTPATH="/usr/X11R6/lib/X11/fonts/Type1"
export PATH PS1 USER LOGNAME HISTSIZE INPUTRC EDITOR TERM NNTPSERVER
These provide defaults for all users, however users can provide ".bashrc" in their home folder to override these defaults. I don't intend for more than one person to use Puppy anyway.

PS1
This controls the appearance of the Bash prompt. I documented this section, then realised that the simple Ash shell provided by Busybox can't do all of this. I have left this stuff here for now.
A reference with indepth on how to customise the Bash prompt: Bash prompt HOWTO, www.tldp.org.

If you are running Linux right now, type this:
[bkauler@mypc bin]# echo $PS1
[\u@\h \W]\$
This will show you the current setting of PS1.
This is the setting used in Red Hat 8.0, and you can see how the actual prompt looks: "[bkauler@mypc etc]#". That is, the prompt is showing the username (bkauler), the hostname of the PC (mypc, that I gave it when installing Linux), and the current directory (bin), following by the "#" character.

You can experiment and change the prompt temporarily, by typing this:

# PS1=[\$PWD]\#
[/etc/bin]#
This is showing you the full path, rather than just your current directory. "pwd*" is actually a Bash command, and means "print working directory".

# PS1="[$PWD]#"

does the same thing.

id
This is a Bash command that gives information about the current user. At the prompt, you can type "man id" to get documentation, or "id --help" for basic info on usage.
You can see that I have used it in the "/etc/profile" file.
id -gn
This prints your group id name, example "bkauler".

id -g
This prints your group id number.

id -un
This prints your username, example "bkauler'.

id -u
This prints your user id number.


umask
The umask is used to set initial file permissions on a newly-created file. Specifically, permissions in the umask are turned off from the mode argument to open(2) (so, for example, the common umask default value of 022 results in new files being created with permissions 0666 & ~022 = 0644 = rw-r--r-- in the usual case where the mode is specified as 0666).

If mode is 777, then for umask of 022 we get file permissions of 755.

set -o vi
This turns on commandline editing. For example, up-arrow can scroll through previous commands, backspace key enables you to move back over a commandline and edit it.

HISTSIZE, HISTFILE
This sets the maximum size and location of the history file of your commandline. When you hit the up-arrow to view/choose earlier commands, you are accessing this history file.

ulimit
This places various limitations on processes. When you start a program running, it is a process.

"ulimit -c 0" limits the core dump size to zero. Some applications can generate what are known as core dump files. These have the name of "core" in the filename. There are debugging files, of no use to the end user, and can be enormous. Probably they should not be generated in the first place on an end-user system, but it can happen, so this command prevents them from happening -- otherwise, you may find your available file space suddenly drops by mega-bytes.

Reference:

http://www.justlinux.com/nhf/Filesystems/Core_Dump_Files_and_What_To_Do_About_Them.html





So there you are, 9 steps and you have a command prompt awaiting your input. Type "xwin" to start X graphics mode.




Miscellaneous stuff
Ncurses references:
http://www.linux.org/docs/ldp/howto/NCURSES-Programming-HOWTO/
http://docs.linux.cz/ncurses-intro.html

Passwords
Shadow password reference:
http://www.tldp.org/HOWTO/Shadow-Password-HOWTO.html

/etc/passwd file
username:passwd:UID:GID:full_name:directory:shell

Where:

username
The user (login) name

passwd
The encoded password

UID
Numerical user ID

GID
Numerical default group ID

full_name
The user's full name - Actually this field is called the GECOS (General Electric Comprehensive Operating System) field and can store information other than just the full name. The Shadow commands and manual pages refer to this field as the comment field.

directory
User's home directory (Full pathname)

shell
User's login shell (Full Pathname)

For example:

username:Npge08pfz4wuk:503:100:Full Name:/home/username:/bin/sh

Where Np is the salt and ge08pfz4wuk is the encoded password. The encoded salt/password could just as easily have been kbeMVnZM0oL7I and the two are exactly the same password. There are 4096 possible encodings for the same password. (The example password in this case is 'password', a really bad password).

Once the shadow suite is installed, the /etc/passwd file would instead contain:

username:x:503:100:Full Name:/home/username:/bin/sh

The x in the second field in this case is now just a place holder. The format of the /etc/passwd file really didn't change, it just no longer contains the encoded password. This means that any program that reads the /etc/passwd file but does not actually need to verify passwords will still operate correctly.

The passwords are now relocated to the shadow file (usually /etc/shadow file).

/etc/shadow
The /etc/shadow file contains the following information:

username:passwd:last:may:must:warn:expire:disable:reserved

Where:

username
The User Name

passwd
The Encoded password

last
Days since Jan 1, 1970 that password was last changed

may
Days before password may be changed

must
Days after which password must be changed

warn
Days before password is to expire that user is warned

expire
Days after password expires that account is disabled

disable
Days since Jan 1, 1970 that account is disabled

reserved
A reserved field

The previous example might then be:

username:Npge08pfz4wuk:9479:0:10000::::

....................


To create the initial /etc/gshadow file do the following:

touch /etc/gshadow
chown root.root /etc/gshadow
chmod 700 /etc/gshadow

Once you create new groups, they will be added to the /etc/group and the /etc/gshadow files. If you modify a group by adding or removing users or changing the group password, the /etc/gshadow file will be changed.

Group password
The format of the /etc/group file is as follows:

groupname:!:GID:member,member,...

Where:

groupname
The name of the group

!
The field that normally holds the password, but that is now relocated to the /etc/gshadow file.

GID
The numerical group ID number

member
List of group members

The format of the /etc/gshadow file is as follows:

groupname:password:admin,admin,...:member,member,...

Where:

groupname
The name of the group

password
The encoded group password.

admin
List of group administrators

member
List of group members

The command gpasswd is used only for adding or removing administrators and members to or from a group. root or someone in the list of administrators may add or remove group members.

The groups password can be changed using the passwd command by root or anyone listed as an administrator for the group.




(c) 2003 Barry Kauler
http://www.goosee.com/explorer


Categories

CategoryLocalizationES

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.0
Page was generated in 0.2684 seconds