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 /mnt bash# 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/src bash# make CC="gcc -mcpu=i386" bash# cp halt init shutdown ~/staging/sbin bash# ln -s halt ~/staging/sbin/reboot bash# ln -s init ~/staging/sbin/telinit bash# 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/etc bash# mkdir rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d rcS.d bash# cd ~/staging/etc/rcS.d bash# ln -s ../init.d/local_fs S20local_fs bash# ln -s ../init.d/hostname S30hostname bash# cd ~/staging/etc/rc0.d bash# ln -s ../init.d/local_fs K10local_fs bash# ln -s ../init.d/halt K90halt bash# cd ~/staging/etc/rc6.d bash# ln -s ../init.d/local_fs K10local_fs bash# ln -s ../init.d/reboot K90reboot |