Section 33.2. System Startup (Topic 2.202)


33.2. System Startup (Topic 2.202)

33.2.1. Review Questions

  1. Why are the files under the /etc/init.d directory executable?

  2. Some systems, such as Red Hat, do not place startup scripts in the /etc/init.d directory. Where do Red Hat and others put these scripts?

  3. What is the result of the following entry in the /etc/inittab file?

     ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now 

  4. You find scripts named K11anacron and S15bind9 in the /etc/rc2.d directory. Which script will run first when the system starts up?

  5. You wish to run the fsck command on a partition named /dev/hda1. What command should you run first?

  6. What is the result of the following command?

     fsck -a /dev/hda3 

33.2.2. Answers

  1. Because these files are run by the init program and are used to start system daemons

  2. In the /etc/rc.d/init.d directory

  3. It traps the hardware-based command that normally shuts the system down, and runs the Linux shutdown command. As a result, system shutdown is more orderly and causes fewer problems.

  4. K11anacron, because K scripts are run first. Then S scripts are run. Alphabetical order is followed. So K11anacron would run before K11bind, for example.

  5. umount /dev/hda1

  6. The command runs fsck on an IDE device and automatically repairs any problems found.

33.2.3. Exercises

  1. Review the contents of the /etc/inittab file. Consider adding the following line that adds a new getty command (standard text-based login) for runlevels 2, 3, 4, and 5 on tty12:

     12:2345:respawn:/sbin/getty 38400 tty12 

  2. Review the contents of the scripts at your particular runlevel. In some systems (Red Hat and Fedora), you can find these scripts in the subdirectories of the /etc/rc.d directory. In other systems, you will find the files in the /etc/rcN.d directory, where N is the number of the runlevel. For example, an Ubuntu system is Debian based and defaults to runlevel 2. Therefore, the scripts that run at the default runlevel are in the /etc/rc2.d directory. Review the scripts in this directory to see what is run. Notice that there are K scripts and S scripts. The K scripts are run before the S scripts. Scripts are run first in numerical, then in alphabetical, order. Determine the order in which scripts are run.

  3. Practice using the following commands as root:

     init 0 init 6 init 2 init 5 

    Write down the results of each command for your particular system or systems.

  4. Review the contents of the /etc/mkinitrd/mkinitrd.conf file. Note the default settings for the initrd image that would be created. They are usually 022. The DELAY option is usually set to 0 by default. You would increase this value if you wished to give the system a chance to rest before running initialization scripts.

  5. As root, type init 1. Notice what you have to do to enter maintenance mode. After you type the root password, you will see that you can edit files, make necessary changes, and run programs such as fsck (as long as you have unmounted the partition). You are now the root user.

  6. If you are using GRUB, reboot your system and then select the default boot option when the GRUB menu screen appears. Press e. You will see that you can now edit the boot parameters for this particular session. Press the Escape key to go back to the main menu.

  7. If you are using GRUB, reboot your system again. Once you see the GRUB menu screen, press c. You will be sent to a GRUB prompt, where you can create your own boot sequence. Press the Escape key to return to the menu and boot your system.

  8. If you are using GRUB, execute the following commands to store Stage 1 and Stage 2 on a floppy disk:

    1. :Insert a floppy disk.

    2. Change to the GRUB directory:

       cd /boot/grub/ 

    3. Copy the Stage 1 files and Stage 2 files to the floppy disk using the dd command:

       dd if=stage1 of=/dev/fd0 bs=512 count=1 dd if=stage2 of=/dev/fd0 bs=512 seek=1 

      These commands create a valid boot floppy disk for your drive.

  9. If you do not have a floppy disk drive and want to create a GRUB boot CD, you need to use the file named stage2_eltorito. This is a special Stage 2 file required by CD-ROM drives. You do not need to use the Stage 1 or Stage 2 files. The stage2_eltorito file is often located in the /usr/lib/grub/i386-pc/ or /lib/grub/i386-pc directory. The steps you take to create a bootable CD-ROM follow.

    1. Create a directory structure to store the ISO image you are going to create. This structure must be stored onto the CD-ROM as /boot/grub:

       mkdir -p iso/boot/grub 

    2. Copy the /usr/lib/grub/i386-pc/stage2_eltorito file to the directory you have just created:

       cp /usr/lib/grub/i386-pc/stage2_eltorito ~/iso/boot/grub/ 

    3. Use the mkisofs command to create an ISO image:

       mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o grub.iso iso 

      This command tells mkisofs to create Rock Ridge protocol files and also specifies the path of the boot image used.

    4. You can then use any application you wish to burn the ISO image (grub.iso) onto the CD-ROM.

  10. If you are using LILO, add password protection to it using the instructions given in this book. Be sure to make a backup copy of your original lilo.conf file before making any changes to it. Once you are finished making your changes, be sure to install them as lilo.conf and then run lilo to make sure your changes are recognized.



LPI Linux Certification in a Nutshell
LPI Linux Certification in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596005288
EAN: 2147483647
Year: 2004
Pages: 257

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net