Read an Excerpt
Chapter 4: Linux Installation and Package Management (Topic 2.2)
Many resources describe Linux installation.1 Despite its title, however, this section's Topic and Objectives do not provide an overview for the installation of any particular Linux distribution. Rather, they focus on four installation topics and two packaging tools as required for LPI Exam 102:
- Objective 1: Design a Hard Disk Layout
- The layout and partitioning of disks is a fundamental concept for almost all computer platforms. Unlike other operating systems though, Linux uses multiple partitions in a unified filesystem. This Objective covers this filesystem layout. Weight: 2.
- Objective 2: Install a Boot Manager
- Booting Linux is a process started by a boot manager. This Objective covers the use of LILO. Weight: 2.
- Objective 3: Make and Install Programs from Source
- The unique advantages of open source software allow the distribution of programs in source code form. This Objective covers compiling and installing programs from source code. (Objectives 5 and 6 deal with binary package management.) Weight: 2.
- Objective 4: Manage Shared Libraries
- One of the efficiencies of modern operating systems is the concept of shared libraries of system software. This Objective provides an overview of shared libraries and their configuration. Weight: 3.
- Objective 5: Use Debian Package Management.
- This topic covers the management of Debian Linux binary packages. Weight: 5.
- Objective 6: Use Red Hat Package Manager (RPM)
- This topic covers the management of RPM binary packages. Weight: 8.
Design a Hard Disk Layout
Part of the installation process for Linux is the design of the hard disk partitioning scheme. If you're used to systems that reside on a single partition, this step may seem to complicate installation. However, there are advantages to splitting the filesystem into multiple partitions, potentially on multiple disks. Details about disks, partitions, and Linux filesystem top-level directories are provided in . This Topic covers considerations for implementing Linux disk layouts.
A variety of factors influence the choice of a disk layout plan for Linux, including:
- The amount of disk space
- The size of the system
- What the system will be used for
- How and where backups will be performed
Limited disk space
Except for read-only filesystems (such as CD-ROMs or a shared /usr partition), most Linux filesystems should have some free space available. Filesystems holding user data should be maintained with a generous amount of free space to accommodate user activity. Unfortunately, if there are many filesystems and all of them contain free space, a significant portion of disk space could be considered wasted. This presents a tradeoff between the number of filesystems in use and the availability of free disk space. Finding the right configuration depends on system requirements and available disk resources.
When disk space is limited, it is desirable to reduce the number of filesystems, thereby combining free space into a single contiguous pool. For example, installing Linux on a PC with only 1 GB of available disk space might best be implemented using only a few partitions:
- 50 MB. A small /boot filesystem in the first partition ensures that all kernels are below the 1024-cylinder limit.
- 100 MB.
- 850 MB. A large root partition holds everything on the system that's not in /boot.
The /boot partition could be combined with the root partition as long as the entire root partition fits within the 1024-cylinder limit (see ").
On older systems with smaller hard drives, Linux is often installed by spreading the directory tree across multiple physical disks. This is no different in practice than using multiple partitions on a single disk and often encourages the reuse of older hardware. An additional disk might be dedicated to /home in order to allow a larger work area for the users' home directories.
On larger platforms, functional issues such as backup strategies and required filesystem sizes can dictate disk layout. For example, suppose a file server is to be constructed serving 100 GB of executable datafiles to end-users via NFS. Such as system will have enough resources to compartmentalize various parts of the directory tree into separate filesystems and might look like this:
- 50 MB. Keep kernels under the 1024-cylinder limit.
- 100 MB.
- 100 MB.
- 1 GB. All of the executables in /usr are shared to workstations via read-only NFS.
- 500 MB. By placing log files in their own partition, they won't threaten system stability if the filesystem is full.
- 100 MB. By placing temporary files in their own partition, they won't threaten system stability if the filesystem is full.
- 98 GB. This is the big filesystem, offered to users for their home directories.
On production servers, much of the system is often placed on redundant media, such as mirrored disks. Large filesystems, such as /home, may be stored on some form of disk array using a hardware controller.
The role of the system also can dictate disk layout. In a traditional Unix-style network with NFS file servers, most of the workstations won't necessarily need all of their own executable files. In the days when disk space was at a premium, this represented a significant savings in disk space. While space on workstation disks isn't the problem it once was, keeping executables on a server still eliminates the administrative headache of distributing updates to workstations.
Some backup schemes use disk partitions as the basic unit of system backup. In such a scenario, each of the filesystems listed in /etc/fstab is backed up separately, and they are arranged so that each filesystem fits within the size of the backup media. For this reason, the available backup device capabilities can play a role in determining the ultimate size of partitions.
When you install Linux, you're asked to configure a swap, or virtual memory, partition. This special disk space is used to temporarily store portions of main memory containing programs or program data that is not needed constantly, allowing more processes to execute concurrently. An old rule of thumb for Linux is to set the size of the system's swap space to be equal to the amount of physical RAM in the machine. For example, if your system has 64 MB of RAM, it would be reasonable to set your swap size to at least 64 MB. Another rule of thumb that predates Linux says swap space should equal three times the main memory size. These are just guidelines, of course, because a system's utilization of virtual memory depends on what the system does and the number and size of processes it runs. Using the size of main memory, or thereabouts, is a good starting point.
Spreading swap space across multiple disk drives can allow better swap performance because multiple accesses can occur concurrently when multiple devices are used. For even better performance, place those disks on separate controllers, increasing bandwidth. For example, you could place half of your planned swap space on each of two IDE disks in your system. Those disks could be attached to the two separate IDE interfaces.
Here are some guidelines for partitioning a Linux system:
- Keep the root filesystem ( / ) small by distributing larger portions of the directory tree to other partitions. A small root filesystem is less likely to be corrupted than a large one.
- Separate a small /boot partition below cylinder 1024 for kernels.
- Separate /var. Make certain it is big enough to handle your logs and their rotation scheme, but not so large that disk space is wasted when the rotation is filled.
- Separate /tmp. Its size depends on the demands of the applications you run. It should be large enough to handle temporary files for all of your users simultaneously.
- Separate /usr and make it big enough to accommodate kernel building. Making it standalone allows you to share it read-only via NFS.
- Separate /home for machines with multiple users. For production use, put it on a disk array subsystem.
- Set swap space around the same size as the main memory. If possible, try to split the swap space across multiple disks and controllers.
TIP: Since a disk layout is the product of both system requirements and available resources, no single example can represent the best configuration. Factors to remember include placing the kernel below cylinder 1024, ways to effectively utilize multiple disks, sizing of partitions to hold various directories such as /var and /usr, the importance of the root filesystem, and swap space size. Also remember the trick of splitting swap space across multiple physical disks to increase virtual memory performance.
While it is possible to boot Linux from a floppy disk, most Linux installations boot from the computer's hard disk.2 This is a two-step process that begins after the system BIOS is initialized and ready to run an operating system. Starting Linux consists of the following two basic phases:
- Run lilo from the boot disk
- It is Linux loader's (LILO's) job to find the selected kernel and get it loaded into memory, including any user-supplied options.
- Launch the Linux kernel and start processes
- LILO starts the loaded kernel. LILO's job at this point is complete and the hardware is placed under the control of the running kernel, which sets up shop and begins running processes.
The Linux Loader (LILO) is a small utility designed to load the Linux kernel (or the boot sector of another operating system) into memory and start it. A program that performs this function is commonly called a boot loader. While other boot loaders exist, LILO is the most popular and is installed as the default boot loader on most Linux distributions. LILO consists of two parts...