To complete this project, you will need to:
This has been already done and burned to a CDROM. It is in the lab beside the computer usable for this class.
Boot to the CDROM. You might have to enter the BIOS to control Boot Order. Once booted on the CDROM, take all defaults, except choose a custom kernel, and later, minimal install. This choice of install requires only the one CDROM.
Choose a root password. Do not leave a machine on the net without a password for root.
You will need a compiler:
yum install gcc.i386will get you one from the net, and install it.
You will need kernel sources. Use wget to this URL:
http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.13.tar.gz{bz2}Use gunzip or bunzip2 to decompress. Move the tarball to /usr/src and extract.
Read on the net how to build a linux kernel. In short:
make config make dep make clean make bzImage make modules make modules_install make installThe result will be:
The BIOS identifies all attached disks and numbers them as hd0, hd1, and so forth. Each disk is an array of sectors. Sector zero of each disk is called the Boot Sector, of the MBR, Master Boot Record. A disk is partitioned, is if acts as several disks, one for each partition. The partitioning information is stored on the Boot Sector, at the end of the Boot Sector. This is called the partition table, and you are advised not the damage it.
To see the boot sector of a disk of a live Linux system, be root, identify the device, such as /dev/hda, for the first IDE disk, and type:
dd if=/dev/hda count=1 | hexdump -CYou will note the words GRUB mixed into the bytes of the sector, if this is an MBR containing the GRUB boot loader. The last 4 lines of the listing is the partition table, and you can try to learn to read it right from the dump. The last two bytes are hex 0x55, 0xaa. This is the signature of an MBR, or at least of a partition table.
A boot sector contains a partition table and it may contain code to read an operating system off of a disk. This code is called the boot loader. Since a sector is small, this code is just enough of the boot loader to read the rest of the boot loader. So the path is: the BIOS reads the MBR, the MBR code reads a boot loader and runs it, the boot loader reads the operating system (the kernel) and runs it.
We use the GRUB boot loader. It wants itself, its configuration files, and the kernels it can load, to live on its own little partition which will be mounted as /boot (by convention) once the system is running. On clean, default Linux installs, this partition is usually the first, located in the lowest block numbers of the disk.
Modify /usr/src/linux*/Makefile so that EXTRAVERSION reflects that this is hacked kernel. Else you will be sorry. Modify arch/i386/kernel/entry.S or some such file to subsitute sys_helloworld for some "ni" entry. Find an appropriate file and add the function sys_helloworld following the pattern of the othere syscall bodies. Recompile the kernel, and so on.
Booting to the hacked kernel, in the root home directory, write a program to test the new system call.