Last Modified: Oct. 2, 2011

Creating a Single User Linux Distribution(Part II)

The purpose of this lab is to continue developing your Minimal Linux operating system, so that it will allow you to run a few commands and properly shutdown the system. This is a continuation of Lab3.

Step One

We need to copy the following system commands to our file system. The program files must come from the same CentOS system we used in Lab 3. The text files in the /etc directory we will create with a text editor, with the exception of the termcap file, which you will copy.
bin etc sbin
mount inittab init
umount rc.reboot reboot
ls rc.halt halt
ps rc.sysinit fdisk
hostname termcap  
rm    
cat    
  1. Start with the files in the /bin directory. Copy the six files listed into your bin directory. (some of these files may be in /usr/bin, but put them all in your bin directory.)
  2. Run the ldd command on each of these files, and write down the names of any libraries needed that you don't already have.
    ldd bin/*
  3. For any libraries that you do not already have in /lib, you will need to copy to your lib directory.
  4. Copy the system commands in the /sbin column to your sbin directory.
    Note that either halt or reboot will most likely be a symbolic link to the other. You should maintain that relationship.
  5. Note that you will be overwriting the init symbolic link with the actual binary. You may want to remove the symbolic link before you copy the files. Once the files are copied, make sure you don't need any additional libraries in your lib directory for these executables.

Step Two

We are now ready to tackle the etc directory. You are going to create similar, but simpler files than the files listed in the /etc column of the table above.
  1. In your etc directory create a file called inittab with the following content:
    id:1:initdefault:
    si::sysinit:/etc/rc.sysinit
    l0:0:wait:/etc/rc.halt
    l1:1:wait:/bin/bash
    l6:6:wait:/etc/rc.reboot
  2. Now create the file rc.sysinit with the following lines of code:
    #!/bin/bash
    echo "This is my Linux" > /dev/console
    hostname linux
    mount -n -o remount /
    mount -a 
  3. Create an rc.halt script with the following lines of code:
    #!/bin/bash
    echo "System shutting down..." > /dev/console
    rm -rf /etc/mtab
    echo "Unmounting filesystems..." > /dev/console
    umount -a > /dev/null 2>&1
    /sbin/halt -d -p
  4. Create the rc.reboot script with the following lines of code:
    #!/bin/bash
    echo "Standby while system reboots..." > /dev/console
    rm -rf /etc/mtab
    echo "Unmounting filesystems..." > /dev/console
    umount -a > /dev/null 2>&1
    /sbin/reboot -d 
  5. Make certain the three rc scripts above have execute permission.
  6. /etc/termcap - Copy this file, if it exists, to your etc directory.

Step Three

Add a couple device files, and test your singleuser system
  1. In your dev directory, create the null and sda device nodes:
    mknod null c 1 3; chmod 666 null
    mknod sda b 8 0; chmod 660 sda
  2. Change your current working directory back to /root
  3. Unmount your new file system
    umount /mnt
  4. You should now be able to boot up to a shell prompt your pen drive. Give it a try!
  5. To test your new Linux, execute the hostname, ls and ps commands.
    Can you use fdisk to view your partition table?
  6. Look at the contents of your grub.conf file.
  7. When you are ready to shut down, issue the command:
    init 0
    What happens?

To Turn In

For this lab I want to see a recursive long listing of your file system, and a copy of your /etc/inittab file:
ls -lR /mountpoint > lab5x; cat /mountpoint/etc/inittab >> lab5x

Use the scp command to forward this file to your home directory on opus:
scp lab5x logname@opus.cabrillo.edu:

Grading Rubrik

3 points -
For having all the files from the table on your root file system.
2 points -
For correctly specified /etc/inittab and rc scripts.