Today, continue on your path to RHCE certification. Learn about creating a new kernel the easy way, kernel sources, recompiling a kernel, and the cron and at systems. Take notes, because there's a test at the end. This comes from chapter five of Red Hat Certified Engineer Linux Study Guide (Exam RH302), fourth edition, by Michael Jang. (McGraw-Hill/Osborne, 2004, ISBN: 0-07-225365-7).
You can have great control over how your Linux installation is set up and configured. You can control almost all aspects of the user environment, as well as the details of your kernel. Any variables or system-wide functions you may need to run can be kept in the /etc/bashrc or /etc/profile script.
You can set up quotas to limit the userís disk usage. You can set up one quota per partition, and set soft and hard limits for users. With grace periods, you can set up a soft limit to give users an appropriate warning.
The easiest way to update a kernel is to install (and not upgrade it) from a Red Hat RPM. When you do, it automatically updates your boot loader files as needed.
Alternatively, the kernel can be optimized for your particular installation and hardware, and you have detailed control over its configuration. To make a modular kernel, you need to run six commands: make mrproper, make config, make dep, make clean, make modules, make modules_install and make install. If you are compiling a monolithic kernel, you will notneed to run the last two module-related commands.
The cron and at daemons allow you to schedule jobs to run at any given time.
Here are some of the key points from the certification objectives in Chapter 5.
Shell Configuration Files
All system-wide shell configuration files are kept in the /etc directory.
/etc/profile is the system-wide startup shell script for bash users.
All users have hidden shell configuration files in their home directories.
Setting Up and Managing Disk Quotas
Quotas are used to limit a userís or a group of usersí ability to consume disk space.
Quotas are set on specific filesystems mounted to standard Linux formats.
Quota support must be enabled in the kernel. By default, quotas are enabled in RHEL 3 kernels.
Quotas have soft limits and hard limits. If both soft and hard limits are set, then a user can exceed his or her soft limit for a modest period of time.
Users and groups may never exceed their hard limits.
The Basics of the Kernel
The kernel lies at the heart of the operating system.
You can recompile Linux kernels to minimize size and maximize efficiency.
To optimize the Linux kernel, it is a best practice to compile kernels with only needed elements, and configure modules for most hardware.
Modular kernels, with separate device modules, are more efficient than monolithic kernels, where device drivers are integrated into the kernel.
If youíre going to update your kernel, you should keep a copy of your current working kernel.
There are a number of RHEL 3 kernels available for different types of CPU and levels of RAM.
Linux kernels and related files are stored in the /boot directory.
The /proc directory provides a window to what Linux sees in your computer.
Changing the values of variables in the /proc directory can change the behavior of your running kernel. For example, setting ip_forward = 1 enables routing.
Kernel modules are managed by a special kernel thread, kmod. Additional settings can be configured through /etc/modules.conf.
The lsmod command lists currently loaded modules; important related commands are insmod, rmmod, and modprobe.
Basic RHEL 3 modules are stored in the /lib/modules/2.4.21-4.EL directory.
New Kernels, the Easy Way
Kernel version numbers are organized in major.minor.patchformat. Red Hat adds a build number to the Linux kernels that it builds from source code.
Itís fairly easy to install a Red Hat kernel from RPM, as long as you remember to install and not upgrade. This allows you to return to the current working kernel if you have a problem.
Sometimes, what you need is a kernel patch, which supports upgrades of one patch version number. Unfortunately, patches are not always compatible with Red Hat built kernels.
Itís important to create a new boot floppy whenever you install a new kernel.
When you install a Red Hat kernel from RPM, the process should automatically update your boot loader (GRUB or LILO).
The kernel source tree is accessible through /usr/src/linux-2.4, which is normally linked to the actual directory with kernel source files.
Kernel sources can be loaded from the kernel-source RPM or from a Linux kernel tarball downloaded from a site such as ftp.kernel.org.
Recompiling a Kernel
Your current kernel configuration is stored in the config-versionnumberfile in the /boot directory.
You can modify kernel settings from the /usr/src/linux-2.4 directory with one of the following commands: make config, make menuconfig,or make xconfig. The last two lead to a long series of menus.
Once youíve made the proper backups and boot disks, set the EXTRAVERSION variable in your Makefile, run the make mrproper command, and placed current settings in /usr/src/linux-2.4/.config, youíre ready to modify your kernel.
Once youíve settled on and saved your changes, run the make dep, make clean, make bzImage, make modules, make modules_install, and make install commands, youíve compiled your new kernel, and it should be ready for use from the GRUB boot loader.
The cron and at Systems
The cron system allows any user to schedule jobs so they run at given intervals.
The at system allows users to configure jobs to run once at a scheduled time.
The crontab command is used to work with cron files. Use crontab -e to edit, crontab -l to list, or crontab -d to delete cron files.
The /etc/cron.allow and /etc/cron.deny files are used to control access to the cron job scheduler.
This is part one from the fifth chapter of Red Hat Certified Engineer Linux Study Guide (Exam RH302), fourth edition, by Michael Jang. (McGraw-Hill/Osborne, 2004, ISBN: 0-07-225365-7). Check it out at your favorite bookstore today. Buy this book now.