Last Modified: Nov. 22, 2011
Adding Kernel Modules to Your Linux Distribution: Extra Credit)
The purpose of this lab is to continue developing your Minimal Linux operating system, so that it supports the dynamic loading of kernel modules. You may also want to add more commands to your bin and sbin directories, e.g. tar, fdisk, (can you think of others?)
Step One
You need to copy the following files to your file system. The program files must come from the same distribution, CentOS 5.4
| /lib/modules |
sbin |
| kernel/fs/jbd/jbd.ko |
insmod |
| kernel/fs/ext3/ext3.ko |
modprobe |
| kernel/fs/fat/fat.ko, vfat/vfat.ko |
lsmod |
| kernel/drivers/ide/ide-cd.ko cdrom/cdrom.ko |
rmmod |
- Start with the files in the sbin directory. Copy these binaries into
your sbin directory.
- Run the ldd command on each of these files, and copy
any libraries needed that you don't already have to your lib directory.
Step Two
Now that we have the commands copied, we will copy some kernel modules that
will be needed for reading ext3 and vfat file systems, as well as the cdrom.
- Change directory to your pendrive's lib directory and create
a subdirectory called modules:
mkdir modules
And then change directory into that subdirectory.
- The kernel modules we are going to copy from the host system to your
file system must match the kernel you have, so be sure to get these from
the same system you obtained the kernel. The drivers we want are in the table above and may be found on your system under:
/lib/modules/2.6.18-164.el5
Copy each driver to your modules directory; you do not need to preserver
the long pathname - just put all six drivers in the same modules directory.
Step Three
In this step we will edit the etc/rc.sysinit shell script.
- To the bottom of your rc.sysinit script,, add the following lines:
insmod /lib/modules/jbd.ko > /dev/null
insmod /lib/modules/cdrom.ko > /dev/null
insmod /lib/modules/ext3.ko
insmod /lib/modules/ide-cd.ko
- Verify that the permisions of this file are 755
Step Four
Unmount the file system and test your new system.
- Change your current working directory back to /root
- Unmount your new filesystem
umount /mnt
- Boot the computer from your Minial Linux: You should
see your personal banner along with a few messages from the mount command.
- Log in as root and list the kernel modules currently loaded in the kernel:
lsmod
- Try loading the fat.ko module using the insmod command:
insmod /lib/modules/fat.ko
Verify that it loaded.
- Now load the vfat.ko module using the insmod command:
insmod /lib/modules/vfat.ko
Verify that it loaded.
- You should now be able to mount a vfat file system such as a floppy disk
and view the files on it.
To Turn In
For this lab I want to see a recursive long listing of your file system, a copy of your /etc/rc.sysinit file, and the output of the lsmod command:
ls -lR /mountpoint > lab11x
cat /mountpoint/etc/rc.sysinit >> lab11x
lsmod >> lab11x
Use the scp command to forward this file to your home directory on opus:
scp lab11x logname@opus.cabrillo.edu:lab11x
Grading Rubrik
- 1 point -
- For having all the files from the table on your root file system.
- 2 points -
- For a correctly specified /etc/rc.d/rc.sysinit file
- 2 points -
- For your lsmod listing showing the loaded kernel modules