System Boot Setup

System Bootup

A Linux system installed on a hard drive is loaded by a special loader program. In ALT Linux 2.3 Compact two standard Linux loaders are available: LILO and GRUB. The loader program is executed when the system is booted from the hard drive. It loads the Linux OS kernel, also located on the hard drive.

LILO may also be used at the first stage of bootup for multiple systems, allowing to choose an OS (for instance, Windows or Linux), which should be loaded at the moment. LILO automatically loads the operating system that is specified as default. Different boot options for Linux are also possible.

For instance, as a result of a standard installation, three alternatives are available in the initial ALT Linux 2.3 Compact loader menu: ALT Linux, ALT Linux — Safe Settings (bootup with a minimal set of drivers, which may be necessary in case of problems), Boot From Floppy. If you have a Compact installation CD, you may also boot up from it: aside from installing a new system, it allows to load a Linux system already installed on a hard drive, which for some reason cannot be loaded directly.

The lower part of the screen of the bootloader menu in ALT Linux 2.3 Compact contains the “boot options” area. In this field, you can specify parameters, which will be passed over to the Linux kernel during bootup. For more information on possible parameters, see bootparam(7).

Immediately after the Linux system is loaded and its kernel mounts the root filesystem, it executes the first program, init. This program is responsible for launching system start scripts and for changing the system state from bootup to regular multi-user. It also invokes other startup and finishing procedures.

To be brief, the init program consequently passes through runlevels. The program starts up at runlevel 1 directly after system bootup. Runlevels 2 and 3 are regular multi-user system modes, runlevel 4 loads X Window System using the xdm (X display manager), runlevel 6 reboots the system. Each runlevel has a corresponding directory /etc/rc.d/rcN.d, where N is the runlevel number. These directories store symbolic links pointing to those start scripts that should be run when a certain runlevel is entered. Start scripts are designed to launch, stop and restart system services. All scripts are actually located in the /etc/init.d directory.

Any service which has placed its start script into /etc/init.d/ may be started and stopped by hand by executing the script with start or stop parameters correspondingly. To check service status (started, stopped or failed) the same script may be run with the parameter status. The same is done by the service command: it calls the script (the name of which should be passed to it as the first parameter) from /etc/init.d/ and runs it. Thus, in order to restart httpd service, any of the following commands may be used: /etc/init.d/httpd restart or service httpd restart.

Registration of start scripts on various runlevels is quite similar. If you want to start the httpd service when the third (network) level is entered, you must organize a symbolic link to /etc/rc.d/httpd in /etc/rc3.d/. This link should have the name S<number>httpd in order to be started at the right time. If you do not want httpd to start at this level, the link must have the name K<number>httpd. Creation and removal of such links, as well as display of their current state is achieved by the chkconfig command. Its most important keys are --list (to view the list of registered services), on (to enable launching of a particular service for a certain runlevel) and off (to deny the service for a runlevel).

System bootup ends when the init program launches several copies of the getty program, which calls the login: prompt for all virtual consoles.

After that, the init program enters background mode; it continues to monitor the system state and modifies it if necessary. The init program functions are defined in the /etc/inittab file.

Booting Several Operating Systems

First of all it should be noted that the Linux operating system may be loaded from any hard drive and from any partition type: primary or logical, from various filesystems (for instance, Ext2, Ext3, ReiserFS). The partition that contains the root filesystem does not necessarily have to be active (that is, have status A in the partition table). Moreover, you may continue to use the loader that you are using now, given that it is capable of passing control over to the boot sector of any partition (for instance, OS/2 Boot Manager, System Commander, WinNT Boot Loader). If any other loader is present, the Linux loader should be installed into the boot sector of the Linux system root partition, rather than the MBR sector of the primary hard drive of the system. Control should then be passed to the boot sector of the root partition of the Linux system by the external loader. The vast majority of UNIX-like systems, as well as OS/2, are not sensitive to their exact installation location, as long as there is a way to pass control over to their initial bootloaders.

