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 |
|
|
- 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.)
- 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/*
- For any libraries that you do not already have in /lib, you will need to
copy to your lib directory.
- 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.
- 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.
- 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
- 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
- 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
- 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
- Make certain the three rc scripts above have execute permission.
- /etc/termcap - Copy this file, if it exists, to your etc directory.
Step Three
Add a couple device files, and test your singleuser system
- 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
- Change your current working directory back to /root
- Unmount your new file system
umount /mnt
- You should now be able to boot up to a shell prompt
your pen drive. Give it a try!
- To test your new Linux, execute the hostname, ls and ps commands.
Can you use fdisk to view your partition table?
- Look at the contents of your grub.conf file.
- 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.