Наши друзья и партнеры

купить дешевый 
компьютер родом из Dhgate.com

Книги по Linux (с отзывами читателей)

Библиотека сайта rus-linux.net

6.3. Construction

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.

6.3.1. Create a GRUB configuration file

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

6.3.2. Install sysvinit utilities

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.

6.3.3. Create /etc/inittab file

Use a text editor to create the following file and save it as ~/staging/etc/inittab

# /etc/inittab - init daemon configuration file
# Default runlevel
# System initialization
si:S:sysinit:/etc/init.d/rc S
# Runlevel scripts
r0:0:wait:/etc/init.d/rc 0
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

6.3.4. Create /etc/init.d/rc script

Use a text editor to create the following file and save it as ~/staging/etc/init.d/rc

# /etc/init.d/rc - runlevel change script
# 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;
# Do the Start scripts last.
  for SCRIPT in $SCRIPT_DIR/S*; do
    if [ -x $SCRIPT ]; then
      $SCRIPT start;
# end of /etc/init.d/rc

Make the file executable.

bash# chmod +x ~/staging/etc/init.d/rc

6.3.5. Modify /etc/init.d/local_fs script

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.

# local_fs - check and mount local filesystems
PATH=/sbin:/bin ; export PATH

case $1 in

  echo "Checking local filesystem integrity."
  fsck -ATCp
  if [ $? -gt 1 ]; then
    echo "Filesystem errors still exist!  Manual intervention required."
    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

  echo "Unmounting local filesystems."
  umount -a -r

  echo "usage: $0 start|stop";

# end of local_fs

6.3.6. Create a hostname script

Use a text editor to create the following script and save it as ~/staging/etc/init.d/hostname

# 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)
  hostname gnu-linux
# end of hostname

6.3.7. Create halt & reboot scripts

Use a text editor to create ~/staging/etc/init.d/halt as shown below.

# halt - halt the system
PATH=/sbin:/bin ; export PATH

echo "Initiating system halt."
# end of /etc/init.d/halt

Create the following script and save it as ~/staging/etc/init.d/reboot

# reboot - reboot the system
PATH=/sbin:/bin ; export PATH

echo "Initiating system reboot."
# end of /etc/init.d/reboot

Flag all script files as executable.

bash# chmod +x ~/staging/etc/init.d/*

6.3.8. Create rcN.d directories and links

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

6.3.9. Create the root disk image

bash# cd /
bash# dd if=/dev/zero of=/dev/ram7 bs=1k count=4096
bash# mke2fs -m0 /dev/ram7 4096
bash# mount /dev/ram7 /mnt
bash# cp -dpR ~/staging/* /mnt
bash# umount /dev/ram7
bash# dd if=/dev/ram7 of=~/phase5-image bs=1k
bash# gzip -9 ~/phase5-image

6.3.10. Copy the image to diskette

Insert the diskette labeled "root disk" into drive fd0.

bash# dd if=~/phase5-image.gz of=/dev/fd0 bs=1k

Если вам понравилась статья, поделитесь ею с друзьями: