Опубликован: 06.08.2012 | Уровень: специалист | Доступ: платный
Лекция 29:

Starting and stopping the system

< Лекция 28 || Лекция 29: 12345 || Лекция 30 >
Аннотация: Starting the system; Things you can do before booting; What are you going to boot?; Running the kernel; Single-user mode; Shutting down and rebooting the system; FreeBSD without disks.
Ключевые слова: CAN, scroll, off, screen, AND, prompt, login, this, chapter, look, power up, system, Actions, running, bootstrapping, story, SEQUENCE, PC, architecture, system firmware, firmware, SRM, performance testing, master boot record, boot manager, spawn, virtual disk, swap space, system integrator, boot, boot loader, characteristic, if, multiplication operator, choose, ONE, example, First, stage, LIKE, load, FROM, default, partition, function, GET, Menu, second, disk, with, return, bootstrap loader, SEE, Character, end, previous, Line, back, NEXT, ITS, point, continue, waiting, change, software, hardware, CASE, space, BAR, enter, loader, serial port, recompilation, hardware address, behaviour, boot sequence, step, kernel, Command, output, dual, processor, motherboard, board, IDE, scsi host adapter, control, intensive, text, MOST, TIME, machine operation, message buffer, retrieve, course, fill, able, find, startup, content, NOT, shutdown, even, power, summary, information, ALL, configuration, IDEA, confirm, correct, read, WHERE, release number, Basic, counter, CPU, reliable, real memory, size, RAM, real mode, available, memory, DUE, BIOS, incompatible, build, custom, memory size, DESCRIPTION, PARAMETER, Verbose, fact, multiprocessor, I/O, used, SMP, reassign, interrupt request, debug, subsystem, release, class, usage, chipset, support, PCI, separate, Plug-in, FAR, adapter, IRQ, ID, parity, problem, POST, host adapter, Ethernet, PHY, interface, additional, legacy, ISA, driver, failure, floppy drive, Unix, device number, AS, system testing, APIC, cause, finally, root, Swap, still, probing, shell script, shut down, perform, CHECK, while, hour, very, long, terminate, background, new, feature, network, firewall, routing, period, core dump, save, fail, dump, overwrite, pass, choice, exception, internal database, Last, specified, walk-through, USER, set, boot time, device, shell, read-only, reason, damage, require, repair, Write, mount, UPDATE, option, leave, single-user, mode, concept, controlled, init, level, networking, integral, part, syntax, section, insecure, sophisticated, performance, Data, WAITS, magnitude, result, system structure, quote, MAN, automated, procedure, shutting, hacker, useful, turn off, capacity, unreliable, hardware failure, sweet spot, disk space, Replace, else, flash, floppy disk, cd-rom drive, remote, VIA, replacement, strategy, original, SUN, NFS, net, private, create, PROM, network card, PXE, method, SAW, setup, system initialization, daemon, CD-ROM, theoretical, alternative, difference, significant, implication, system administration, transfer, security, block, setting up, remote system, local disk, diskless workstation, relevant, deliver, concession, symbolic link, current supply, boot rom, boot disk, EPROM, absolute path, gotcha, provisioning, swap file, attraction, system file, changeability, shared resource, system software, Local, substitute, stand-alone

Before you can run FreeBSD, you need to start it up. That's normally pretty straightforward: you turn the machine on, a lot of things scroll off the screen, and about a minute later you have a login: prompt or an X login window on the screen. Sometimes, though, the process is of more interest. You have a number of options when booting, and it's also a source of a number of problems, so it pays to understand it. In this chapter we'll look at the following topics:

  • In the next section, we'll look at the startup process in more detail.
  • On page 529 we'll look at how to control the boot process.
  • If something goes wrong, and the system doesn't come up, those messages that scrolled off the screen are very important. We'll look at what they mean on page 529.
  • It's not so obvious that you need to adhere to a procedure when shutting down the system. We'll look at the hows and whys on page 541.
  • There are a number of ways of starting the system for particular applications. On page 542 we'll look at how to run FreeBSD without a disk.

Starting the system

