Выбрать главу

8.8.4. GRUB Legacy Configuration

Version 1 of GRUB can also read filesystems. It is installed using the grub-install /dev/sda command.

NOTE Disk names for GRUB Legacy

GRUB Legacy uses the same system for naming disks as GRUB 2, and the same /boot/grub/device.map file. On the other hand, it names partitions a little differently: the first partition on the first disk is labeled (hd0,0), the second (hd0,1), etc.

GRUB's configuration is in the /boot/grub/menu.lst file (see example).

Example 8.4. GRUB configuration file

# Boot automatically after 30 seconds

timeout 30

# Boot first entry by default

default 0

# If that fails, try the second

fallback 1

# Last kernel installed

title GNU/Linux

root (hd0,1)

kernel /vmlinuz root=/dev/sda2

initrd /initrd.img

# Old kernel (if the most recent doesn't boot)

title GNU/Linux OLD

root (hd0,1)

kernel /vmlinuz.old root=/dev/sda2

initrd /initrd.img.old

# Only for dual boot, Linux/Windows

title Microsoft Windows

rootnoverify (hd0,0)

makeactive

chainloader +1

8.8.5. For Macintosh Computers (PowerPC): Configuring Yaboot

Yaboot is the bootloader used by old Macintosh computers using PowerPC processors. They do not boot like PCs, but rely on a “bootstrap” partition, from which the BIOS (or OpenFirmware) executes the loader, and on which the ybin program installs yaboot and its configuration file. You will only need to run this command again if the /etc/yaboot.conf is modified (it is duplicated on the bootstrap partition, and yaboot knows how to find the position of the kernels on the disks).

Before executing ybin, you must first have a valid /etc/yaboot.conf. The following is an example of a minimal configuration.

Example 8.5. Yaboot configuration file

# bootstrap partition

boot=/dev/sda2

# the disk

device=hd:

# the Linux partition

partition=3

root=/dev/sda3

# boot after 3 seconds of inactivity

# (timeout is in tenths of seconds)

timeout=30

install=/usr/lib/yaboot/yaboot

magicboot=/usr/lib/yaboot/ofboot

enablecdboot

# last kernel installed

image=/vmlinux

        label=linux

        initrd=/initrd.img

        read-only

# old kernel

image=/vmlinux.old

        label=old

        initrd=/initrd.img.old

        read-only

# only for Linux/Mac OSX dual-boot

macosx=/dev/sda5

# bsd=/dev/sdaX and macos=/dev/sdaX

# are also possible

8.9. Other Configurations: Time Synchronization, Logs, Sharing Access...

The many elements listed in this section are good to know for anyone who wants to master all aspects of configuration of the GNU/Linux system. They are, however, treated briefly and frequently refer to the documentation.

8.9.1. Timezone

BACK TO BASICS Symbolic links

A symbolic link is a pointer to another file. When you access it, the file to which it points is opened. Removal of the link will not cause deletion of the file to which it points. Likewise, it does not have its own set of permissions, but rather retains the permissions of its target. Finally, it can point to any type of file: directories, special files (sockets, named pipes, device files, etc.), even other symbolic links.

The ln -s target link-name command creates a symbolic link, named link-name, pointing to target.

If the target does not exist, then the link is “broken” and accessing it will result in an error indicating that the target file does not exist. If the link points to another link, you will have a “chain” of links that turns into a “cycle” if one of the targets points to one of its predecessors. In this case, accessing one of the links in the cycle will result in a specific error (“too many levels of symbolic links”); this means the kernel gave up after several rounds of the cycle.

The timezone, configured during initial installation, is a configuration item for the tzdata package. To modify it, use the dpkg-reconfigure tzdata command, which allows you to choose the timezone to be used in an interactive manner (until lenny, the command to use was tzconfig). Its configuration is stored in the /etc/timezone file. Additionally, the corresponding file in the /usr/share/zoneinfo directory is copied in /etc/localtime; this file contains the rules governing the dates where daylight saving time is active, for countries that use it.

When you need to temporarily change the timezone, use the TZ environment variable, which takes priority over the configured system default:

date

Wed Mar 28 15:51:19 CEST 2012

TZ="Pacific/Honolulu" date

Wed Mar 28 03:51:21 HST 2012

NOTE System clock, hardware clock

There are two time sources in a computer. A computer's motherboard has a hardware clock, called the “CMOS clock”. This clock is not very precise, and provides rather slow access times. The operating system kernel has its own, the software clock, which it keeps up to date with its own means (possibly with the help of time servers, see the “Time Synchronization” section). This system clock is generally more accurate, especially since it doesn't need access to hardware variables. However, since it only exists in live memory, it is zeroed out every time the machine is booted, contrary to the CMOS clock, which has a battery and therefores “survives” rebooting or halting of the machine. The system clock is, thus, set from the CMOS clock during boot, and the CMOS clock is updated on shutdown (to take into account possible changes or corrections if it has been improperly adjusted).

In practice, there is a problem, since the CMOS clock is nothing more than a counter and contains no information regarding the time zone. There is a choice to make regarding its interpretation: either the system considers it runs in universal time (UTC, formerly GMT), or in local time. This choice could be a simple shift, but things are actually more complicated: as a result of daylight saving time, this offset is not constant. The result is that the system has no way to determine whether the offset is correct, especially around periods of time change. Since it is always possible to reconstruct local time from universal time and the timezone information, we strongly recommend using the CMOS clock in universal time.

Unfortunately, Windows systems in their default configuration ignore this recommendation; they keep the CMOS clock on local time, applying time changes when booting the computer by trying to guess during time changes if the change has already been applied or not. This works relatively well, as long as the system has only Windows running on it. But when a computer has several systems (whether it be a “dual-boot” configuration or running other systems via virtual machine), chaos ensues, with no means to determine if the time is correct. If you absolutely must retain Windows on a computer, you should either configure it to keep the CMOS clock as UTC, or deactivate UTC in the /etc/default/rcS file on the Debian system (and make sure to manually check your clock in spring and autumn).