Опубликован: 06.08.2012 | Доступ: свободный | Студентов: 1189 / 25 | Оценка: 5.00 / 5.00 | Длительность: 53:41:00
Лекция 29:

Starting and stopping the system

< Лекция 28 || Лекция 29: 12345 || Лекция 30 >

Loader commands

There are two ways to communicate with the loader:

  • A number of files in the directory /boot on the root file system tell the loader what to do. Most are not intended to be changed, but you can create a file called /boot/loader.conf, into which you can enter commands to override the commands in /boot/defaults/loader.conf. We'll look at this below.
  • In addition, the file /boot/device.hints takes the place of many configuration file entries and allows you to set hardware characteristics such as information about IRQ, DMA, I/O address and other settings for the hardware. You can change these values during booting.

The CD-ROM installation installs /boot/device.hints, but a kernel install does not. You'll find it in the conf directory for your architecture. For example, /usr/src/sys/i386/conf includes the configuration file GENERIC and the corresponding hints file GENERIC.hints. Install it like this:

# cp /usr/src/sys/i386/conf/GENERIC.hints /boot/device.hints

The hints file contains entries of the following nature:

hint.sio.0.at="isa" 
hint.sio.0.port="0x3F8" 
hint.sio.0.flags="0x10" 
hint.sio.0.irq="4"
hint.sio.1.at="isa" 
hint.sio.1.port="0x2F8"
hint.sio.1.irq="3" 
hint.sio.2.at="isa"
hint.sio.2.d±sabled="1"
hint.sio.2.port="0x3E8"
hint.sio.2.irq="5"
hint.sio.3.at="isa"
hint.sio.3.disabled="1"
hint.sio.3.port="0x2E8"
hint.sio.3.irq="9"

These entries describe the serial port configuration. They replace the older method of hard coding the information in the kernel. For example, the hints above contain the configuration information contained in these lines of the Release 4 configuration file:

Device    sio0   at isa?    port IO_CCM1 flags 0x10 irq 4
Device    sio1   at isa?    port IO_CCM2 irq 3
Device    sio2   at isa?    disable port IC_CCM3 irq 5
Device    sio3   at isa?    disable port IC_CCM4 irq 9

The corresponding line in the Release 5 configuration file is:

Device    sio    #8250, 16[45]50 based serial ports

More importantly, though, this means that you don't need to recompile the kernel if you change the hardware addresses.

  • You can enter commands directly to the command prompt.

When you hit the space bar, you get the following prompt:

Type '?' for a list of commands, 'help' for more detailed help,
ok ?
Available commands:
  Reboot      reboot the system
  Heap        show heap usage
  Bcachestat  get disk block cache stats
  Boot        boot a file or loaded kernel
  Autoboot    boot automatically after a delay
  Help        detailed help
  ?           list commands
  Show        show variable(s)
  Set         set avariable
  Unset       unset avariable
  More        show contents of a file
  Lsdev       list all devices
  Include     read commands from a file
  Ls          list files
  Load        load akernel or module
  Unload      unload all modules
  Lsmod       list loaded modules
  Pnpscan     scan for PnP devices

The most important of these commands are set, show, load, unload and boot. We'll see some examples of their use in the following sections. Note, however, that if you have accidentally hit the "any" key during boot and just want to continue with the boot, you just have to enter boot.

loader.conf

Much of the behaviour of the loader is controlled by entries in /boot/defaults/loader.conf. You shouldn't change this file, though: put changes in a file /boot/loader.conf, which may not exist. There are a large number of possible entries; in /boot/defaults/loader.conf you'll see the default values, frequently commented out because the loader already knows the defaults. Here are some of the more interesting ones:

kernel="kernel"
verbose_loading="NO"     # Set to YES for verbose loader output
#autoboot_delay="10"     # Delay in seconds before autobooting
#console="vidconsole"    # Set the current console
#currdev="disk1s1a"      # Set the current device
module_path="/boot/kernel;/boot/modules;/modules"  #Set the module search path
#prompt="\${interpret}"  # Set the command prompt
#root_disk_unit="0"      # Force the root disk unit number
#rootdev="disk1s1a"      # Set the root filesystem
  • The kernel entry gives the name of the kernel, relative to the kernel directory /boot/kernel. Sometimes it might be of interest to change this value, for example when testing.
  • console=vidconsole tells the loader where to output its messages. vidconsole is short for video console; you can also select comconsole if you have a serial terminal connected to a specified serial port.
  • currdev specifies where to look for the root file system. If you have multiple BIOS partitions on a disk, you can select the correct one with this value.

There are many more options to the loader; read the man page for more details.

Loading other modules at boot time

By default, loader loads only the kernel. That may not be what you want. You might want to load a different kernel, or you may want to load a kld as well.

There are two ways to do this. If you only want to do this once, you can interrupt the boot sequence by pressing the space bar, and tell loader what to do:

Booting [kernel] in 6 seconds...     this counts down from 10 seconds
(space bar hit)
Type '?' for a list of commands, 'help' for more detailed help.
ok unload                            not the kernel we wanted
OK load /boot/kernel.old/kernel      load the old kernel
/boot/kernel.old/kernel text=0x3e474c data=0x52f00+0x81904 syms=[0x4+0x4cab0+0x4+0x5
b458]
OK load /boot/kernel.old/vinum.ko    and the old vinum module
/boot/kernel.old/vinum.ko text=0x149a4 data=0xaf75c+0x164 syms=[0x4+0x11e0+0x4+0xcac]
ok boot                              then start the kernel
Copyright (c) 1992-2002 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
    The Regents of the University of California. All rights reserved.
FreeBSD 5.0-RELEASE #0: Sat 15 Feb 16:30:26 CST 2003
    grog@monorchid.example.org:/usr/src/sys/i386/compile/BUMBLE
Preloaded elf kernel "/boot/kernel.old/kernel" at 0xc072a000.
Preloaded elf module "/boot/kernel.old/vinum.ko" at 0xc072a0bc.
Timecounter "i8254" frequency 1193182 Hz
(etc)

This example shows two separate activities: one is changing the kernel from /boot/kernel/kernel to /boot/kernel.old/kernel, and the other is loading the vinum kld. You don't need to reload the kernel to load the vinum module.

Automatic kld load

The method described above is cumbersome if you want to load the kld every time you boot. In this case, it's easier to add the following line to /boot/loader. conf:

vinum_load="YES"

To see what commands you can use, look in /boot/defaults/loader.conf, where you would find all normal configuration entries commented out.

…
ccd_load="NO"    # Concatenated disk driver
vinum_load="NO"  # Concatenated/mirror/raid driver
md_load="NO"     # Memory disk driver (vnode/swap/malloc)
…

Don't change this file; it's designed to be replaced on upgrade, and any changes would get lost when you upgrade.

< Лекция 28 || Лекция 29: 12345 || Лекция 30 >
Владимир Шишкин
Владимир Шишкин
Россия, Киров
Олег Страхов
Олег Страхов
Россия