When you power up the system, or when you reboot, a number of actions occur before the system is up and running. Starting the system is usually called "bootstrapping, " after the story of Baron von Munchhausen pulling himself up by his own bootstraps. The following sequence describes the sequence on the PC architecture, but there are only relatively minor differences on other platforms.

  • First, the BIOS1More accurately, the system firmware. The firmware is called BIOS (Basic Input/Output System ) on the i386 architecture, SRM on the Alpha architecture, and Open Firmware on a number of other architectures performs tests that check that the machine is working correctly and determines the hardware configuration. This Power On Self Test or POST has nothing to do with FreeBSD.
  • Next, the BIOS bootstrap loads the Master Boot Record from the first sector of the first disk on the system (C: in BIOS parlance) into memory and executes it. This step is the same for all operating systems on PCs.
  • It's up to this bootstrap to decide which operating system to boot. The bootstrap in the MBR may or may not be part of the FreeBSD system. FreeBSD can install two different MBRs, as we saw on page 66. The standard MBR works without intervention, while the boot manager gives you the choice of booting from any partition on the disk.
  • The FreeBSD bootstrap first loads the second-level bootstrap, BTX, from the next 15 sectors on disk and executes it.
  • The second-level boot locates the third-level bootstrap, called loader, and loads it into memory. loader is an intelligent bootstrap component that allows preloading of multiple kernel components. See the man page loader (8) for more information. By default, loader locates the kernel, the file /boot/kernel/kernel on the root file system, and loads it into memory. You can interrupt the loader at this point, for example to load different or additional files.
  • The kernel performs its own tests to look for hardware it knows about. It's quite verbose about this, and prints messages about both the hardware it finds and the hardware it doesn't find. This operation is called probing. Most kernels are built to recognize a large selection of hardware, so it's normal to have more "not found" messages than "found" messages.
  • After the probe, the kernel starts two processes. The first, process 0, is the swapper and is responsible for emergency clearing of memory when the standard virtual memory algorithms aren't fast enough.
  • Process 1 is called init. As the name suggests, it is responsible for starting up the system and daemons. When coming up in the default multi-user mode, it spawns a shell to execute the shell script /etc/rc.
  • /etc/rc first reads in the description files /etc/defaults/rc.conf, which contains defaults for a number of configuration variables, and /etc/rc.co/, which contains your modifications to the defaults. It then proceeds to perform the steps necessary to bring up the system, first starting virtual disk drivers, mounting swap space and checking the file system integrity if necessary.
  • When /etc/rc exits, init reads the file /etc/ttys and starts processes as determined there. It spends the rest of its life looking after these processes.

Things you can do before booting

You can do a number of things before you boot the system:

  • The most obvious thing to do is to decide what you're going to boot. The boot loader gives you the chance to load different operating systems or different FreeBSD kernels and modules. We'll look at that below.
  • You can also set a number of options for the kernel loader, including specification of hardware and software characteristics. We'll look at that on page 532.

What are you going to boot?

If you have multiple operating systems on your system, you can use the boot manager described on page 64, to choose which one to boot. For example, if you have two disks, the first of which contains four partitions, the first stage of the boot looks something like this:

F1: FreeBSD
F2: Windows
F3: Linux
F4: FreeBSD
F5: Drive 1
Default: F

After 10 seconds, the boot manager attempts to load the bootstrap from the default partition; you can choose any of the selections by pressing the corresponding function key. If you press F5, you get a menu showing the partitions on the second disk, with F5 to return to the first disk.

If you choose to boot FreeBSD, the bootstrap loaders load, and you see something like:

/                                     this is a "twirling baton"
BTX loader 1.00 BTX version is 1.01
BIOS drive A: is disk0
BIOS drive C: is disk1
BIOS drive D: is disk1
BIOS 639kB/130048kB available memory

These messages are printed by BTX. If you're loading from disk, the / character at the end of the previous line keeps changing through -, \,and | before going back to / again, giving the impression that the character is rotating. This display, called a twirling baton, is your indication that the system hasn't crashed and burned. It's normal for it to take a few seconds before the baton starts to twirl.

Next, loader prints its prompt:

FreeBSD/i386 bootstrap loader, Revision 0.8
(grog@freebie.example.com, Thu Jun 13 13:06:03 CST 2002)
Loading /boot/defaults/loader.conf
Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [kernel] in 6 seconds...         this counts down from 10 second

At this point, you would normally continue with the boot, either by pressing the Enter key or just waiting the 10 seconds. We'll see what happens then on page 533.

Sometimes you may want to change software or hardware characteristics. In this case, you press the "any other key" (by tradition the space bar) and enter commands to the loader.

< Лекция 28 || Лекция 29: 12345 || Лекция 30 >
Бехзод Сайфуллаев
Бехзод Сайфуллаев
Узбекистан, Бухара, Бухарский институт высоких технологий, 2013
Василь Остапенко
Василь Остапенко