When the LILO loader, supplied with the distribution, is used, control can be seamlessly handed over to a boot sector of any partition physically accessible at the moment of bootup. However, the architectural specifics of most DOS-based Microsoft Windows systems is such that, even if they are physically installed on different disks and partitions, they are still loaded from one partition (C:), and this partition needs to be an active primary partition on the first hard drive of the system. Otherwise, the most unexpected problems with loading Microsoft Windows are possible. When Microsoft Windows is installed, this configuration of partitions is set up automatically. This is why we do not recommend enforcing a different configuration - it is better to preserve the status of Microsoft Windows boot sector fully.

When Compact is installed, you have an opportunity to change sizes of existing partitions without any loss of data (see the section on “Disk Partitioning and Choosing Mount Points” in the “System Installation” chapter). In particular, there is a very useful option, which allows to scale FAT16 and FAT32 partitions without losing data. However, it is necessary to remember that the procedure of changing partition size is potentially dangerous in terms of data loss: an electric power surge or errors in the filesystem that were not corrected in advance may lead to complete loss of data on the partition!

Warning

It is strongly recommended to check the integrity of filesystems using Microsoft Windows tools before conducting this procedure, to correct all errors and perform a full defragmentation of the filesystems, and to back up all valuable data.

Note that scaling of NTFS and HPFS filesystems is possible only with complete loss of data on these partitions!

If you have chosen the default installation class, the following will happen:

When beginning the “Setup Filesystems” stage, the installer will automatically analyze the contents of accessible hard drives and, depending on the result, will offer the following options:

If the entire volume of the hard drive is occupied by partitions of other operating systems, but existing filesystems are suitable for installation of Linux (FAT16, FAT32), then the installer will suggest the following:

«Delete Windows»

All partitions will be deleted and replaced by Linux partitions, created and formatted automatically.

«Use Free Space on Windows Partition»

The installer will offer to change the size of the Microsoft Windows partition using the free space available on it. It is possible to directly specify the size of the partition to be left for use by Microsoft Windows. After changing partition size the installer will automatically create and format partitions needed by Linux.

«Custom Disk Partitioning»

The program will offer the “Direct Hard Drive Partition Management Interface”.

If partitions belonging to various operating systems, including Linux, are found on the hard drive, then it is possible to choose from the following set of alternatives:

«Use Existing Partition»

It will be suggested to format an already existing Linux partition. If you agree, the installer will proceed to the choice of packages for installation. If you refuse, it will offer the “Direct Hard Drive Partition Management Interface”.

«Erase Entire Disk»

All partitions will be deleted and replaced by automatically created and formatted Linux partitions.

«Use Free Space on Windows Partition»

The program will suggest to change the size of the Microsoft Windows partition using the free space available on it. It is possible to directly specify what size of partition should be left for use by Microsoft Windows. After changing partition size the installer will automatically create and format partitions needed by Linux.

«Custom Disk Partitioning»

The program will offer the “Direct Hard Drive Partition Management Interface”.

If the entire disk space is occupied by partitions on which Linux cannot be installed, and the size of which cannot be changed without data loss, (for instance, NTFS partitions belonging to Windows NT/2000/XP operating systems), then two alternatives will be offered:

«Erase Entire Disk»

All partitions will be deleted and replaced by automatically created and formatted Linux partitions.

«Custom Disk Partitioning»

The program will offer the “Direct Hard Drive Partition Management Interface”.

If the “Expert” installation class is chosen, the following happens:

The installer will not analyze hard drives in this case. Instead, it will offer the “Direct Hard Drive Partition Management Interface” right away (see the section on Direct Hard Drive Partition Management in the “System Installation” chapter).

Bootloader Setup

First of all, it is necessary to clearly decide where exactly the loader will be placed, in cases of both GRUB or LILO.

