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:
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
C: in BIOS parlance) into memory and executes it. This step is the same for all operating systems on PCs.You can do a number of things before you boot the system:
If you have
F1: FreeBSD F2: Windows F3: Linux F4: FreeBSD F5: Drive 1 Default: F
After 10 seconds, the
If you choose to boot FreeBSD, the
/ 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
There are two ways to communicate with the loader:
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
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
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.
Much of the
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
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 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.
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
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.
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.
The next step in the boot process is to run the kernel. This is what happens by default if you do nothing at the Booting [kernel] prompt, or if you press Enter. If you have interrupted the boot process, you continue with the command:
ok boot
The following example shows the output of booting an Abit BP6 dual processor
The loader transfers control to the kernel it has preloaded. Messages from the kernel are in high-
Once it has finished loading, the kernel prints some summary information and then calls all configured drivers to examine the hardware configuration of the machine on which it is running. This is called probing for the devices. If you have time, it's a good idea to confirm that it's correct. Much of it appears so quickly that you can't read it, but once the boot is complete, you can examine it with the dmesg command. If something goes wrong, it won't scroll off the screen. The place where it stops is then of interest.
Under normal circumstances, we see something like:
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@nonorcMd.example.org:/usr/src/sys/i386/compile/BlMBLE
Preloaded elf kernel "/boot/kernel/kernel" at 0xc0663000.
Here the kernel identifies itself with information about the
Timecounter "i8254" frequency 1193182 Hz CPU: Pentium II/Pentium II Xeon/Celeron (467.73-MHz 686-class CPU) Origin = "Genuinelntel" Id = 0x665 Stepping = 5 Features=0x183fbff <FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA, CMOV,P AT,PSE36,MMX,FXSR> real memory =134217728 (128 MB) avail memory = 123465728 (117 MB)
The lines above identify the basic hardware. There is one time counter (some motherboards have two), the CPU is a Celeron, Pentium II or Xeon, and it runs at 466 MHz. This information is relatively reliable. The
On some older machines, the kernel reports only 16 MB although the system has more memory. This is due to BIOS MAXMEM parameter, which is described in the verbose configuration file /usr/src/sys/i386/conf/NOTES.
This machine is in fact a
Programming 24 pins in IOAPIC #0
IOAPIC #0 intpin 2 -< irq 0
IOAPIC #0 intpin 16 -< irq 10
IOAPIC #0 intpin 17 -< irq 9
IOAPIC #0 intpin 18 -< irq 11
FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
cpu0 (BSP): apic id: 0, version: 0x00040011, at 0xfee00000
cpu1 (AP): apic id: 1, version: 0x00040011, at 0xfee00000
io0 (APIC): apic id: 2, version: 0x00170011, at 0xfec00000
The IOAPIC is the I/O Advanced Programmable Interrupt Controller used by SMP machines only. It
Initializing GEOMetry subsystem Pentium Pro MTRR support enabled npxO: <math processor> on motherboard numeric coprocessor, on chip npx0: INT 16 interfac
The GEOMetry subsystem is a disk I/O system that was introduced in FreeBSD Release 5. This processor is a P6 class processor, so it has Memory Type Range Registers or MTRRs, which are used to optimize memory usage.
Next we look at the other chips on the
pcib0: <Intel 82443BX (440 BX) host to PCI bridge> at pcibus 0 on motherboard pci0: <PCI bus> on pcib0 agp0: <Intel 82443BX (440 BX) host to PCI bridge> mem 0xe0000000-0xe3ffffff at devic e0.0 on pci0 pcib1: <PCIBIOS PCI-PCI bridge> at device 1.0 on pci0 pci1: <PCI bus> on pcib1
This
pci1: <Matrox MGA G200 AGP graphics accelerator> at 0.0 isab0: <Intel 82371AB PCI to ISA bridge> at device 7.0 on pci0 isa0: <ISA bus> on isab0 ISA bus atapci0: <Intel PIIX4 ATA33 controller> port 0xf000-0xf00f at device 7.1 on pci0 ata0: at 0x1f0 irq 14 on atapci0 primary IDE controller ata1: at 0x170 irq 15 on atapci0 secondary IDE controller uhci0: <Intel 82371AB/EB (PIIX4) USB controller> port 0xc000-0xc01f irq 10 at device 7.2 on pci0 USB controller usb0: <Intel 82371AB/EB (PIIX4) USB controller> on uhci0 USB bus usb0: USB revision 1.0 uhub0: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1 uhub0: 2 ports with 2 removable, self powered Timecounter "PIIX" frequency 3579545 Hz pci0: <bridge, PCI-unknown> at device 7.3 (no driver attached)
The system doesn't know which devices are implemented internally in the
Next we find two Symbios
sym0: <875> port 0xc400-0xc4ff mem 0xec002000-0xec002fff, 0xec003000-0xec0030ff irq 1 0atdevice 9.0 on pci0 sym0: Symbios NVRAM, ID 7, Fast-20, SE, NO parity sym0: open drain IRQ line driver, using on-chip SRAM sym0: using LOAD/STORE-based firmware. sym0: SCAN FOR LUNS disabled for targets 0. sym1: <875> port 0xc800-0xc8ff mem 0xec001000-0xec001fff, 0xec000000-0xec0000ff irq 9 at device 13.0 on pci0 sym1: No NVRAM, ID 7, Fast-20, SE, parity checking
The first Symbios adapter is on IRQ 10. It is on ID 7, like most
dc0: <Macronix 98715AEC-C 10/100BaseTX> port 0xe000-0xe0ff mem 0xe7800000-0xe78000ff irq 11 at device 11.0 on pci0 dc0: Ethernet address: 00:80:c6:f9:a6:c8 miibus0: <MII bus> on dc0 dcphy0: <Intel 21143 NWAY media interface> on miibus0 dcphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
This is a Macronix Ethernet card with associated
After that, we return to on-board peripherals, in this case two additional IDE controllers and
atapci1: <HighPoint HPT366 ATA66 controller> port 0xd800-0xd8ff,0xd400-0xd403,0xd000 -0xd007 irq 11 at device 19.0 on pci0 ata2: at 0xd000 on atapci1 Third lDE controller atapci2: <HighPoint HPT366 ATA66 controller> port 0xe400-0xe4ff,0xe000-0xe003,0xdc00 -0xdc07 irq 11 at device 19.1 on pci0 Fourth IDE controller ata3: at 0xdc00 on atapci2 orm0: <Option RCMs> at iomem 0xc0000-0xc7fff,0xc8000-0xc87ff on isa0 fdc0: ready for input in output Floppy controller fdc0: cmd 3 failed at out byte 1 of 3
The floppy driver command failure here is caused by the lack of any
atkbdc0: <Keyboard controller (i8042)> at port 0x60,0x64 on isa0 atkbd0: <AT Keyboard> flags 0x1 irq 1 on atkbdc0 keyboard kbd0 at atkbd0 vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0 sc0: <System console> at flags 0x100 on isa0 system console sc0: VGA <16 virtual consoles, flags=0x300> sio0 at port 0x3f8-0x3ff irq 4 flags 0x10 on isa0 first serial port sio0: type 16550A it's a buffered UART sio1 at port 0x2f8-0x2ff irq 3 on isa0 second serial port sio1: type 16550A sio2 not found at 0x3e8 no moreserial I/O ports sio3 not found at 0x2e8
UNIX starts counting
ppc0: <Parallel port>at port 0x378-0x37f irq 7 on isa0 parallel port controller ppc0: Generic chipset (NIBBLE-only) in COMPATIBLE mode plip0: <PLIP network interface> on ppbus0 lpt0: <Printer> on ppbus0 line printer on parallel port lpt0: Interrupt-driven port ppi0: <Parallel I/C> on ppbus0 alternate I/O on the same port
Next, on this
APIC_IO: Testing 8254 interrupt delivery APIC_IO: routing 8254 via IOAPIC #0 intpin 2 SMP: AP CPU #1 Launched!
Finally, the system detects the disks connected to this machine:
ad0: 19574MB <WDC WD205BA> [39770/16/63] at ata0-master UDMA33 ad4: 19574MB <WDC WD205BA> [39770/16/63] at ata0-master UDMA66 Waiting 15 seconds for SCSI devices to settle (noperiph: sym0:0:-1:-1): SCSI BUS reset delivered. da0 at sym1 bus 0 target 3 lun 0 da0: <SEAGATE ST15230W SUN4.2G 0738> Fixed Direct Access SCSI-2 device da0: 20.000MB/s transfers (10.000MHz, offset 15, 16bit), Tagged Queueing Enabled da0: 4095MB (8386733 512 byte sectors: 255H 63S/T 522C) da1 at sym1 bus 0 target 0 lun 0 da1: <SEAGATE ST15230W SUN4.2G 0738> Fixed Direct Access SCSI-2 device da1: 20.000MB/s transfers (10.000MHz, offset 15, 16bit), Tagged Queueing Enabled da1: 4095MB (8386733 512 byte sectors: 255H 63S/T 522C
Here, we have four disks, one each on the first and third IDE controllers, both as master, and two on the second
Finally, the system starts Vinum and mounts the root file system and the swap partition:
Mounting root from ufs: /dev/ad0s1a vinum: loaded vinum: reading configuration from /dev/ad0s1h vinum: updating configuration from /dev/ad4s2h swapon: adding /dev/ad0s1b as swap device swapon: /dev/vinum/swap: No such file or directory Automatic reboot in progress...
At this point, the system is up and running, but it still needs to start some services. The remaining messages come from processes, not from the kernel, so they are in normal
add net default: gateway 223.147.37.5 Additional routing options: tcp extensions=NO TCP keepalive=YES. routing daemons:. Mounting NFS file systems. additional daemons: syslogd Doing additional network setup: portmap. Starting final network daemons: rwhod. setting ELF ldconfig path: /usr/lib /usr/lib/compat /usr/X11R6/lib /usr/local/lib setting a.out ldconfig path: /usr/lib/aout /usr/lib/compat/aout /usr/X11R6/lib/aout starting standard daemons: inetd cron Initial rc.i386 initialization:. rc.i386 configuring syscons: blank_time. Local package initialization:. Additional TCP options:. Tue Apr 23 13:59:05 CST 2000
At this point, the kernel has finished probing, and it transfers control to the shell script /etc/rc. From this point on the display is in normal
/dev/da0s1a: FILESYSTEM CLEAN; SKIPPING CHECKS /dev/da0s1a: clean, 6311 free (367 frags, 743 blocks, 0.9% fragmentation) /dev/da0s1e: FILESYSTEM CLEAN; SKIPPING CHECKS /dev/da0s1e: clean, 1577 files, 31178 used, 7813 free (629 frags, 898 blocks, 1.6% fr Augmentation)
If your system has crashed, however, either due to a software or hardware problem, or because it was not shut down correctly, it will perform a file system check (fsck), which can take quite a while, up to an hour on very big file systems. You'll see something like:
WARNING: / was not properly dismounted /dev/da0s1a: 6311 free (367 frags, 743 blocks, 0.9% fragmentation
On a large file system, fsck can take a long time to complete, up to several hours in extreme cases. By default, the system does not need to wait for it to terminate; the fsck continues in the background. This is a relatively new feature in FreeBSD, so you can turn it off in case you have problems with it. See page 554 for more details.
Next, /etc/rc invokes the first of three network start invocations. This one initializes the interfaces, sets the routes and starts the firewall if necessary:
Doing initial network setup: hostname.
dc0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
inet 223.147.37.81 netmask 0xffffff00 broadcast 223.147.37.255
inet6 fe80::280:c6ff:fef9:a6c8%dc0 prefixlen 64 scopeid 0x1
ether 00:80:c6:f9:a6:c8
media: autoselect (100baseTX <full-duplex>) status: active
supported media: autoselect 100baseTX <full-duplex> 100baseTX 10baseT/UTP
<full-duplex> 10baseT/UTP 100baseTX <hw-loopback> none
lo0: flags=8049<UP, LOOPBACK,RUNNING,MULTICAST> mtu 16384
inet 127.0.0.1 netmask 0xff000000
add net default: gateway 223.147.37.5
Additional routing options:.
routing daemons:.
In this example, there were no additional routing options and no routing daemons. The messages accordingly have nothing between the character: and the final period. You'll see this relatively frequently.
Next, /etc/rc mounts the network file systems, cleans up /var/run and then starts syslogd:
Mounting NFS file systems. Additional daemons: syslog
Then it checks if we have a
checking for core dump...savecore: no core dum
Saving the
Next comes the second pass of the network startup, which starts our choice of named, ntpdate, ntpd, timed, portmap, ypserv, rpc.ypxfrd, rpc.yppasswdd, ypbind, ypset, keyserv and rpc.ypupdated:
Doing additional network setup: named xntpd portmap. starting, named 8.1.2 Sun May 9 13:04:13 CST 1999 grog@freebie.example.org:/usr /obj/usr.sbin/named master zone "example.org" (IN) loaded (serial 1997010902) master zone "37.147.223.in-addr.arpa" (in) loaded (serial 1996110801) listening on [223.147.37.149].53 (ep0) listening on [127.0.0.1].53 (lo0) Forwarding source address is [0.0.0.0].1063 Ready to answer queries.
With the exception of the first line, all the messages come from named. They may come in the middle of the first line, rather than waiting for the end of the line.
Next, /etc/rc enables quotas if asked, and then runs the third network pass, which starts our choice of mountd, nfsd, rpc.lockd, rpc.statd, nfsiod, amd, rwhod and kerberos:
Starting final network daemons: mountd nfsd rpc.statd nfsiod rwhod
Now we're almost done. /etc/rc rebuilds a couple of
setting ELF ldconfig path: /usr/lib /usr/lib/compat /usr/X11R6/lib /usr/local/lib setting a.out ldconfig path: /usr/lib/aout /usr/lib/compat/aout /usr/X11R6/lib/aout /usr/local/lib/aout
Next, it starts your choice of inetd, cron, printer, sendmail and usbd:
starting standard daemons: inetd cron sendmail
The last thing that /etc/rc does is to check for other startup files. These could be in the files specified in the variable
local_startup, or in the file /etc/rc.local. In our case, there are none, so all we see is:
Local package initialization:.
Finally, we're done. /etc/rc stops, and init processes /etc/ttys, which starts getty processes on specified terminals. On the console, we see:
Mon May 13 13:52:00 CST 2002 FreeBSD (freebie.example.org) (ttyv0) Login:
At this point, we're at the beginning of Chapter 7 (page 111).
Sometimes it's inconvenient that multiple users can access the system. For example, if you're repartitioning a disk, you don't want other people -s fag at
ok boot -s
As soon as the device probes have been completed, the system startup is interrupted, and you are prompted for a shell. Only the root file system is accessible, and it is mounted read-only. The reason for this is that the file system may be -u (update) option. For example,
npx0 on motherboard npx0: INT 16 interface end of the probes (high intensity display) Enter pathname of shell or RETURN for sh: hit Enter erase ^H, kill ^U, intr ^C # fsck -y /dev/ad0s1a check the integrity of the root file system ** /dev/ad0s1a ** Last Mounted on / ** Root file system ** Phase 1 - Check Blocks and Sizes ** Phase 2 - Check Pathnames ** Phase 3 - Check Connectivity ** Phase 4 - Check Reference Counts ** Phase 5 - Check Cyl groups 1064 files, 8190 used, 6913 free (61 frags, 1713 blocks, 0.4% fragmentation) mount -u / remount root file system read/write mount /usr mount any other file systems you need
To leave
# ^D Skipping file system checks... (the rest of the boot sequenc)
System V and Linux have the concept of run levels, which are controlled by init.
Networking is such an integral part of FreeBSD that this is just not practicable. FreeBSD init now understands a syntax similar to the System V init. Table 29-1 shows the supported levels. For example, to read in the /etc/ttys file, you could enter:
# init q
| Level | Signal | Action |
|---|---|---|
| 0 | SIGUSR2 | Halt and turn the power off |
| 1 | SIGTERM | Go to |
| 6 | SIGINT | Reboot the machine |
| C | SIGTSTP | Block further logins |
| q | SIGHUP | Rescan the ttys(5) file |
You can also enter
If you run a secure environment, you could be concerned about the fact that you can start up in
secure to
#If you want to be asked for password, change "secure" to "insecure" here console none unknown off insecure
If you do this, you will be in real trouble if you forget the root password.
FreeBSD uses a number of
The result of turning power off before the data is written is equally dramatic. You may just lose the data, but if the data is information on a change in file
Never stop your machine by just turning off the power. The results could be devastating.
The correct way to shut a system down is with the shutdown command. To quote the man page shutdown(8):
Shutdown provides an automated shutdown procedure for super-users to nicely notify users when the system is shutting down, saving them from system administrators,
This command has a number of useful options:
-r option to reboot the computer. You sometimes need to do this, for example after installing a new kernel.-h option to stop the machine. This isn't the default.In the normal case, where you want to stop the machine immediately so you can turn the power off, you type:
# shutdown - h now Feb 4 12:38:36 freebie shutdown: halt by grog: Feb 4 12:38:39 freebie syslogd: exiting on signal 15 syncing disks...done The operating system has halted. Please press any key to reboot
Be sure to wait for this message before you turn off the power.
Disks are getting much cheaper and their capacity is continually increasing, so it's easy to think that there would never be a reason to want to run FreeBSD without a disk at all. Still, there are reasons:
There are a number of ways to run a system without a disk. You can replace the disk with something else, such as a flash card,
Network booting is not a new idea. It was the original reason for Sun's Network File System, which we looked at in Chapters 24 and 25. Nowadays people normally use NFS for additional shared file systems; in the case of net booting, you mount your own private NFS file system as your root file system. Clearly, the first thing you need to do is to create this file system.
Next, you need to find a way to boot the system. There are a few possibilities here:
Whichever method you use, you need to set up a network interface very early. In Chapter 17 we saw that the network setup is part of the
If you use floppy or CD-ROM, you could
The next step is to actually transfer the data. We do this with TFTP, the Trivial File Transfer Protocol. As the name suggests, TFTP is a relatively simple replacement for FTP. In particular, it knows almost nothing about security. If you use TFTP, make sure that it can't be accessed from outside your network, for example by using a firewall. The default firewall rules block TFTP.
In the following sections we'll look at the example of setting up bumble.example.org as a diskless machine.
There are a number of ways to put the files on the NFS server:
We'll look at refining this technique after the system is up and running.
You still need to build a special kernel for
#Kernel BOOTP support Options BOOTP #Use BOOTP to obtain IP address/hostname Options BOOTP_NFSROOT #NFS mount root filesystem using BOOTP info Options BOOTP_NFSV3 #Use NFS v3 to NFS mount root Options BOOTP_COMPAT #Workaround for broken bootp daemons. Options BOOTP_WIRED_TO=fxp0 #Use interface fxp0 for BOOT
Only the first two are required. If you use BOOTP_WIRED_TO, make sure that the interface name matches the
Build the kernel, as described on page 617. To install, you need to set the DESTDIR variable to specify the directory in which you want to install the kernel:
# make install DESTDIR=/src/nodisk/bumbl
Next we need to set up TFTP to
File transfer error: Image file too large for low memory.
In this case, you'll need to load a loader, such as pxeboot.
As a minor
# mkdir /tftpboot # In -s /src/nodisk/bumble/boot/kernel/kernel /tftpboot/kernel.bumble # ln -s /boot/pxeboot /tftpboot/pxeboo
We also need to ensure that we can start the TFTP daemon, ftpd. Unless you're constantly booting, there's no need to have it running constantly: just enable it in /etc/inetd.conf, which has the following entries in the distribution file:
#tftp dgram udp wait root /usr/libexec/tftpd tftpd -s /tftpboot #tftp dgram udp6 wait root /usr/libexec/tftpd tftpd -s /tftpboot
These are entries for IPv4 and IPv6 respectively. We enable tftpd by uncommenting the first line (removing the # character) and sending a HUP signal to inetd:
# killall -1 inetd send a SIGHUP
We already looked at dhcpd's configuration file /usr/local/etc/dhcpd.conf on page 302, In addition to the information we looked at there, we need to know what file to load, which system to load it from, and where the root file system is located. For our diskless system bumble we might add the text in bold to the configuration we saw on page 303:
subnet 223.147.37.0 netmask 255.255.255.0
range 223.147.37.90 223.147.37.110;
option domain-name-servers freebie.example.com, presto.example.com;
option domain-name "example.com";
option routers gw.example.com;
option subnet-mask 255.255.255.0;
option broadcast-address 223.147.37.255;
default-lease-time 86400;
max-lease-time 259200;
host sydney {
hardware ethernet 0:50:da:cf:7:35;
}
host bumble {
hardware ethernet 0:50:da:cf:17:d3;
next-server presto.example.com; only if on a different machine
filename "/tftpboot/bumble/kernel.bumble"; for direct booting
filename "/tftpboot/pxeboot"; for PXE
option root-path 223.147.37.1:/src/nodisk/bumble;
}
}
There are a few things to note here:
next-server line tells where the TFTP server is located. If it's the same as the machine running the DHCP server, you don't need this specification.filename lines.If your Ethernet card doesn't have a
#Compex RL2000 compexrl2000 ns8390 0x11f6,0x1401
This information is mainly for the build process; you just need to know the compexrl2000, which is the name of the driver.
# cd /usr/ports/net/etherboot # make all # cd work/ether*/src # cat bin/bootla.bin bin32/compexrl2000.lzrom > /dev/fd0
bin/bootla.bin is a disk
etherboot uses NFS, not TFTP. As a result, things change: you can use
host bumble {
hardware ethernet 00:80:48:e6:a0:61;
filename "/src/nodisk/bumble/boot/kernel/kernel";
fixed-address bumble.example.org;
option root-path "192.109.197.82:/src/nodisk/bumble";
}
When booting in this manner, you don't see any boot messages. The
.........................done
After that, nothing appears on the screen for quite some time. In fact, the boot is proceeding normally, and the next thing you see is a login prompt.
Setting up a diskless machine is not too difficult, but there are some
Dec 11 14:18:50 bumble sm-mta[141]: NOQUEUE: SYSERR(root): cannot flock(/var/run/ sendmail.pid, fd=6, type=2, omode=40001, euid=0): Operation not supported
One solution to this problem is to mount /var as an MD (memory) file system. This is what currently happens by default, though it's subject to change: at startup, when the system detects that it is running diskless (via the sysctl vfs.nfs.disk-less_valid), it invokes the configuration file /etc/rc.diskless1.This file in turn causes the file /etc/rc.diskless2 to be invoked later in the startup procedure. Each of these files adds an MD file system. In the course of time, this will be phased out and replaced by the traditional configuration via /etc/fstab, but at the moment this file has no
You should probably look at these files carefully: they may need some tailoring to your requirements. :
Dec 11 14:18:46 bumble savecore: 192.109.197.82:/src/nodisk/swap/bumble: No such file or directory
This, too, will change; in the meantime, it is possible to mount swap on files, even if they are NFS mounted, but not on the NFS file system itself. This means that the first of the following entries in /etc/fstab will not work, but the second will:
192.109.197.82:/src/nodisk/swap/bumble none swap sw 0 0 /src/nodisk/swap/bumble none swap sw 0 0 echunga:/src /src nfs rw 0
The reason here is the third line: /src/nodisk/swap/bumble is NFS mounted, so this is a swap-to-file situation. For this to work, you may have to add the following line at the end of your /etc/rc.diskless2:
swapon -a
This is because the standard system startup mounts swap before mounting additional NFS file systems. If you place the
In many cases, you may have a number of machines that you want to run diskless. If you have enough disk (one image for each machine), you don't have anything to worry about, but often it may be
The big problem is /etc. In particular, /etc/rc.conf contains information like the system name. One way to handle this is to have a separate /etc directory for each system. This may seem reasonable, because /etc is only about 1.5 MB in size. In fact, this implies mounting the entire root file system with the other top-level directories, and that means more like 60MB.
The other alternative to network booting is to find a local substitute for the disk. This is obviously the only alternative for a stand-alone machine. There are a number of alternatives:
Flash memory is intended mainly for reading. It is much slower to write than to read, and it can only take a certain number of write cycles before it fails. Clearly it's a candidate for read-only file systems.
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:
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
C: in BIOS parlance) into memory and executes it. This step is the same for all operating systems on PCs.You can do a number of things before you boot the system:
If you have
F1: FreeBSD F2: Windows F3: Linux F4: FreeBSD F5: Drive 1 Default: F
After 10 seconds, the
If you choose to boot FreeBSD, the
/ 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
There are two ways to communicate with the loader:
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
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
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.
Much of the
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
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 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.
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
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.
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.
The next step in the boot process is to run the kernel. This is what happens by default if you do nothing at the Booting [kernel] prompt, or if you press Enter. If you have interrupted the boot process, you continue with the command:
ok boot
The following example shows the output of booting an Abit BP6 dual processor
The loader transfers control to the kernel it has preloaded. Messages from the kernel are in high-
Once it has finished loading, the kernel prints some summary information and then calls all configured drivers to examine the hardware configuration of the machine on which it is running. This is called probing for the devices. If you have time, it's a good idea to confirm that it's correct. Much of it appears so quickly that you can't read it, but once the boot is complete, you can examine it with the dmesg command. If something goes wrong, it won't scroll off the screen. The place where it stops is then of interest.
Under normal circumstances, we see something like:
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@nonorcMd.example.org:/usr/src/sys/i386/compile/BlMBLE
Preloaded elf kernel "/boot/kernel/kernel" at 0xc0663000.
Here the kernel identifies itself with information about the
Timecounter "i8254" frequency 1193182 Hz CPU: Pentium II/Pentium II Xeon/Celeron (467.73-MHz 686-class CPU) Origin = "Genuinelntel" Id = 0x665 Stepping = 5 Features=0x183fbff <FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA, CMOV,P AT,PSE36,MMX,FXSR> real memory =134217728 (128 MB) avail memory = 123465728 (117 MB)
The lines above identify the basic hardware. There is one time counter (some motherboards have two), the CPU is a Celeron, Pentium II or Xeon, and it runs at 466 MHz. This information is relatively reliable. The
On some older machines, the kernel reports only 16 MB although the system has more memory. This is due to BIOS MAXMEM parameter, which is described in the verbose configuration file /usr/src/sys/i386/conf/NOTES.
This machine is in fact a
Programming 24 pins in IOAPIC #0
IOAPIC #0 intpin 2 -< irq 0
IOAPIC #0 intpin 16 -< irq 10
IOAPIC #0 intpin 17 -< irq 9
IOAPIC #0 intpin 18 -< irq 11
FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
cpu0 (BSP): apic id: 0, version: 0x00040011, at 0xfee00000
cpu1 (AP): apic id: 1, version: 0x00040011, at 0xfee00000
io0 (APIC): apic id: 2, version: 0x00170011, at 0xfec00000
The IOAPIC is the I/O Advanced Programmable Interrupt Controller used by SMP machines only. It
Initializing GEOMetry subsystem Pentium Pro MTRR support enabled npxO: <math processor> on motherboard numeric coprocessor, on chip npx0: INT 16 interfac
The GEOMetry subsystem is a disk I/O system that was introduced in FreeBSD Release 5. This processor is a P6 class processor, so it has Memory Type Range Registers or MTRRs, which are used to optimize memory usage.
Next we look at the other chips on the
pcib0: <Intel 82443BX (440 BX) host to PCI bridge> at pcibus 0 on motherboard pci0: <PCI bus> on pcib0 agp0: <Intel 82443BX (440 BX) host to PCI bridge> mem 0xe0000000-0xe3ffffff at devic e0.0 on pci0 pcib1: <PCIBIOS PCI-PCI bridge> at device 1.0 on pci0 pci1: <PCI bus> on pcib1
This
pci1: <Matrox MGA G200 AGP graphics accelerator> at 0.0 isab0: <Intel 82371AB PCI to ISA bridge> at device 7.0 on pci0 isa0: <ISA bus> on isab0 ISA bus atapci0: <Intel PIIX4 ATA33 controller> port 0xf000-0xf00f at device 7.1 on pci0 ata0: at 0x1f0 irq 14 on atapci0 primary IDE controller ata1: at 0x170 irq 15 on atapci0 secondary IDE controller uhci0: <Intel 82371AB/EB (PIIX4) USB controller> port 0xc000-0xc01f irq 10 at device 7.2 on pci0 USB controller usb0: <Intel 82371AB/EB (PIIX4) USB controller> on uhci0 USB bus usb0: USB revision 1.0 uhub0: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1 uhub0: 2 ports with 2 removable, self powered Timecounter "PIIX" frequency 3579545 Hz pci0: <bridge, PCI-unknown> at device 7.3 (no driver attached)
The system doesn't know which devices are implemented internally in the
Next we find two Symbios
sym0: <875> port 0xc400-0xc4ff mem 0xec002000-0xec002fff, 0xec003000-0xec0030ff irq 1 0atdevice 9.0 on pci0 sym0: Symbios NVRAM, ID 7, Fast-20, SE, NO parity sym0: open drain IRQ line driver, using on-chip SRAM sym0: using LOAD/STORE-based firmware. sym0: SCAN FOR LUNS disabled for targets 0. sym1: <875> port 0xc800-0xc8ff mem 0xec001000-0xec001fff, 0xec000000-0xec0000ff irq 9 at device 13.0 on pci0 sym1: No NVRAM, ID 7, Fast-20, SE, parity checking
The first Symbios adapter is on IRQ 10. It is on ID 7, like most
dc0: <Macronix 98715AEC-C 10/100BaseTX> port 0xe000-0xe0ff mem 0xe7800000-0xe78000ff irq 11 at device 11.0 on pci0 dc0: Ethernet address: 00:80:c6:f9:a6:c8 miibus0: <MII bus> on dc0 dcphy0: <Intel 21143 NWAY media interface> on miibus0 dcphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
This is a Macronix Ethernet card with associated
After that, we return to on-board peripherals, in this case two additional IDE controllers and
atapci1: <HighPoint HPT366 ATA66 controller> port 0xd800-0xd8ff,0xd400-0xd403,0xd000 -0xd007 irq 11 at device 19.0 on pci0 ata2: at 0xd000 on atapci1 Third lDE controller atapci2: <HighPoint HPT366 ATA66 controller> port 0xe400-0xe4ff,0xe000-0xe003,0xdc00 -0xdc07 irq 11 at device 19.1 on pci0 Fourth IDE controller ata3: at 0xdc00 on atapci2 orm0: <Option RCMs> at iomem 0xc0000-0xc7fff,0xc8000-0xc87ff on isa0 fdc0: ready for input in output Floppy controller fdc0: cmd 3 failed at out byte 1 of 3
The floppy driver command failure here is caused by the lack of any
atkbdc0: <Keyboard controller (i8042)> at port 0x60,0x64 on isa0 atkbd0: <AT Keyboard> flags 0x1 irq 1 on atkbdc0 keyboard kbd0 at atkbd0 vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0 sc0: <System console> at flags 0x100 on isa0 system console sc0: VGA <16 virtual consoles, flags=0x300> sio0 at port 0x3f8-0x3ff irq 4 flags 0x10 on isa0 first serial port sio0: type 16550A it's a buffered UART sio1 at port 0x2f8-0x2ff irq 3 on isa0 second serial port sio1: type 16550A sio2 not found at 0x3e8 no moreserial I/O ports sio3 not found at 0x2e8
UNIX starts counting
ppc0: <Parallel port>at port 0x378-0x37f irq 7 on isa0 parallel port controller ppc0: Generic chipset (NIBBLE-only) in COMPATIBLE mode plip0: <PLIP network interface> on ppbus0 lpt0: <Printer> on ppbus0 line printer on parallel port lpt0: Interrupt-driven port ppi0: <Parallel I/C> on ppbus0 alternate I/O on the same port
Next, on this
APIC_IO: Testing 8254 interrupt delivery APIC_IO: routing 8254 via IOAPIC #0 intpin 2 SMP: AP CPU #1 Launched!
Finally, the system detects the disks connected to this machine:
ad0: 19574MB <WDC WD205BA> [39770/16/63] at ata0-master UDMA33 ad4: 19574MB <WDC WD205BA> [39770/16/63] at ata0-master UDMA66 Waiting 15 seconds for SCSI devices to settle (noperiph: sym0:0:-1:-1): SCSI BUS reset delivered. da0 at sym1 bus 0 target 3 lun 0 da0: <SEAGATE ST15230W SUN4.2G 0738> Fixed Direct Access SCSI-2 device da0: 20.000MB/s transfers (10.000MHz, offset 15, 16bit), Tagged Queueing Enabled da0: 4095MB (8386733 512 byte sectors: 255H 63S/T 522C) da1 at sym1 bus 0 target 0 lun 0 da1: <SEAGATE ST15230W SUN4.2G 0738> Fixed Direct Access SCSI-2 device da1: 20.000MB/s transfers (10.000MHz, offset 15, 16bit), Tagged Queueing Enabled da1: 4095MB (8386733 512 byte sectors: 255H 63S/T 522C
Here, we have four disks, one each on the first and third IDE controllers, both as master, and two on the second
Finally, the system starts Vinum and mounts the root file system and the swap partition:
Mounting root from ufs: /dev/ad0s1a vinum: loaded vinum: reading configuration from /dev/ad0s1h vinum: updating configuration from /dev/ad4s2h swapon: adding /dev/ad0s1b as swap device swapon: /dev/vinum/swap: No such file or directory Automatic reboot in progress...
At this point, the system is up and running, but it still needs to start some services. The remaining messages come from processes, not from the kernel, so they are in normal
add net default: gateway 223.147.37.5 Additional routing options: tcp extensions=NO TCP keepalive=YES. routing daemons:. Mounting NFS file systems. additional daemons: syslogd Doing additional network setup: portmap. Starting final network daemons: rwhod. setting ELF ldconfig path: /usr/lib /usr/lib/compat /usr/X11R6/lib /usr/local/lib setting a.out ldconfig path: /usr/lib/aout /usr/lib/compat/aout /usr/X11R6/lib/aout starting standard daemons: inetd cron Initial rc.i386 initialization:. rc.i386 configuring syscons: blank_time. Local package initialization:. Additional TCP options:. Tue Apr 23 13:59:05 CST 2000
At this point, the kernel has finished probing, and it transfers control to the shell script /etc/rc. From this point on the display is in normal
/dev/da0s1a: FILESYSTEM CLEAN; SKIPPING CHECKS /dev/da0s1a: clean, 6311 free (367 frags, 743 blocks, 0.9% fragmentation) /dev/da0s1e: FILESYSTEM CLEAN; SKIPPING CHECKS /dev/da0s1e: clean, 1577 files, 31178 used, 7813 free (629 frags, 898 blocks, 1.6% fr Augmentation)
If your system has crashed, however, either due to a software or hardware problem, or because it was not shut down correctly, it will perform a file system check (fsck), which can take quite a while, up to an hour on very big file systems. You'll see something like:
WARNING: / was not properly dismounted /dev/da0s1a: 6311 free (367 frags, 743 blocks, 0.9% fragmentation
On a large file system, fsck can take a long time to complete, up to several hours in extreme cases. By default, the system does not need to wait for it to terminate; the fsck continues in the background. This is a relatively new feature in FreeBSD, so you can turn it off in case you have problems with it. See page 554 for more details.
Next, /etc/rc invokes the first of three network start invocations. This one initializes the interfaces, sets the routes and starts the firewall if necessary:
Doing initial network setup: hostname.
dc0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
inet 223.147.37.81 netmask 0xffffff00 broadcast 223.147.37.255
inet6 fe80::280:c6ff:fef9:a6c8%dc0 prefixlen 64 scopeid 0x1
ether 00:80:c6:f9:a6:c8
media: autoselect (100baseTX <full-duplex>) status: active
supported media: autoselect 100baseTX <full-duplex> 100baseTX 10baseT/UTP
<full-duplex> 10baseT/UTP 100baseTX <hw-loopback> none
lo0: flags=8049<UP, LOOPBACK,RUNNING,MULTICAST> mtu 16384
inet 127.0.0.1 netmask 0xff000000
add net default: gateway 223.147.37.5
Additional routing options:.
routing daemons:.
In this example, there were no additional routing options and no routing daemons. The messages accordingly have nothing between the character: and the final period. You'll see this relatively frequently.
Next, /etc/rc mounts the network file systems, cleans up /var/run and then starts syslogd:
Mounting NFS file systems. Additional daemons: syslog
Then it checks if we have a
checking for core dump...savecore: no core dum
Saving the
Next comes the second pass of the network startup, which starts our choice of named, ntpdate, ntpd, timed, portmap, ypserv, rpc.ypxfrd, rpc.yppasswdd, ypbind, ypset, keyserv and rpc.ypupdated:
Doing additional network setup: named xntpd portmap. starting, named 8.1.2 Sun May 9 13:04:13 CST 1999 grog@freebie.example.org:/usr /obj/usr.sbin/named master zone "example.org" (IN) loaded (serial 1997010902) master zone "37.147.223.in-addr.arpa" (in) loaded (serial 1996110801) listening on [223.147.37.149].53 (ep0) listening on [127.0.0.1].53 (lo0) Forwarding source address is [0.0.0.0].1063 Ready to answer queries.
With the exception of the first line, all the messages come from named. They may come in the middle of the first line, rather than waiting for the end of the line.
Next, /etc/rc enables quotas if asked, and then runs the third network pass, which starts our choice of mountd, nfsd, rpc.lockd, rpc.statd, nfsiod, amd, rwhod and kerberos:
Starting final network daemons: mountd nfsd rpc.statd nfsiod rwhod
Now we're almost done. /etc/rc rebuilds a couple of
setting ELF ldconfig path: /usr/lib /usr/lib/compat /usr/X11R6/lib /usr/local/lib setting a.out ldconfig path: /usr/lib/aout /usr/lib/compat/aout /usr/X11R6/lib/aout /usr/local/lib/aout
Next, it starts your choice of inetd, cron, printer, sendmail and usbd:
starting standard daemons: inetd cron sendmail
The last thing that /etc/rc does is to check for other startup files. These could be in the files specified in the variable
local_startup, or in the file /etc/rc.local. In our case, there are none, so all we see is:
Local package initialization:.
Finally, we're done. /etc/rc stops, and init processes /etc/ttys, which starts getty processes on specified terminals. On the console, we see:
Mon May 13 13:52:00 CST 2002 FreeBSD (freebie.example.org) (ttyv0) Login:
At this point, we're at the beginning of Chapter 7 (page 111).
Sometimes it's inconvenient that multiple users can access the system. For example, if you're repartitioning a disk, you don't want other people -s fag at
ok boot -s
As soon as the device probes have been completed, the system startup is interrupted, and you are prompted for a shell. Only the root file system is accessible, and it is mounted read-only. The reason for this is that the file system may be -u (update) option. For example,
npx0 on motherboard npx0: INT 16 interface end of the probes (high intensity display) Enter pathname of shell or RETURN for sh: hit Enter erase ^H, kill ^U, intr ^C # fsck -y /dev/ad0s1a check the integrity of the root file system ** /dev/ad0s1a ** Last Mounted on / ** Root file system ** Phase 1 - Check Blocks and Sizes ** Phase 2 - Check Pathnames ** Phase 3 - Check Connectivity ** Phase 4 - Check Reference Counts ** Phase 5 - Check Cyl groups 1064 files, 8190 used, 6913 free (61 frags, 1713 blocks, 0.4% fragmentation) mount -u / remount root file system read/write mount /usr mount any other file systems you need
To leave
# ^D Skipping file system checks... (the rest of the boot sequenc)
System V and Linux have the concept of run levels, which are controlled by init.
Networking is such an integral part of FreeBSD that this is just not practicable. FreeBSD init now understands a syntax similar to the System V init. Table 29-1 shows the supported levels. For example, to read in the /etc/ttys file, you could enter:
# init q
| Level | Signal | Action |
|---|---|---|
| 0 | SIGUSR2 | Halt and turn the power off |
| 1 | SIGTERM | Go to |
| 6 | SIGINT | Reboot the machine |
| C | SIGTSTP | Block further logins |
| q | SIGHUP | Rescan the ttys(5) file |
You can also enter
If you run a secure environment, you could be concerned about the fact that you can start up in
secure to
#If you want to be asked for password, change "secure" to "insecure" here console none unknown off insecure
If you do this, you will be in real trouble if you forget the root password.
FreeBSD uses a number of
The result of turning power off before the data is written is equally dramatic. You may just lose the data, but if the data is information on a change in file
Never stop your machine by just turning off the power. The results could be devastating.
The correct way to shut a system down is with the shutdown command. To quote the man page shutdown(8):
Shutdown provides an automated shutdown procedure for super-users to nicely notify users when the system is shutting down, saving them from system administrators,
This command has a number of useful options:
-r option to reboot the computer. You sometimes need to do this, for example after installing a new kernel.-h option to stop the machine. This isn't the default.In the normal case, where you want to stop the machine immediately so you can turn the power off, you type:
# shutdown - h now Feb 4 12:38:36 freebie shutdown: halt by grog: Feb 4 12:38:39 freebie syslogd: exiting on signal 15 syncing disks...done The operating system has halted. Please press any key to reboot
Be sure to wait for this message before you turn off the power.
Disks are getting much cheaper and their capacity is continually increasing, so it's easy to think that there would never be a reason to want to run FreeBSD without a disk at all. Still, there are reasons:
There are a number of ways to run a system without a disk. You can replace the disk with something else, such as a flash card,
Network booting is not a new idea. It was the original reason for Sun's Network File System, which we looked at in Chapters 24 and 25. Nowadays people normally use NFS for additional shared file systems; in the case of net booting, you mount your own private NFS file system as your root file system. Clearly, the first thing you need to do is to create this file system.
Next, you need to find a way to boot the system. There are a few possibilities here:
Whichever method you use, you need to set up a network interface very early. In Chapter 17 we saw that the network setup is part of the
If you use floppy or CD-ROM, you could
The next step is to actually transfer the data. We do this with TFTP, the Trivial File Transfer Protocol. As the name suggests, TFTP is a relatively simple replacement for FTP. In particular, it knows almost nothing about security. If you use TFTP, make sure that it can't be accessed from outside your network, for example by using a firewall. The default firewall rules block TFTP.
In the following sections we'll look at the example of setting up bumble.example.org as a diskless machine.
There are a number of ways to put the files on the NFS server:
We'll look at refining this technique after the system is up and running.
You still need to build a special kernel for
#Kernel BOOTP support Options BOOTP #Use BOOTP to obtain IP address/hostname Options BOOTP_NFSROOT #NFS mount root filesystem using BOOTP info Options BOOTP_NFSV3 #Use NFS v3 to NFS mount root Options BOOTP_COMPAT #Workaround for broken bootp daemons. Options BOOTP_WIRED_TO=fxp0 #Use interface fxp0 for BOOT
Only the first two are required. If you use BOOTP_WIRED_TO, make sure that the interface name matches the
Build the kernel, as described on page 617. To install, you need to set the DESTDIR variable to specify the directory in which you want to install the kernel:
# make install DESTDIR=/src/nodisk/bumbl
Next we need to set up TFTP to
File transfer error: Image file too large for low memory.
In this case, you'll need to load a loader, such as pxeboot.
As a minor
# mkdir /tftpboot # In -s /src/nodisk/bumble/boot/kernel/kernel /tftpboot/kernel.bumble # ln -s /boot/pxeboot /tftpboot/pxeboo
We also need to ensure that we can start the TFTP daemon, ftpd. Unless you're constantly booting, there's no need to have it running constantly: just enable it in /etc/inetd.conf, which has the following entries in the distribution file:
#tftp dgram udp wait root /usr/libexec/tftpd tftpd -s /tftpboot #tftp dgram udp6 wait root /usr/libexec/tftpd tftpd -s /tftpboot
These are entries for IPv4 and IPv6 respectively. We enable tftpd by uncommenting the first line (removing the # character) and sending a HUP signal to inetd:
# killall -1 inetd send a SIGHUP
We already looked at dhcpd's configuration file /usr/local/etc/dhcpd.conf on page 302, In addition to the information we looked at there, we need to know what file to load, which system to load it from, and where the root file system is located. For our diskless system bumble we might add the text in bold to the configuration we saw on page 303:
subnet 223.147.37.0 netmask 255.255.255.0
range 223.147.37.90 223.147.37.110;
option domain-name-servers freebie.example.com, presto.example.com;
option domain-name "example.com";
option routers gw.example.com;
option subnet-mask 255.255.255.0;
option broadcast-address 223.147.37.255;
default-lease-time 86400;
max-lease-time 259200;
host sydney {
hardware ethernet 0:50:da:cf:7:35;
}
host bumble {
hardware ethernet 0:50:da:cf:17:d3;
next-server presto.example.com; only if on a different machine
filename "/tftpboot/bumble/kernel.bumble"; for direct booting
filename "/tftpboot/pxeboot"; for PXE
option root-path 223.147.37.1:/src/nodisk/bumble;
}
}
There are a few things to note here:
next-server line tells where the TFTP server is located. If it's the same as the machine running the DHCP server, you don't need this specification.filename lines.If your Ethernet card doesn't have a
#Compex RL2000 compexrl2000 ns8390 0x11f6,0x1401
This information is mainly for the build process; you just need to know the compexrl2000, which is the name of the driver.
# cd /usr/ports/net/etherboot # make all # cd work/ether*/src # cat bin/bootla.bin bin32/compexrl2000.lzrom > /dev/fd0
bin/bootla.bin is a disk
etherboot uses NFS, not TFTP. As a result, things change: you can use
host bumble {
hardware ethernet 00:80:48:e6:a0:61;
filename "/src/nodisk/bumble/boot/kernel/kernel";
fixed-address bumble.example.org;
option root-path "192.109.197.82:/src/nodisk/bumble";
}
When booting in this manner, you don't see any boot messages. The
.........................done
After that, nothing appears on the screen for quite some time. In fact, the boot is proceeding normally, and the next thing you see is a login prompt.
Setting up a diskless machine is not too difficult, but there are some
Dec 11 14:18:50 bumble sm-mta[141]: NOQUEUE: SYSERR(root): cannot flock(/var/run/ sendmail.pid, fd=6, type=2, omode=40001, euid=0): Operation not supported
One solution to this problem is to mount /var as an MD (memory) file system. This is what currently happens by default, though it's subject to change: at startup, when the system detects that it is running diskless (via the sysctl vfs.nfs.disk-less_valid), it invokes the configuration file /etc/rc.diskless1.This file in turn causes the file /etc/rc.diskless2 to be invoked later in the startup procedure. Each of these files adds an MD file system. In the course of time, this will be phased out and replaced by the traditional configuration via /etc/fstab, but at the moment this file has no
You should probably look at these files carefully: they may need some tailoring to your requirements. :
Dec 11 14:18:46 bumble savecore: 192.109.197.82:/src/nodisk/swap/bumble: No such file or directory
This, too, will change; in the meantime, it is possible to mount swap on files, even if they are NFS mounted, but not on the NFS file system itself. This means that the first of the following entries in /etc/fstab will not work, but the second will:
192.109.197.82:/src/nodisk/swap/bumble none swap sw 0 0 /src/nodisk/swap/bumble none swap sw 0 0 echunga:/src /src nfs rw 0
The reason here is the third line: /src/nodisk/swap/bumble is NFS mounted, so this is a swap-to-file situation. For this to work, you may have to add the following line at the end of your /etc/rc.diskless2:
swapon -a
This is because the standard system startup mounts swap before mounting additional NFS file systems. If you place the
In many cases, you may have a number of machines that you want to run diskless. If you have enough disk (one image for each machine), you don't have anything to worry about, but often it may be
The big problem is /etc. In particular, /etc/rc.conf contains information like the system name. One way to handle this is to have a separate /etc directory for each system. This may seem reasonable, because /etc is only about 1.5 MB in size. In fact, this implies mounting the entire root file system with the other top-level directories, and that means more like 60MB.
The other alternative to network booting is to find a local substitute for the disk. This is obviously the only alternative for a stand-alone machine. There are a number of alternatives:
Flash memory is intended mainly for reading. It is much slower to write than to read, and it can only take a certain number of write cycles before it fails. Clearly it's a candidate for read-only file systems.
Для получения официальных документов о завершении программы дополнительного профессионального образования (удостоверения о повышении квалификации, дипломов о профессиональной переподготовке и MBA) необходимо предоставить:
Внимание! Вы можете не заказывать доставку бумажной версии официального документы, а скачать его в электронном виде и распечатать самостоятельно. Информация о выданном документе в течение 1 месяца загружается в Федеральную информационную систему «Федеральный реестр сведений о документах об образовании и (или) о квалификации, документах об обучении» - ФИС ФРДО.
Доступ на новый сайт осуществляется с использованием адреса электронной почты, который был указан вами при регистрации на "старом". Мы постарались перенести все ваши данные с прежнего ресурса, однако не исключена вероятность потери части информации.
При возникновении проблемы со входом, воспользуйтесь функцией сброса пароля
Если вы обнаружите несоответствия, пожалуйста, сообщите нам.