There is a lot of typing to do in this section because of all of the start-up scripts that need to be created. Using a mouse to copy the text from this guide and paste it into a text editor can be a great time saving tool.
Insert and mount the floppy labeled "boot disk".
bash#
mount /dev/fd0 /mntbash#
cd /mnt/boot/grub
Use your favorite text editor to create the following file and save it as /mnt/boot/grub/menu.lst:
default 0 timeout 3 title Pocket Linux Boot Disk kernel (fd0)/boot/vmlinuz root=/dev/fd0 load_ramdisk=1 prompt_ramdisk=1
Download the latest sysvinit source from ftp://ftp.cistron.nl/pub/people/miquels/software/
bash#
cd /usr/src/sysvinit-2.85/srcbash#
make CC="gcc -mcpu=i386"bash#
cp halt init shutdown ~/staging/sbinbash#
ln -s halt ~/staging/sbin/rebootbash#
ln -s init ~/staging/sbin/telinitbash#
mknod ~/staging/dev/initctl p
In the interest of speed we are skipping the steps for checking libraries and stripping binaries. The library requirements for sysvinit are very basic and the Makefile is configured to automatically strip the binaries.
Use a text editor to create the following file and save it as
~/staging/etc/inittab
# /etc/inittab - init daemon configuration file # # Default runlevel id:1:initdefault: # # System initialization si:S:sysinit:/etc/init.d/rc S # # Runlevel scripts r0:0:wait:/etc/init.d/rc 0 r1:1:respawn:/bin/sh r2:2:wait:/etc/init.d/rc 2 r3:3:wait:/etc/init.d/rc 3 r4:4:wait:/etc/init.d/rc 4 r5:5:wait:/etc/init.d/rc 5 r6:6:wait:/etc/init.d/rc 6 # # end of /etc/inittab
Use a text editor to create the following file and save it as
~/staging/etc/init.d/rc
#!/bin/sh # # /etc/init.d/rc - runlevel change script # PATH=/sbin:/bin SCRIPT_DIR="/etc/rc$1.d" # # Check that the rcN.d directory really exists. if [ -d $SCRIPT_DIR ]; then # # Execute the kill scripts first. for SCRIPT in $SCRIPT_DIR/K*; do if [ -x $SCRIPT ]; then $SCRIPT stop; fi; done; # # Do the Start scripts last. for SCRIPT in $SCRIPT_DIR/S*; do if [ -x $SCRIPT ]; then $SCRIPT start; fi; done; fi # # end of /etc/init.d/rc
Make the file executable.
bash#
chmod +x ~/staging/etc/init.d/rc
A case statement is added to allow the script to either mount or unmount local filesystems depending on the command-line argument given. The original script is contained inside the "start" portion of the case statement. The "stop" portion is new.
#!/bin/sh # # local_fs - check and mount local filesystems # PATH=/sbin:/bin ; export PATH case $1 in start) echo "Checking local filesystem integrity." fsck -ATCp if [ $? -gt 1 ]; then echo "Filesystem errors still exist! Manual intervention required." /bin/sh else echo "Remounting / as read-write." mount -n -o remount,rw / echo -n > /etc/mtab mount -f -o remount,rw / echo "Mounting local filesystems." mount -a -t nonfs,smbfs fi ;; stop) echo "Unmounting local filesystems." umount -a -r ;; *) echo "usage: $0 start|stop"; ;; esac # # end of local_fs
Use a text editor to create the following script and save it as
~/staging/etc/init.d/hostname
#!/bin/sh # # hostname - set the system name to the name stored in /etc/hostname # PATH=/sbin:/bin ; export PATH echo "Setting hostname." if [ -f /etc/hostname ]; then hostname $(cat /etc/hostname) else hostname gnu-linux fi # # end of hostname
Use a text editor to create
~/staging/etc/init.d/halt
as shown below.
#!/bin/sh # # halt - halt the system # PATH=/sbin:/bin ; export PATH echo "Initiating system halt." halt # # end of /etc/init.d/halt
Create the following script and save it as
~/staging/etc/init.d/reboot
#!/bin/sh # # reboot - reboot the system # PATH=/sbin:/bin ; export PATH echo "Initiating system reboot." reboot # # end of /etc/init.d/reboot
Flag all script files as executable.
bash#
chmod +x ~/staging/etc/init.d/*
bash#
cd ~/staging/etcbash#
mkdir rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d rcS.dbash#
cd ~/staging/etc/rcS.dbash#
ln -s ../init.d/local_fs S20local_fsbash#
ln -s ../init.d/hostname S30hostnamebash#
cd ~/staging/etc/rc0.dbash#
ln -s ../init.d/local_fs K10local_fsbash#
ln -s ../init.d/halt K90haltbash#
cd ~/staging/etc/rc6.dbash#
ln -s ../init.d/local_fs K10local_fsbash#
ln -s ../init.d/reboot K90reboot
bash#
cd /bash#
dd if=/dev/zero of=/dev/ram7 bs=1k count=4096bash#
mke2fs -m0 /dev/ram7 4096bash#
mount /dev/ram7 /mntbash#
cp -dpR ~/staging/* /mntbash#
umount /dev/ram7bash#
dd if=/dev/ram7 of=~/phase5-image bs=1kbash#
gzip -9 ~/phase5-image