If all operating systems are going to be loaded with one of the loaders suggested by the installer, then the first disk of the system should be chosen in the «Boot Device» field: this is usually /dev/hda or /dev/sda. With this option chosen, the loader will be placed into the MBR sector of the hard drive and will be the first one to receive control from BIOS. In order to be able to load different operating systems, it is sufficient to enter information about their presence in the bootloader configuration files. When Linux is installed in addition to existing Microsoft Windows systems, the installation program automatically searches for their boot sectors and enters data about them into the bootloader configuration.

Later, if more partitions with new operating systems are added, they can be easily included into the bootloader configuration manually. For instance, for LILO the following should be done: a new OS description section should be added to /etc/lilo.conf file similar to the following record:

other=/dev/hda1 
label=windows
table=/dev/hda
  

The record tells LILO that an unknown operating system is installed in the /dev/hda1 partition, that it should be displayed as “windows” in the menu, that if this menu item is chosen by the user, control should be passed to the /dev/hda1 boot sector.

After this configuration file is saved, the following command should be issued:

    # lilo
  

for changes to become effective.

Addition of new records to GRUB is different in comparison to LILO. For instance, to make an analogous addition to the GRUB configuration file (/boot/grub/menu.lst) is is necessary to add the following record:

title Windows
  rootnoverify (hd0,0)
  chainloader +1

If some other software is used to bootload operating systems, then the Linux loader must be installed in the boot sector of the root partition, onto which the Linux operating system has just been installed. For instance, if the root partition (mounted as /) is located on /dev/hdb8, then /dev/hdb8 should be written to the «Boot Device» field. General rule: if the device is specified as the “whole” hard drive (without specifying the partition number, for instance, /dev/hda), then the loader will be installed in the MBR partition of the specified disk; if the device is specified as a disk partition (with a partition number in the end), then the loader will be installed into the boot sector of the corresponding partition. After the Linux bootloader is installed, it is necessary to inform the common loader of all operating systems about the presence of a new partition and about the necessity of passing control over to it. The way to do it should be described in the documentation to the boootloader software you are using.

Theoretically, it is possible to have six or more operating systems on the same computer. For instance, Windows 98, NT4, two OS/2 and two Linux can live on the same hard drive perfectly well given that each operating system is given its own partition. The issue is really how many partitions are allowed on the same hard drive and what the overall capacity of this hard drive is.

If Linux is installed on top of or together with existing Microsoft Windows systems, everything usually goes flawlessly, and right after the installation it is possible to load any of the available operating systems. But if Linux is installed first (with space reserved for Windows partitions and the loader allocated in the MBR, as it should be), and after that some version of Windows, then problems with subsequent loading of Linux are highly likely. The problem is that the majority of Windows versions rewrite the contents of the MBR of the boot hard drive without even issuing a warning, deleting existing content and writing the Windows loader in its place, which does not want to know anything about Linux or most other non-Windows operating systems. Fortunately, it is easy enough to solve this problem: prior to installing Windows it is necessary to make a Linux boot floppy:

 
      # mkbootdisk `uname -r` 

Please note that backticks are used. It is also possible to use a rescue disk, created during the installation of Linux. After Windows is installed or reinstalled, which makes it impossible to load Linux, it is necessary to boot from a Linux boot disk, to inform the loader about the addition of a new operating system (as described earlier), and to recover the Linux loader with the following command:

# lilo

In order to have two or more Linux OS'es installed and working on the same computer, it is desirable to follow these recommendations:

  1. You should have a common swap partition for all Linux OS'es, because they will take turns in using it. This will allow you to save some disk space.

  2. You should either use one independent loader, and install loaders for each copy of Linux into the first sectors of root partitions, or have a common allocated /boot sector, mounted into the root partitions, and one common loader, located in MBR. The size of this sector may be quite small, around 20-30 MB. Usually one hard drive cylinder is allocated for it. In these conditions, no problems arise when you update kernels of both copies of Linux, and the configuration of the common loader is flexible enough.