diff --git a/handbook/dialup.sgml b/handbook/dialup.sgml index bb87f073be..9170e3238c 100644 --- a/handbook/dialup.sgml +++ b/handbook/dialup.sgml @@ -1,809 +1,810 @@ Dialup access

Contributed by &a.ghelmer;. This document provides suggestions for configuring a FreeBSD system to handle dialup modems. This document is written based on the author's experience with FreeBSD versions 1.0, 1.1, and 1.1.5.1 (and experience with dialup modems on other UNIX-like operating systems); however, this document may not answer all of your questions or provide examples specific enough to your environment. The author cannot be responsible if you damage your system or lose data due to attempting to follow the suggestions here. Prerequisites

To begin with, the author assumes you have some basic knowledge of FreeBSD. You need to have FreeBSD installed, know how to edit files in a UNIX-like environment, and how to look up manual pages on the system. As discussed below, you'll need certain versions of FreeBSD, and knowledge of some terminology & modem and cabling. FreeBSD Version

First, it is assumed that you are using FreeBSD version 1.1 or higher (including versions 2.x). FreeBSD version 1.0 included two different serial drivers, which complicates the situation. Also, the serial device driver (Terminology

A quick rundown of terminology: If you need more information about these terms and data communications in general, the author remembers reading that External vs. Internal Modems

External modems seem to be more convenient for dialup, because external modems often can be semi-permanently configured via parameters stored in non-volatile RAM and they usually provide lighted indicators that display the state of important RS-232 signals. Blinking lights impress visitors, but lights are also very useful to see whether a modem is operating properly. Internal modems usually lack non-volatile RAM, so their configuration may be limited only to setting DIP switches. If your internal modem has any signal indicator lights, it is probably difficult to view the lights when the system's cover is in place. Modems and Cables

A background knowledge of these items is assumed You know how to connect your modem to your computer so that the two can communicate (unless you have an internal modem, which doesn't need such a cable) You are familiar with your modem's command set, or know where to look up needed commands You know how to configure your modem (probably via a terminal communications program) so you can set the non-volatile RAM parameters The first, connecting your modem, is usually simple - most straight-through serial cables work without any problems. You need to have a cable with appropriate connectors (DB-25 or DB-9, male or female) on each end, and the cable must be a DCE-to-DTE cable with these signals wired: Transmitted Data ( Received Data ( Request to Send ( Clear to Send ( Data Set Ready ( Data Terminal Ready ( Carrier Detect ( Signal Ground ( FreeBSD needs the Serial Interface Considerations

FreeBSD supports NS8250-, NS16450-, NS16550-, and NS16550A-based EIA RS-232C (CCITT V.24) communications interfaces. The 8250 and 16450 devices have single-character buffers. The 16550 device provides a 16-character buffer, which allows for better system performance. (Bugs in plain 16550's prevent the use of the 16-character buffer, so use 16550A's if possible). Because single-character-buffer devices require more work by the operating system than the 16-character-buffer devices, 16550A-based serial interface cards are much prefered. If the system has many active serial ports or will have a heavy load, 16550A-based cards are better for low-error-rate communications. Quick Overview

Here is the process that FreeBSD follows to accept dialup logins. A /dev/ttyd0, for our example). The command 4850 ?? I 0:00.09 /usr/libexec/getty V19200 ttyd0 When a user dials the modem's line and the modems connect, the /usr/bin/login, which completes the login by asking for the user's password and then starting the user's shell. Let's dive into the configuration... Kernel Configuration

FreeBSD kernels typically come prepared to search for four serial ports, known in the PC-DOS world as /sbin/dmesg command to replay the kernel's boot messages. In particular, look for messages that start with the characters /usr/sbin/dmesg | grep 'sio' For example, on a system with four serial ports, these are the serial-port specific kernel boot messages: sio0 at 0x3f8-0x3ff irq 4 on isa sio0: type 16550A sio1 at 0x2f8-0x2ff irq 3 on isa sio1: type 16550A sio2 at 0x3e8-0x3ef irq 5 on isa sio2: type 16550A sio3 at 0x2e8-0x2ef irq 9 on isa sio3: type 16550A If your kernel doesn't recognize all of your serial ports, you'll probably need to configure a custom FreeBSD kernel for your system. Please see the BSD System Manager's Manual chapter on ``Building Berkeley Kernels with Config'' [the source for which is in /usr/src/share/doc/smm] and ``FreeBSD Configuration Options'' [in /sys/doc/options.doc] for more information on configuring and building kernels. You may have to unpack the kernel source distribution if haven't installed the system sources already (srcdist/srcsys.?? in FreeBSD 1.1, srcdist/sys.?? in FreeBSD 1.1.5.1, or the entire source distribution in FreeBSD 2.0) to be able to configure and build kernels. Create a kernel configuration file for your system (if you haven't already) by /sys/i386/conf. Then, if you are creating a new custom configuration file, copy the file GENERICAH (or GENERICBT, if you have a BusTek SCSI controller on FreeBSD 1.x) to device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr device sio2 at isa? port "IO_COM3" tty irq 5 vector siointr device sio3 at isa? port "IO_COM4" tty irq 9 vector siointr You can comment-out or completely remove lines for devices you don't have. If you have a multiport serial board, such as the Boca Board BB2016, please see the can't share interrupts on ISA-bus PCs (multiport boards have on-board electronics that allow all the 16550A's on the board to share one or two interrupt request lines). When you are finished adjusting the kernel configuration file, use the program Device Special Files

Most devices in the kernel are accessed through ``device special files'', which are located in the /dev directory. The /dev/ttyd? (dial-in) and /dev/cua0? (call-out) devices. On FreeBSD version 1.1.5 and higher, there are also initialization devices (/dev/ttyid? and /dev/cuai0?) and locking devices (/dev/ttyld? and /dev/cual0?). The initialization devices are used to initialize communications port parameters each time a port is opened, such as crtscts for modems which use CTS/RTS signalling for flow control. The locking devices are used to lock flags on ports to prevent users or programs changing certain parameters; see the manual pages Making Device Special Files

A shell script called /dev directory manages the device special files. (The manual page for /dev and issue the command /dev/ttyd? device special files, but also creates the /dev/cua0? (and all of the initializing and locking special files under FreeBSD 1.1.5 and up) and removes the hardwired terminal special file /dev/tty0?, if it exists. After making new device special files, be sure to check the permissions on the files (especially the /dev/cua* files) to make sure that only users who should have access to those device special files can read & write on them - you probably don't want to allow your average user to use your modems to dialout. The default permissions on the /dev/cua* files should be sufficient: crw-rw---- 1 uucp dialer 28, 129 Feb 15 14:38 /dev/cua01 crw-rw---- 1 uucp dialer 28, 161 Feb 15 14:38 /dev/cuai01 crw-rw---- 1 uucp dialer 28, 193 Feb 15 14:38 /dev/cual01 These permissions allow the user Configuration Files

There are three system configuration files in the /etc directory that you'll probably need to edit to allow dialup access to your FreeBSD system. The first, /etc/gettytab, contains configuration information for the /usr/libexec/getty daemon. Second, /etc/ttys holds information that tells /sbin/init what /etc/rc.serial script if you have FreeBSD 1.1.5.1 or higher; otherwise, you can initialize ports in the /etc/rc.local script. There are two schools of thought regarding dialup modems on UNIX. One group likes to configure their modems and system so that no matter at what speed a remote user dials in, the local computer-to-modem RS-232 interface runs at a locked speed. The benefit of this configuration is that the remote user always sees a system login prompt immediately. The downside is that the system doesn't know what a user's true data rate is, so full-screen programs like Emacs won't adjust their screen-painting methods to make their response better for slower connections. The other school configures their modems' RS-232 interface to vary its speed based on the remote user's connection speed. For example, V.32bis (14.4 Kbps) connections to the modem might make the modem run its RS-232 interface at 19.2 Kbps, while 2400 bps connections make the modem's RS-232 interface run at 2400 bps. Because <Enter> key until they see a recognizable prompt. If the data rates don't match, /etc/gettytab

/etc/gettytab is a Locked-Speed Config

If you are locking your modem's data communications rate at a particular speed, you probably won't need to make any changes to /etc/gettytab. Matching-Speed Config

You'll need to setup an entry in /etc/gettytab to give # # Fast dialup terminals, 2400/1200/300 rotary (can start either way) # D2400|d2400|Fast-Dial-2400:\ :nx=D1200:tc=2400-baud: 3|D1200|Fast-Dial-1200:\ :nx=D300:tc=1200-baud: 5|D300|Fast-Dial-300:\ :nx=D2400:tc=300-baud: If you have a higher speed modem, you'll probably need to add an entry in /etc/gettytab; here's an entry you could use for a 14.4 Kbps modem with a top interface speed of 19.2 Kpbs: # # Additions for a V.32bis Modem # um|V300|High Speed Modem at 300,8-bit:\ :nx=V19200:tc=std.300: un|V1200|High Speed Modem at 1200,8-bit:\ :nx=V300:tc=std.1200: uo|V2400|High Speed Modem at 2400,8-bit:\ :nx=V1200:tc=std.2400: up|V9600|High Speed Modem at 9600,8-bit:\ :nx=V2400:tc=std.9600: uq|V19200|High Speed Modem at 19200,8-bit:\ :nx=V9600:tc=std.19200: On FreeBSD 1.1.5 and later, this will result in 8-bit, no parity connections. Under FreeBSD 1.1, add std. entries at the top of the file for 8 bits, no parity; otherwise, the default is 7 bits, even parity. The example above starts the communications rate at 19.2 Kbps (for a V.32bis connection), then cycles through 9600 bps (for V.32), 2400 bps, 1200 bps, 300 bps, and back to 19.2 Kbps. Communcations rate cycling is implemented with the # # Additions for a V.32bis or V.34 Modem # Starting at 57.6 Kpbs # vm|VH300|Very High Speed Modem at 300,8-bit:\ :nx=VH57600:tc=std.300: vn|VH1200|Very High Speed Modem at 1200,8-bit:\ :nx=VH300:tc=std.1200: vo|VH2400|Very High Speed Modem at 2400,8-bit:\ :nx=VH1200:tc=std.2400: vp|VH9600|Very High Speed Modem at 9600,8-bit:\ :nx=VH2400:tc=std.9600: vq|VH57600|Very High Speed Modem at 57600,8-bit:\ :nx=VH9600:tc=std.57600: If you have a slow CPU or a heavily loaded system and you don't have 16550A-based serial ports, you may receive sio ``silo'' errors at 57.6 Kbps. /etc/ttys

/etc/ttys is the list of /etc/ttys also provides security information to /etc/ttys or add new lines to make ttyd0 "/usr/libexec/getty xxx" dialup on The first item in the above line is the device special file for this entry - /dev/ttyd0 is the file that this "/usr/libexec/getty (secure, but it should only be used for terminals which are physically secure (such as the system console). The default terminal type (/etc/ttys, you may send the kill -1 1 to send the signal. If this is your first time setting up the system, though, you may want to wait until your modem(s) are properly configured and connected before signalling Locked-Speed Config

For a locked-speed configuration, your ttyd0 "/usr/libexec/getty std.19200" dialup on If your modem is locked at a different data rate, substitute the appropriate name for the std. entry for /etc/gettytab for your modem's data rate. Matching-Speed Config

In a matching-speed configuration, your /etc/gettytab. For example, if you added the above suggested entry for a matching-speed modem that starts at 19.2 Kbps (the ttyd0 "/usr/libexec/getty V19200" dialup on /etc/rc.serial or /etc/rc.local

High-speed modems, like V.32, V.32bis, and V.34 modems, need to use hardware (RTS/CTS) flow control. You can add /etc/rc.serial on FreeBSD 1.1.5.1 and up, or /etc/rc.local on FreeBSD 1.1, to set the hardware flow control flag in the FreeBSD kernel for the modem ports. For example, on a sample FreeBSD 1.1.5.1 system, /etc/rc.serial reads: #!/bin/sh # # Serial port initial configuration stty -f /dev/ttyid1 crtscts stty -f /dev/cuai01 crtscts which sets the # Set serial ports to use RTS/CTS flow control stty -f /dev/ttyd0 crtscts stty -f /dev/ttyd1 crtscts stty -f /dev/ttyd2 crtscts stty -f /dev/ttyd3 crtscts Since there isn't an initialization device special file on FreeBSD 1.1, one has to just set the flags on the sole device special file and hope the flags aren't cleared by a miscreant. Modem Settings

If you have a modem whose parameters may be permanently set in non-volatile RAM, you'll need to use a terminal program (such as Telix under PC-DOS or Disable XON/XOFF flow control Quiet mode (no result codes) No command echo Please read the documentation for your modem to find out what commands and/or DIP switch settings you need to give it. For example, to set the above parameters on a USRobotics Sportster 14,400 external modem, one could give these commands to the modem: ATZ AT&C1&D2&H1&I0&R2&W You might also want to take this opportunity to adjust other settings in the modem, such as whether it will use V.42bis and/or MNP5 compression. The USR Sportster 14,400 external modem also has some DIP switches that need to be set; for other modems, perhaps you can use these settings as an example: Switch 1: UP - DTR Normal Switch 2: Don't care (Verbal Result Codes/Numeric Result Codes) Switch 3: UP - Suppress Result Codes Switch 4: DOWN - No echo, offline commands Switch 5: UP - Auto Answer Switch 6: UP - Carrier Detect Normal Switch 7: UP - Load NVRAM Defaults Switch 8: Don't care (Smart Mode/Dumb Mode) Result codes should be disabled/suppressed for dialup modems to avoid problems that can occur if Locked-speed Config

For a locked-speed configuration, you'll need to configure the modem to maintain a constant modem-to-computer data rate independent of the communications rate. On a USR Sportster 14,400 external modem, these commands will lock the modem-to-computer data rate at the speed used to issue the commands: ATZ AT&B1&W Matching-speed Config

For a variable-speed configuration, you'll need to configure your modem to adjust its serial port data rate to match the incoming call rate. On a USR Sportster 14,400 external modem, these commands will lock the modem's error-corrected data rate to the speed used to issue the commands, but allow the serial port rate to vary for non-error-corrected connections: ATZ AT&B2&W Checking the Modem's Configuration

Most high-speed modems provide commands to view the modem's current operating parameters in a somewhat human-readable fashion. On the USR Sportster 14,400 external modems, the command Troubleshooting

Here are a few steps you can follow to check out the dialup modem on your system. Checking out the FreeBSD system

Hook up your modem to your FreeBSD system, boot the system, and, if your modem has status indication lights, watch to see whether the modem's 114 ?? I 0:00.10 /usr/libexec/getty V19200 ttyd0 115 ?? I 0:00.10 /usr/libexec/getty V19200 ttyd1 If you see something different, like this: 114 d0 I 0:00.10 /usr/libexec/getty V19200 ttyd0 ^^ and the modem hasn't accepted a call yet, this means that /etc/ttys to see if there are any mistakes there. Also, check the log file /var/log/messages to see if there are any log messages from /etc/ttys and /etc/gettytab, as well as the appropriate device special files /dev/ttyd?, for any mistakes, missing entries, or missing device special files. Try Dialing In

Try dialing into the system; be sure to use 8 bits, no parity, 1 stop bit on the remote system. If you don't get a prompt right away, or get garbage, try pressing <Enter> about once per second. If you still don't see a BREAK. If you are using a high-speed modem to do the dialing, try dialing again after locking the dialing modem's interface speed (via AT&B1 on a USR Sportster, for example). If you still can't get a /etc/gettytab again and double-check that The initial capability name specified in /etc/ttys for the line matches a name of a capability in /etc/gettytab Each Each If you dial but the modem on the FreeBSD system won't answer, make sure that the modem is configured to answer the phone when FreeBSD-Questions@freebsd.org describing your modem and your -problem, and the good folks on the list will try to help. +perhaps you can send an electronic mail message to +describing your modem and your problem, and the good folks on the list will +try to help. Acknowledgements

Thanks to these people for comments and advice: diff --git a/handbook/esdi.sgml b/handbook/esdi.sgml index 1705280aa8..7ced7a26f3 100644 --- a/handbook/esdi.sgml +++ b/handbook/esdi.sgml @@ -1,421 +1,421 @@ - + Using ESDI hard disks

Copyright © 1995, &a.wilko;.24 September 1995. ESDI is an acronym that means Enhanced Small Device Interface. It is loosely based on the good old ST506/412 interface originally devised by Seagate Technology, the makers of the first affordable 5.25" winchester disk. The acronym says Enhanced, and rightly so. In the first place the speed of the interface is higher, 10 or 15 Mbits/second instead of the 5 Mbits/second of ST412 interfaced drives. Secondly some higher level commands are added, making the ESDI interface somewhat 'smarter' to the operating system driver writers. It is by no means as smart as SCSI by the way. ESDI is standardised by ANSI. Capacities of the drives are boosted by putting more sectors on each track. Typical is 35 sectors per track, high capacity drives I've seen were up to 54 sectors/track. Although ESDI has been largely obsoleted by IDE and SCSI interfaces, the availability of free or cheap surplus drives makes them ideal for low (or now) budget systems. Concepts of ESDI

Physical connections

The ESDI interface uses two cables connected to each drive. One cable is a 34 pin flatcable edge connector that carries the command and status signals from the controller to the drive and viceversa. The command cable is daisy chained between all the drives. So, it forms a bus onto which all drives are connected. The second cable is a a 20 pin flatcable edge connector that carries the data to and from the drive. This cable is radially connected, so each drive has it's own direct connection to the controller. To the best of my knowledge PC ESDI controllers are limited to using a maximum of 2 drives per controller. This is compatibility feature(?) left over from the WD1003 standard that reserves only a single bit for device addressing. Device addressing

On each command cable a maximum of 7 devices and 1 controller can be present. To enable the controller to uniquely identify which drive it addresses, each ESDI device is equipped with jumpers or switches to select the devices address. On PC type controllers the first drive is set to address 0, the second disk to address 1. Always make sure you set each disk to an unique address! So, on a PC with it's two drives/controller maximum the first drive is drive 0, the second is drive 1. Termination

The daisy chained command cable (the 34 pin cable remember?) needs to be terminated at the last drive on the chain. For this purpose ESDI drives come with a termination resistor network that can be removed or disabled by a jumper when it is not used. So, one and only one drive, the one at the fartest end of the command cable has it's terminator installed/enabled. The controller automatically terminates the other end of the cable. Please note that this implies that the controller must be at one end of the cable and not in the middle. Using ESDI disks with FreeBSD

Why is ESDI such a pain to get working in the first place? People who tried ESDI disks with FreeBSD are known to have developed a profound sense of frustration. A combination of factors works against you to produce effects that are hard to understand when you have never seen them before. This has also led to the popular legend ESDI and FreeBSD is a plain NO-GO. The following sections try to list all the pitfalls and solutions. ESDI speed variants

As briefly mentioned before, ESDI comes in two speed flavours. The older drives and controllers use a 10 Mbits/second data transfer rate. Newer stuff uses 15 Mbits/second. It is not hard to imagine that 15 Mbits/second drive cause problems on controllers laid out for 10 Mbits/second. As always, consult your controller and drive documentation to see if things match. Stay on track

Mainstream ESDI drives use 34 to 36 sectors per track. Most (older) controllers cannot handle more than this number of sectors. Newer, higher capacity, drives use higher numbers of sectors per track. For instance, I own a 670 Mb drive that has 54 sectors per track. In my case, the controller could not handle this number of sectors. It proved to work well except that it only used 35 sectors on each track. This meant losing a lot of diskspace. Once again, check the documentation of your hardware for more info. Going out-of-spec like in the example might or might not work. Give it a try or get another more capable controller. Hard or soft sectoring

Most ESDI drives allow hard or soft sectoring to be selected using a jumper. Hard sectoring means that the drive will produce a sector pulse on the start of each new sector. The controller uses this pulse to tell when it should start to write or read. Hard sectoring allows a selection of sector size (normally 256, 512 or 1024 bytes per formatted sector). FreeBSD uses 512 byte sectors. The number of sectors per track also varies while still using the same number of bytes per formatted sector. The number of unformatted bytes per sector varies, dependent on your controller it needs more or less overhead bytes to work correctly. Pushing more sectors on a track of course gives you more usable space, but might give problems if your controller needs more bytes than the drive offers. In case of soft sectoring, the controller itself determines where to start/stop reading or writing. For ESDI hard sectoring is the default (at least on everything I came across). I never felt the urge to try soft sectoring. In general, experiment with sector settings before you install FreeBSD because you need to re-run the low-level format after each change. Low level formatting

ESDI drives need to be low level formatted before they are usable. A reformat is needed whenever you figgle with the number of sectors/track jumpers or the physical orientation of the drive (horizontal, vertical). So, first think, then format. The format time must not be underestimated, for big disks it can take hours. After a low level format, a surface scan is done to find and flag bad sectors. Most disks have a manufacturer bad block list listed on a piece of paper or adhesive sticker. In addition, on most disks the list is also written onto the disk. Please use the manufacturer's list. It is much easier to remap a defect now than after FreeBSD is installed. Stay away from low-level formatters that mark all sectors of a track as bad as soon as they find one bad sector. Not only does this waste space, it also and more importantly causes you grief with bad144 (see the section on bad144). Translations

Translations, although not exclusively a ESDI-only problem, might give you real trouble. Translations come in multiple flavours. Most of them have in common that they attempt to work around the limitations posed upon disk geometries by the original IBM PC/AT design (thanks IBM!). First of all there is the (in)famous 1024 cylinder limit. For a system to be able to boot, the stuff (whatever operating system) must be in the first 1024 cylinders of a disk. Only 10 bits are available to encode the cylinder number. For the number of sectors the limit is 64 (0-63). When you combine the 1024 cylinder limit with the 16 head limit (also a design feature) you max out at fairly limited disk sizes. To work around this problem, the manufacturers of ESDI PC controllers added a BIOS prom extension on their boards. This BIOS extension handles disk I/O for booting (and for some operating systems all disk I/O) by using translation. For instance, a big drive might be presented to the system as having 32 heads and 64 sectors/track. The result is that the number of cylinders is reduced to something below 1024 and is therefore usable by the system without problems. It is noteworthy to know that FreeBSD after it's kernel has started no longer uses the BIOS. More on this later. A second reason for translations is the fact that most older system BIOSes could only handle drives with 17 sectors per track (the old ST412 standard). Newer system BIOSes usually have a user-defined drive type (in most cases this is drive type 47). Whatever you do to translations after reading this document, keep in mind that if you have multiple operating systems on the same disk, all must use the same translation While on the subject of translations, I've seen one controller type (but there are probably more like this) offer the option to logically split a drive in multiple partitions as a BIOS option. I had select 1 drive == 1 partition because this controller wrote this info onto the disk. On powerup it read the info and presented itself to the system based on the info from the disk. Spare sectoring

Most ESDI controllers offer the possibility to remap bad sectors. During/after the low-level format of the disk bad sectors are marked as such, and a replacement sector is put in place (logically of course) of the bad one. In most cases the remapping is done by using N-1 sectors on each track for actual datastorage, and sector N itself is the spare sector. N is the total number of sectors physically available on the track. The idea behind this is that the operating system sees a 'perfect' disk without bad sectors. In the case of FreeBSD this concept is not usable. The problem is that the translation from bad to good is performed by the BIOS of the ESDI controller. FreeBSD, being a true 32 bit operating system, does not use the BIOS after it has been booted. Instead, it has device drivers that talk directly to the hardware. So: don't use spare sectoring, bad block remapping or whatever it may be called by the controller manufacturer when you want to use the disk for FreeBSD. Bad block handling

The preceding section leaves us with a problem. The controller's bad block handling is not usable and still FreeBSD's filesystems assume perfect media without any flaws. To solve this problem, FreeBSD use the bad144 tool. Bad144 (named after a Digital Equipment standard for bad block handling) scans a FreeBSD slice for bad blocks. Having found these bad blocks, it writes a table with the offending block numbers to the end of the FreeBSD slice. - When the disk is in operation, the diskaccesses are checked + When the disk is in operation, the disk accesses are checked against the table read from the disk. Whenever a blocknumber is requested that is in the bad144 list, a replacement block (also from the end of the FreeBSD slice) is used. In this way, the bad144 replacement scheme presents 'perfect' media to the FreeBSD filesystems. There are a number of potential pitfalls associated with the use of bad144. First of all, the slice cannot have more than 126 bad sectors. If your drive has a high number of bad sectors, you might need to divide it into multiple FreeBSD slices each containing less than 126 bad sectors. Stay away from low-level format programs that mark every sector of a track as bad when they find a flaw on the track. As you can imagine, the 126 limit is quickly reached when the low-level format is done this way. Second, if the slice contains the root filesystem, the slice should be within the 1024 cylinder BIOS limit. During the boot process the bad144 list is read using the BIOS and this only succeeds when the list is within the 1024 cylinder limit. Note that the restriction is not that only the root filesystem must be within the 1024 cylinder limit, but rather the entire slice that contains the root filesystem. Kernel configuration

ESDI disks are handled by the same wddriver as IDE and ST412 MFM disks. The wd driver should work for all WD1003 compatible interfaces. Most hardware is jumperable for one of two different I/O address ranges and IRQ lines. This allows you to have two wd type controllers in one system. When your hardware allows non-standard strappings, you can use these with FreeBSD as long as you enter the correct info into the kernel config file. An example from the kernel config file (they live in /sys/i386/conf BTW). # First WD compatible controller controller wdc0 at isa? port "IO_WD1" bio irq 14 vector wdintr disk wd0 at wdc0 drive 0 disk wd1 at wdc0 drive 1 # Second WD compatible controller controller wdc1 at isa? port "IO_WD2" bio irq 15 vector wdintr disk wd2 at wdc1 drive 0 disk wd3 at wdc1 drive 1 Particulars on ESDI hardware

Adaptec 2320 controllers

I succesfully installed FreeBSD onto a ESDI disk controlled by a ACB-2320. No other operating system was present on the disk. To do so I low level formatted the disk using NEFMT.EXE (ftpable from www.adaptec.com) and answered NO to the question whether the disk should be formatted with a spare sector on each track. The BIOS on the ACD-2320 was disabled. I used the 'free configurable' option in the system BIOS to allow the BIOS to boot it. Before using NEFMT.EXE I tried to format the disk using the ACB-2320 BIOS builtin formatter. This proved to be a showstopper, because it didn't give me an option to disable spare sectoring. With spare sectoring enabled the FreeBSD installation process broke down on the bad144 run. Please check carefully which ACB-232xy variant you have. The x is either 0 or 2, indicating a controller without or with a floppy controller on board. The y is more interesting. It can either be a blank, a "A-8" or a "D". A blank indicates a plain 10 Mbits/second controller. An "A-8" indicates a 15 Mbits/second controller capable of handling 52 sectors/track. A "D" means a 15 Mbits/second controller that can also handle drives with > 36 sectors/track (also 52 ?). All variations should be capable of using 1:1 interleaving. Use 1:1, FreeBSD is fast enough to handle it. Western Digital WD1007 controllers

I succesfully installed FreeBSD onto a ESDI disk controlled by a WD1007 controller. To be precise, it was a WD1007-WA2. Other variations of the WD1007 do exist. To get it to work, I had to disable the sector translation and the WD1007's onboard BIOS. This implied I could not use the low-level formatter built into this BIOS. Instead, I grabbed WDFMT.EXE from www.wdc.com Running this formatted my drive just fine. Ultrastor U14F controllers

According to multiple reports from the net, Ultrastor ESDI boards work OK with FreeBSD. I lack any further info on particular settings. Further reading

If you intend to do some serious ESDI hacking, you might want to have the official standard at hand: The latest ANSI X3T10 committee document is: Enhanced Small Device Interface (ESDI) [X3.170-1990/X3.170a-1991] [X3T10/792D Rev 11] On Usenet the newsgroup is a noteworthy place to look for more info. The World Wide Web (WWW) also proves to be a very handy info source: For info on Adaptec ESDI controllers see . For info on Western Digital controllers see . Thanks to...

Andrew Gordon for sending me an Adaptec 2320 controller and ESDI disk for testing. diff --git a/handbook/install.sgml b/handbook/install.sgml index 326db005d9..520ef6c139 100644 --- a/handbook/install.sgml +++ b/handbook/install.sgml @@ -1,876 +1,876 @@ - + Installing FreeBSD

So, you would like to try out FreeBSD on your system? This section is a quick-start guide for what you need to do. FreeBSD can be installed from a variety of media including CD-ROM, floppy disk, magnetic tape, an MS-DOS partition, and if you have a network connection, via anonymous ftp or NFS. Regardless of the installation media you choose, you can get started by downloading the installation disk as described below. Booting your computer with disk will provide important information about compatibility between FreeBSD and your hardware which could dictate which installation options are possible. It can also provide early clues to compatibility problems that could prevent FreeBSD running on your system at all. If you plan on installing via anonymous FTP, then this installation disk is all you need to download. For more information on obtaining the FreeBSD distribution itself, please see in the Appendix. So, to get the show on the road, follow these steps: Review the section of this installation guide to be sure that your hardware is supported by FreeBSD. It may be helpful to make a list of any special cards you have installed, such as SCSI controllers, ethernet adapters or sound cards. This list should include relevant configuration parameters such as interrupts (IRQ) and IO port addresses. Download the file to your hard drive, and be sure to tell your browser to save rather than display. Note: This disk image can be used for both 1.44 megabyte 3.5 inch floppy disks and 1.2 megabyte 5.25 inch floppy disks. Make the installation boot disk from the image file: If you are using MS-DOS download , then run it: C:\> rawrite The program will prompt you for the floppy drive containing the disk you want to write to (A: or B:) and the name of the file to put on disk (boot.flp). If you are using a UNIX system: % dd if=boot.flp of=disk_device where disk_device is the /dev entry for the floppy drive. On FreeBSD systems, this is /dev/fd0 for the A: drive and /dev/fd1 for the B: drive. With the installation disk in the A: drive, reboot your computer. You should get a boot prompt something like this: >> FreeBSD BOOT ... Use hd(1,a)/kernel to boot sd0 when wd0 is also installed. Usage: [[hd(1,a)]/kernel][-abcCdhrsv] Use ? for file list or press Enter for defaults Boot: If you do not type anything, FreeBSD will automatically boot with its default configuration after a delay of about five seconds. As FreeBSD boots, it probes your computer to determine what hardware is installed. The results of this probing is displayed on the screen. When the booting process is finished, The main FreeBSD installation menu will be displayed.

If something goes wrong...

Due to limitations of the PC architecture, it is impossible for probing to be 100 percent reliable. In the event that your hardware is incorrectly identified, or that the probing causes your computer to lock up, first check the section of this installation guide to be sure that your hardware is indeed supported by FreeBSD.

If your hardware is supported, reset the computer and when the Boot: prompt comes up, type -c. This puts FreeBSD into a configuration mode where you can supply hints about your hardware. The FreeBSD kernel on the installation disk is configured assuming that most hardware devices are in their factory default configuration in terms of IRQs, IO addresses and DMA channels. If your hardware has been reconfigured, you will most likely need to use the -c option at boot to tell FreeBSD where things are.

It is also possible that a probe for a device not present will cause a later probe for another device that is present to fail. In that case, the probes for the conflicting driver(s) should be disabled.

In the configuration mode, you can: List the device drivers installed in the kernel. Disable device drivers for hardware not present in your system. Change the IRQ, DRQ, and IO port addresses used by a device driver.

While at the config> prompt, type help for more information on the available commands. After adjusting the kernel to match how you have your hardware configured, type quit at the config> prompt to continue booting with the new settings. After FreeBSD has been installed, changes made in the configuration mode will be permanent so you do not have to reconfigure every time you boot. Even so, it is likely that you will want to build a custom kernel to optimize the performance of your system. See for more information on creating custom kernels. Supported Configurations

FreeBSD currently runs on a wide variety of ISA, VLB, EISA and PCI bus based PC's, ranging from 386sx to Pentium class machines (though the 386sx is not recommended). Support for generic IDE or ESDI drive configurations, various SCSI controller, network and serial cards is also provided. A minimum of five megabytes of RAM is required to run FreeBSD. To run the X-window system, eight megabytes of RAM is the recommended minimum. Following is a list of all disk controllers and ethernet cards currently known to work with FreeBSD. Other configurations may very well work, and we have simply not received any indication of this. Disk Controllers

WD1003 (any generic MFM/RLL) WD1007 (any generic IDE/ESDI) IDE ATA Adaptec 152x series ISA SCSI controllers Adaptec 154x series ISA SCSI controllers Adaptec 174x series EISA SCSI controller in standard and enhanced mode. Adaptec 274x/284x/2940/3940 (Narrow/Wide/Twin) series EISA/VLB/PCI SCSI controllers Adaptec AIC-6360 based boards, which includes the AHA-152x and SoundBlaster SCSI cards. Note: You cannot boot from the SoundBlaster cards as they have no on-board BIOS, which is necessary for mapping the boot device into the system BIOS I/O vectors. They are perfectly usable for external tapes, CDROMs, etc, however. The same goes for any other AIC-6x60 based card without a boot ROM. Some systems DO have a boot ROM, which is generally indicated by some sort of message when the system is first powered up or reset. Check your system/board documentation for more details. Buslogic 545S & 545c Note: that Buslogic was formerly known as "Bustek". Buslogic 445S/445c VLB SCSI controller Buslogic 742A/747S/747c EISA SCSI controller. Buslogic 946c PCI SCSI controller Buslogic 956c PCI SCSI controller NCR 53C810/53C815/53C825/53C860/53C875 PCI SCSI controller. NCR5380/NCR53400 (``ProAudio Spectrum'') SCSI controller. DTC 3290 EISA SCSI controller in 1542 emulation mode. UltraStor 14F/24F/34F SCSI controllers. Seagate ST01/02 SCSI controllers. Future Domain 8xx/950 series SCSI controllers. WD7000 SCSI controllers. With all supported SCSI controllers, full support is provided for SCSI-I & SCSI-II peripherals, including Disks, tape drives (including DAT) and CD ROM drives. The following CD-ROM type systems are supported at this time: Soundblaster SCSI and ProAudio Spectrum SCSI (cd) Mitsumi (all models) proprietary interface (mcd) Matsushita/Panasonic (Creative) CR-562/CR-563 proprietary interface (matcd) Sony proprietary interface (scd) ATAPI IDE interface (experimental and should be considered ALPHA quality!) (wcd) Ethernet cards

Allied-Telesis AT1700 and RE2000 cards SMC Elite 16 WD8013 ethernet interface, and most other WD8003E, WD8003EBT, WD8003W, WD8013W, WD8003S, WD8003SBT and WD8013EBT based clones. SMC Elite Ultra is also supported. DEC EtherWORKS III NICs (DE203, DE204, and DE205) DEC EtherWORKS II NICs (DE200, DE201, DE202, and DE422) DEC DC21140/DC21141 based NICs: ASUS PCI-L101-TB Accton ENI1203 Cogent EM960PCI D-Link DE-530 DEC DE435 Danpex EN-9400P3 JCIS Condor JC1260 Linksys EtherPCI Mylex LNP101 SMC EtherPower 10/100 (Model 9332) SMC EtherPower (Model 8432) Zynx ZX342 DEC FDDI (DEFPA/DEFEA) NICs Fujitsu FMV-181 and FMV-182 Intel EtherExpress Isolan AT 4141-0 (16 bit) Isolink 4110 (8 bit) Novell NE1000, NE2000, and NE2100 ethernet interface. 3Com 3C501 cards 3Com 3C503 Etherlink II 3Com 3c505 Etherlink/+ 3Com 3C507 Etherlink 16/TP 3Com 3C509, 3C579, 3C589 (PCMCIA) Etherlink III Toshiba ethernet cards PCMCIA ethernet cards from IBM and National Semiconductor are also supported.

Note: FreeBSD does not currently suppport PnP (plug-n-play) features present on some ethernet cards. If your card has PnP and is giving you problems, try disabling its PnP features. Miscellaneous devices

AST 4 port serial card using shared IRQ. ARNET 8 port serial card using shared IRQ. BOCA IOAT66 6 port serial card using shared IRQ. BOCA 2016 16 port serial card using shared IRQ. Cyclades Cyclom-y Serial Board. STB 4 port card using shared IRQ. SDL Communications Riscom/8 Serial Board. Adlib, SoundBlaster, SoundBlaster Pro, ProAudioSpectrum, Gravis UltraSound, Gravis UltraSound MAX and Roland MPU-401 sound cards. FreeBSD currently does not support IBM's microchannel (MCA) bus, but support is apparently close to materializing. Details will be posted as the situation develops. Preparing for the installation

There are a number of different methods by which FreeBSD can be installed. The following describes what preparation needs to be done for each type. Before installing from CDROM

If your CDROM is of an unsupported type, such as an IDE CDROM, then please skip to . There is not a lot of preparatory work that needs to be done to successfully install from one of Walnut Creek's FreeBSD CDROMs (other CDROM distributions may work as well, though we cannot say for certain as we have no hand or say in how they're created). You can either boot into the CD installation directly from DOS using Walnut Creek's supplied ``install.bat'' batch file or you can make a boot floppy with the ``makeflp.bat'' command [NOTE: If you're using an IDE CDROM, use - the inst_ide.bat or atapiflp.bat batch files instead]. + the inst_ide.bat or atapiflp.bat batch files instead]. For the easiest interface of all (from DOS), type ``view''. This will bring up a DOS menu utility that leads you through all the available options. If you are creating the boot floppy from a UNIX machine, see for examples. of how to create the boot floppy. Once you have booted from DOS or floppy, you should then be able to select CDROM as the media type in the Media menu and load the entire distribution from CDROM. No other types of installation media should be required. After your system is fully installed and you have rebooted from the hard disk, you can mount the cdrom at any time by typing: mount /cdrom Before removing the CD again, also note that it's necessary to first type: umount /cdrom. Don't just remove it from the drive! Special note: Before invoking the installation, be sure that the CDROM is in the drive so that the install probe can find it. This is also true if you wish the CDROM to be added to the default system configuration automatically during the install (whether or not you actually use it as the installation media). Finally, if you would like people to be able to FTP install FreeBSD directly from the CDROM in your machine, you will find it quite easy. After the machine is fully installed, you simply need to add the following line to the password file (using the vipw command): ftp:*:99:99::0:0:FTP:/cdrom:/nonexistent Anyone with network connectivity to your machine (and permission to log into it) can now chose a Media type of FTP and type in: ftp://your machine after picking ``Other'' in the ftp sites menu. Before installing from Floppy

If you must install from floppy disks, either due to unsupported hardware or just because you enjoy doing things the hard way, you must first prepare some floppies for the install. The first floppy you'll need in addition to the boot.flp image is ``floppies/root.flp'', which is somewhat special in that it's not a DOS filesystem floppy at all, but rather a floppy "image" (it's actually a gzip'd cpio file). You can create this floppy in the same way that you created the boot floppy . Once this floppy is made, you can go on to make the distribution set floppies using ordinary DOS or UFS (if you're preparing the floppies on another FreeBSD machine) formatted diskettes. You will need, at minimum, as many 1.44MB or 1.2MB floppies as it takes to hold all files in the bin (binary distribution) directory. If you're preparing these floppies under DOS, then THESE floppies *must* be formatted using the MS-DOS FORMAT command. If you're using Windows, use the Windows File Manager format command. Do not trust Factory Preformatted floppies! Format them again yourself, just to make sure. Many problems reported by our users in the past have resulted from the use of improperly formatted media, which is why I'm taking such special care to mention it here! If you're creating the floppies from another FreeBSD machine, a format is still not a bad idea though you don't need to put a DOS filesystem on each floppy. You can use the `disklabel' and `newfs' commands to put a UFS filesystem on them instead, like so: disklabel -w -r fd0 floppy3 (use floppy5 for 1.2MB disks) newfs /dev/rfd0 Then you can mount and write to them like any other file system. After you have DOS formatted the floppies, you will need to copy the files onto them. The distribution files are split into chunks conveniently sized so that 5 of them will fit on a conventional 1.44MB floppy. Go through all your floppies, packing as many files as will fit on each one, until you have got all the distributions you want packed up in this fashion. Each distribution should go into a subdirectory on the floppy, e.g.: a:\bin\bin.aa, a:\bin\bin.ab, and so on. Once you come to the Media screen of the install, select ``Floppy'' and you will be prompted for the rest. Before installing from a MS-DOS partition

To prepare for installation from an MS-DOS partition, copy the files from the distribution into a directory called C:\FREEBSD. The directory tree structure of the CDROM must be partially reproduced within this directory so we suggest using the DOS xcopy command. For example, to prepare for a minimal installation of FreeBSD: C> MD C:\FREEBSD C> XCOPY /S E:\DISTS\BIN C:\FREEBSD\BIN\ C> XCOPY /S E:\FLOPPIES C:\FREEBSD\FLOPPIES\ assuming that C: is where you have free space and E: is where your CDROM is mounted. Note that you need the FLOPPIES directory because the root.flp image is needed during an MS-DOS installation. For as many `DISTS' you wish to install from MS-DOS (and you have free space for), install each one under C:\FREEBSD - the BIN dist is only the minimal requirement. If you have room on your MS-DOS partition for all the distributions, you could replace the last line above with: C> XCOPY /S E:\DISTS C:\FREEBSD\ which would copy all the subdirectories of E:\DISTS to C:\FREEBSD. Before installing from QIC/SCSI Tape

Installing from tape is probably the easiest method, short of an on-line install using FTP or a CDROM install. The installation program expects the files to be simply tar'ed onto the tape, so after getting all of the files for distribution you are interested in, simply tar them onto the tape with a command like: cd /freebsd/distdir tar cvf /dev/rwt0 (or /dev/rst0) dist1 .. dist2 Make sure that the `floppies/' directory is one of the ``dists'' given above, since the installation will look for `floppies/root.flp' on the tape. When you go to do the installation, you should also make sure that you leave enough room in some temporary directory (which you will be allowed to choose) to accommodate the full contents of the tape you have created. Due to the non-random access nature of tapes, this method of installation requires quite a bit of temporary storage. You should expect to require as much temporary storage as you have stuff written on tape. Note: When going to do the installation, the tape must be in the drive before booting from the boot floppy. The installation probe may otherwise fail to find it. Before installing over a network

You can do network installations over 3 types of communications links: Serial port SLIP or PPP Parallel port PLIP (laplink cable) Ethernet A standard ethernet controller (includes some PCMCIA). SLIP support is rather primitive, and limited primarily to hard-wired links, such as a serial cable running between a laptop computer and another computer. The link should be hard-wired as the SLIP installation does not currently offer a dialing capability; that facility is provided with the PPP utility, which should be used in preference to SLIP whenever possible. If you are using a modem, then PPP is almost certainly your only choice. Make sure that you have your service provider's information handy as you will need to know it fairly soon in the installation process. You will need to know, at the minimum, your service provider's IP address and possibly your own (though you can also leave it blank and allow PPP to negotiate it with your ISP). You also need to know how to use the various ``AT commands'' to dial the ISP with your particular modem as the PPP dialer provides only a very simple terminal emulator. If a hard-wired connection to another FreeBSD (2.0R or later) machine is available, you might also consider installing over a ``laplink'' parallel port cable. The data rate over the parallel port is much higher than what is typically possible over a serial line (up to 50k/sec), thus resulting in a quicker installation. Finally, for the fastest possible network installation, an ethernet adaptor is always a good choice! FreeBSD supports most common PC ethernet cards, a table of supported cards (and their required settings) is provided in . If you are using one of the supported PCMCIA ethernet cards, also be sure that it is plugged in before the laptop is powered on! FreeBSD does not, unfortunately, currently support hot insertion of PCMCIA cards. You will also need to know your IP address on the network, the netmask value for your address class, and the name of your machine. Your system administrator can tell you which values to use for your particular network setup. If you will be referring to other hosts by name rather than IP address, you will also need a name server and possibly the address of a gateway (if you are using PPP, it is your provider's IP address) to use in talking to it. If you do not know the answers to all or most of these questions, then you should really probably talk to your system administrator first before trying this type of installation. Once you have a network link of some sort working, the installation can continue over NFS or FTP. Preparing for NFS installation

NFS installation is fairly straight-forward: Simply copy the FreeBSD distribution files you want onto a server somewhere and then point the NFS media selection at it. If this server supports only ``privileged port'' access (as is generally the default for Sun workstations), you will need to set this option in the Options menu before installation can proceed. If you have a poor quality ethernet card which suffers from very slow transfer rates, you may also wish to toggle the appropriate Options flag. In order for NFS installation to work, the server must support subdir mounts, e.g., if your FreeBSD 2.1 distribution directory lives on: ziggy:/usr/archive/stuff/FreeBSD Then ziggy will have to allow the direct mounting of /usr/archive/stuff/FreeBSD, not just /usr or /usr/archive/stuff. In FreeBSD's /etc/exports file, this is controlled by the ``-alldirs'' option. Other NFS servers may have different conventions. If you are getting `Permission Denied' messages from the server then it is likely that you do not have this enabled properly. Preparing for FTP Installation

FTP installation may be done from any mirror site containing a reasonably up-to-date version of FreeBSD 2.1. A full menu of reasonable choices from almost anywhere in the world is provided by the FTP site menu. If you are installing from some other FTP site not listed in this menu, or you are having troubles getting your name server configured properly, you can also specify your own URL by selecting the ``Other'' choice in that menu. A URL can also be a direct IP address, so the following would work in the absence of a name server: ftp://192.216.222.4/pub/FreeBSD/2.1.0-RELEASE There are two FTP installation modes you can use: FTP Active For all FTP transfers, use ``Active'' mode. This will not work through firewalls, but will often work with older ftp servers that do not support passive mode. If your connection hangs with passive mode (the default), try active! FTP Passive For all FTP transfers, use ``Passive'' mode. This allows the user to pass through firewalls that do not allow incoming connections on random port addresses. Note: ACTIVE AND PASSIVE MODES ARE NOT THE SAME AS A `PROXY' CONNECTION, WHERE A PROXY FTP SERVER IS LISTENING ON A DIFFERENT PORT! In such instances, you should specify the URL as something like: ftp://foo.bar.com:1234/pub/FreeBSD Where ``1234'' is the port number of the proxy ftp server. Installing FreeBSD

Once you have taken note of the appropriate preinstallation steps, you should be able to install FreeBSD without any further trouble. Should this not be true, then you may wish to go back and re-read the relevant preparation section above for the installation media type you are trying to use, perhaps there is a helpful hint there that you missed the first time? If you are having hardware trouble, or FreeBSD refuses to boot at all, read the Hardware Guide provided on the boot floppy for a list of possible solutions. The FreeBSD boot floppy contains all the on-line documentation you should need to be able to navigate through an installation and if it does not then we would like to know what you found most confusing. Send your comments to . It is the objective of the FreeBSD installation program (sysinstall) to be self-documenting enough that painful ``step-by-step'' guides are no longer necessary. It may take us a little while to reach that objective, but that is the objective! Meanwhile, you may also find the following ``typical installation sequence'' to be helpful: Boot the boot floppy. After a boot sequence which can take anywhere from from 30 seconds to 3 minutes, depending on your hardware, you should be presented with a menu of initial choices. If the floppy does not boot at all, or the boot hangs at some stage, go read the Q&A section of the Hardware Guide for possible causes. Press F1. You should see some basic usage instructions on the menu system and general navigation. If you have not used this menu system before then PLEASE read this thoroughly! Select the Options item and set any special preferences you may have. Select a Custom or Express install, depending on whether or not you would like the installation to give you a high degree of control over each step of the installation or simply lead you through it, chosing reasonable defaults when possible. See details on both installation types below. The Configure menu choice allows you to furthur configure your FreeBSD installation by giving you menu-driven access to various system defaults. Some items, like networking, may be especially important if you did a CDROM/Tape/Floppy installation and have not yet configured your network interfaces (assuming you have any). Properly configuring such interfaces here will allow FreeBSD to come up on the network when you first reboot from the hard disk. Express installation

The express installation is not too much different than the Custom one except that it leads you through the required stages in the proper order and presents you with various helpful prompts along the way. The first step is the `Partition Editor', which allows you to chose how your drives will be used for FreeBSD. If you are dedicating an entire drive to FreeBSD, the `A' command is probably all you need to type here. Next, with the `Label Editor', you can specify how the space in any allocated FreeBSD partitions should be used by FreeBSD, or where to mount a non-FreeBSD partition (such as DOS). If you want the standard layout, simply type `A' here. Next, the `Distributions' menu allows you to specify which parts of FreeBSD you wish to load. A good choice is ``User'' for a small system or ``Developer'' for someone wanting a bit more out of FreeBSD. If none of the existing collections sound applicable, select Custom. Next, the `Media' menu allows you to specify what kind of media you wish to install from. If a desired media choice is found and configured automatically then this menu will simply return, otherwise you will be asked for additional details on the media device type. Finally, you will be prompted to commit all of these actions at once (nothing has been written to your disk so far, nor will it until you give the final confirmation). All new or changed partition information will be written out, file systems will be created and/or non-destructively labelled (depending on how you set their newfs flags in the Label Editor) and all selected distributions will be extracted. At this point, you are generally done with the sysinstall utility and can select the final `Quit'. If you are running it as an installer (e.g., before the system is all the way up) then the system will now reboot after you press return one last time. If you selected the boot manager option, you will see a small boot menu with an `F?' prompt. Press the function key for BSD (it will be shown) and you should boot up into FreeBSD off the hard disk. If this fails to happen for some reason, see the Q&A section of the Hardware Guide for possible clues! Custom installation

You can do anything you like in this menu without altering your system except for ``Commit'', which will perform any requests to alter your system you may have made. Some of the menu options will also have direct `Write' commands available for commiting an operation immediately, but they should only be used if you are absolutely sure it is necessary. It is generally better to make your changes and then commit them all at once so that you are left with the option of changing your mind up to the very last minute. If you are confused at any point, the F1 key usually pulls up the right information for the screen you are in. MS-DOS user's Questions and Answers

Many FreeBSD users wish to install FreeBSD on PCs inhabited by MS-DOS. Here are some commonly asked questions about installing FreeBSD on such systems.

Help! I have no space! Do I need to delete everything first? If your machine is already running MS-DOS and has little or no free space available for FreeBSD's installation, all is not lost! You may find the FIPS utility, provided in the tools directory on the FreeBSD CDROM or on the various FreeBSD ftp sites, to be quite useful. FIPS allows you to split an existing MS-DOS partition into two pieces, preserving the original partition and allowing you to install onto the second free piece. You first defragment your MS-DOS partition, using the DOS 6.xx DEFRAG utility or the Norton Disk tools, then run FIPS. It will prompt you for the rest of the information it needs. Afterwards, you can reboot and install FreeBSD on the new free slice. See the Distributions menu for an estimation of how much free space you will need for the kind of installation you want. Can I use compressed MS-DOS filesystems from FreeBSD? No. If you are using a utility such as Stacker(tm) or DoubleSpace(tm), FreeBSD will only be able to use whatever portion of the filesystem you leave uncompressed. The rest of the filesystem will show up as one large file (the stacked/dblspaced file!). Do not remove that file! You will probably regret it greatly! It is probably better to create another uncompressed MS-DOS primary partition and use this for communications between MS-DOS and FreeBSD. Can I run MS-DOS binaries under FreeBSD? Not yet! We would like to add support for this someday, but are still lacking anyone to actually do the work. Ongoing work with Linux's DOSEMU utility may bring this much closer to being a reality sometime soon. Send mail to hackers@freebsd.org if you're interested in joining this effort! However, there is a nice application available in the called pcemu, that allows you to run many basic MS-DOS text-mode binaries by entirely emulating an 8088 CPU. diff --git a/handbook/kernelconfig.sgml b/handbook/kernelconfig.sgml index b8842b9571..58525d9883 100644 --- a/handbook/kernelconfig.sgml +++ b/handbook/kernelconfig.sgml @@ -1,1238 +1,1239 @@ - + Configuring the FreeBSD Kernel

Contributed by &a.jehamby;.6 October 1995. This large section of the handbook discusses the basics of building your own custom kernel for FreeBSD. This section is appropriate for both novice system administrators and those with advanced Unix experience. Why build a custom kernel?

Building a custom kernel is one of the most important rites of passage every Unix system administrator must learn. This process, while time-consuming, will provide many benefits to your FreeBSD system. Unlike the GENERIC kernel, which must support every possible SCSI and network card, along with tons of other rarely used hardware support, a custom kernel only contains support for your PC's hardware. This has a number of benefits: It will take less time to boot because it does not have to spend time probing for hardware which you do not have. A custom kernel often uses less memory, which is important because the kernel is the one process which must always be present in memory, and so all of that unused code ties up pages of RAM that your programs would otherwise be able to use. Therefore, on a system with limited RAM, building a custom kernel is of critical importance. Finally, there are several kernel options which you can tune to fit your needs, and device driver support for things like sound cards which you can include in your kernel but are not present in the GENERIC kernel.

Building and Installing a Custom Kernel

First, let us take a quick tour of the kernel build directory. All directories mentioned will be relative to the main /usr/src/sys directory, which is also accessible through /sys. There are a number of subdirectories here representing different parts of the kernel, but the most important, for our purposes, are i386/conf, where you will edit your custom kernel configuration, and compile, which is the staging area where your kernel will be built. Notice the logical organization of the directory tree, with each supported device, filesystem, and option in its own subdirectory. Also, anything inside the i386 directory deals with PC hardware only, while everything outside the i386 directory is common to all platforms which FreeBSD could potentially be ported to. not a /usr/src/sys directory on your system, then the kernel source has not been been installed. Follow the instructions for installing packages to add this package to your system. Next, move to the i386/conf directory and copy the GENERIC configuration file to the name you want to give your kernel. For example: # cd /usr/src/sys/i386/conf # cp GENERIC MYKERNEL Traditionally, this name is in all capital letters and, if you are maintaining multiple FreeBSD machines with different hardware, it's a good idea to name it after your machine's hostname. We will call it MYKERNEL for the purpose of this example. Now, edit MYKERNEL with your favorite text editor. If you're just starting out, the only editor available will probably be vi, which is too complex to explain here, but is covered well in many books in the . Feel free to change the comment lines at the top to reflect your configuration or the changes you've made to differentiate it from GENERIC. If you've build a kernel under SunOS or some other BSD operating system, much of this file will be very familiar to you. If you're coming from some other operating system such as DOS, on the other hand, the GENERIC configuration file might seem overwhelming to you, so follow the descriptions in the section slowly and carefully. When you're finished, type the following to compile and install your kernel: # /usr/sbin/config MYKERNEL # cd ../../compile/MYKERNEL +# make depend # make # make install The new kernel will be copied to the root directory as /kernel and the old kernel will be moved to /kernel.old. Now, shutdown the system and reboot to use your kernel. In case something goes wrong, there are some instructions at the end of this document. Be sure to read the section which explains how to recover in case your new kernel . to your /dev directory before you can use them. The Configuration File

The general format of a configuration file is quite simple. Each line contains a keyword and one or more arguments. For simplicity, most lines only contain one argument. Anything following a # is considered a comment and ignored. The following sections describe each keyword, generally in the order they are listed in GENERIC, although some related keywords have been grouped together in a single section (such as Networking) even though they are actually scattered throughout the GENERIC file. An exhaustive list of options is present in the LINT configuration file, located in the same directory as GENERIC. Mandatory Keywords

These keywords are required in every kernel you build. machine ``i386''

The first keyword is machine, which, since FreeBSD only runs on Intel 386 and compatible chips, is i386. Note: that any keyword which contains numbers used as text must be enclosed in quotation marks, otherwise config gets confused and thinks you mean the actual number 386. cpu ``cpu_type''

The next keyword is cpu, which includes support for each CPU supported by FreeBSD. The possible values of cpu_type include: I386_CPU I486_CPU I586_CPU and multiple instances of the cpu line may be present with different values of cpu_type as are present in the GENERIC kernel. For a custom kernel, it is best to specify only the cpu you have. If, for example, you have an Intel Pentium, use I586_CPU for cpu_type. ident machine_name

Next, we have ident, which is the identification of the kernel. You should change this from GENERIC to whatever you named your kernel, in this example, MYKERNEL. The value you put in ident will print when you boot up the kernel, so it's useful to give a kernel a different name if you want to keep it separate from your usual kernel (if you want to build an experimental kernel, for example). Note that, as with machine and cpu, enclose your kernel's name in quotation marks if it contains any numbers. Since this name is passed to the C compiler as a -D switch, don't use names like DEBUG, or something that could be confused with another machine or CPU name, like vax. maxusers number

This file sets the size of a number of important system tables. This number is supposed to be roughly equal to the number of simultaneous users you expect to have on your machine. However, under normal circumstances, you will want to set maxusers to at least four, especially if you're using X Windows or compiling software. The reason is that the most important table set by maxusers is the maximum number of processes, which is set to 20 + 16 * maxusers, so if you set maxusers to one, then you can only have 36 simultaneous processes, including the 18 or so that the system starts up at boot time, and the 15 or so you will probably create when you start X Windows. Even a simple task like reading a man page will start up nine processes to filter, decompress, and view it. Setting maxusers to 4 will allow you to have up to 84 simultaneous processes, which should be enough for anyone. If, however, you see the dreaded ``proc table full'' error when trying to start another program, or are running a server with a large number of simultaneous users (like Walnut Creek CDROM's FTP site), you can always increase this number and rebuild. maxuser does not limit the number of users which can log into your machine. It simply sets various table sizes to reasonable values considering the maximum number of users you will likely have on your system and how many processes each of them will be running. One keyword which does limit the number of simultaneous remote logins is . config kernel_name root on root_device

This line specifies the location and name of the kernel. Traditionally the kernel is called vmunix but in FreeBSD, it is aptly named kernel. You should always use kernel for kernel_name because changing it will render numerous system utilities inoperative. The second part of the line specifies the disk and partition where the root filesystem and kernel can be found. Typically this will be wd0 for systems with non-SCSI drives, or sd0 for systems with SCSI drives. General Options

These lines provide kernel support for various filesystems and other options.

This line allows the kernel to simulate a math coprocessor if your computer does not have one (386 or 486SX). If you have a Pentium, a 486DX, or a 386 or 486SX with a separate 387 or 487 chip, you can comment this line out. Note: The normal math coprocessor emulation routines that come with FreeBSD are not very accurate. If you do not have a math coprocessor, and you need the best accuracy, I recommend that you change this option to GPL_MATH_EMULATE to use the superior GNU math support, which is not included by default for licensing reasons. options ``COMPAT_43''

Compatibility with BSD 4.3. Leave this in; some programs will act strangely if you comment this out. options BOUNCE_BUFFERS

ISA devices and EISA devices operating in an ISA compatibilty mode can only perform DMA (Direct Memory Access) to memory below 16 megabytes. This option enables such devices to work in systems with more than 16 megabytes of memory. options UCONSOLE

Allow users to grab the console, useful for X Windows. For example, you can create a console xterm by typing xterm -C, which will display any `write', `talk', and other messages you receive, as well as any console messages sent by the kernel. options SYSVSHM

This option provides for System V shared memory. The most common use of this is the XSHM extension in X Windows, which many graphics-intensive programs (such as the movie player XAnim, and Linux DOOM) will automatically take advantage of for extra speed. If you use X Windows, you'll definitely want to include this. options SYSVSEM

Support for System V semaphores. Less commonly used but only adds a few hundred bytes to the kernel. options SYSVMSG

Support for System V messages. Again, only adds a few hundred bytes to the kernel. ipcs(1) command will tell will list any processes using using each of these System V facilities. Filesystem Options

These options add support for various filesystems. You must include at least one of these to support the device you boot from; typically this will be FFS if you boot from a hard drive, or NFS if you are booting a diskless workstation from Ethernet. You can include other commonly-used filesystems in the kernel, but feel free to comment out support for filesystems you use less often (perhaps the MS-DOS filesystem?), since they will be dynamically loaded from the Loadable Kernel Module directory /lkm the first time you mount a partition of that type. options FFS

The basic hard drive filesystem; leave it in if you boot from the hard disk. options NFS

Network Filesystem. Unless you plan to mount partitions from a Unix file server over Ethernet, you can comment this out. options MSDOSFS

MS-DOS Filesystem. Unless you plan to mount a DOS formatted hard drive partition at boot time, you can safely comment this out. It will be automatically loaded the first time you mount a DOS partition, as described above. Also, the excellent mtools software (in the ports collection) allows you to access DOS floppies without having to mount and unmount them (and does not require MSDOSFS at all). options ``CD9660''

ISO 9660 filesystem for CD-ROMs. Comment it out if you do not have a CD-ROM drive or only mount data CD's occasionally (since it will be dynamically loaded the first time you mount a data CD). Audio CD's do not need this filesystem. options PROCFS

Process filesystem. This is a pretend filesystem mounted on /proc which allows programs like ps(1) to give you more information on what processes are running. options MFS

Memory-mapped file system. This is basically a RAM disk for fast storage of temporary files, useful if you have a lot of swap space that you want to take advantage of. A perfect place to mount an MFS partition is on the /tmp directory, since many programs store temporary data here. To mount an MFS RAM disk on /tmp, add the following line to /etc/fstab and then reboot or type mount /tmp: /dev/wd1s2b /tmp mfs rw 0 0 /dev/wd1s2b with the name of your swap partition, which will be listed in your /etc/fstab as follows: /dev/wd1s2b none swap sw 0 0 /tmp device simultaneously). As such, you may want to avoid it for now. --> Also, the MFS filesystem can not be dynamically loaded, so you must compile it into your kernel if you want to experiment with it. options QUOTA

Enable disk quotas. If you have a public access system, and do not want users to be able to overflow the /home partition, you can establish disk quotas for each user. This code is a little buggy, so do not enable it unless you have to. View the manual page for quota(1) to learn more about disk quotas. Basic Controllers and Devices

These sections describe the basic disk, tape, and CD-ROM controllers supported by FreeBSD. There are separate sections for controllers and cards. controller isa0

All PC's supported by FreeBSD have one of these. If you have an IBM PS/2 (Micro Channel Architecture), then you cannot run FreeBSD at this time. controller pci0

Include this if you have a PCI motherboard. This enables auto-detection of PCI cards and gatewaying from the PCI to the ISA bus. controller fdc0

Floppy drive controller: fd0 is the ``A:'' floppy drive, and fd1 is the ``B:'' drive. ft0 is a QIC-80 tape drive attached to the floppy controller. Comment out any lines corresponding to devices you do not have. ft(8), see the manual page for details. controller wdc0

This is the primary IDE controller. wd0 and wd1 are the master and slave hard drive, respectively. wdc1 is a secondary IDE controller where you might have a third or fourth hard drive, or an IDE CD-ROM. Comment out the lines which do not apply (if you have a SCSI hard drive, you'll probably want to comment out all six lines, for example). controller wcd0

This device provides IDE CD-ROM support. Be sure to leave wdc1 uncommented if your CD-ROM is on its own controller card. To use this, you must also include the line options ATAPI. device npx0 at isa? port ``IO_NPX'' irq 13 vector npxintr

npx0 is the interface to the math coprocessor. If you have a math coprocessor, either an external 80387 or 80487, or a cpu one built in such as an 80486DX or Pentium, then you do not need the option above. device wt0 at isa? port 0x300 bio irq 5 drq 1 vector wtintr

Wangtek and Archive QIC-02/QIC-36 tape drive support Proprietary CD-ROM support

The following drivers are for the so-called proprietary CD-ROM drives. These drives have their own controller card or might plug into a sound card such as the Soundblaster 16. They are not IDE or SCSI. Most older single-speed and double-speed CD-ROMs use these interfaces, while newer quad-speeds are likely to be or . device mcd0 at isa? port 0x300 bio irq 10 vector mcdintr

Mitsumi CD-ROM (LU002, LU005, FX001D). device scd0 at isa? port 0x230 bio

Sony CD-ROM (CDU31, CDU33A). controller matcd0 at isa? port ? bio

Matsushita/Panasonic CD-ROM (sold by Creative Labs for Soundblaster). SCSI Device Support

This section describes the various SCSI controllers and devices supported by FreeBSD. SCSI Controllers

The next ten or so lines include support for different kinds of SCSI controllers. Comment out all except for the one(s) you have: controller bt0 at isa? port ``IO_BT0'' bio irq ? vector btintr

Most Buslogic controllers controller uha0 at isa? port ``IO_UHA0'' bio irq ? drq 5 vector uhaintr

UltraStor 14F and 34F controller ahc0

Adaptec 274x/284x/294x controller ahb0 at isa? bio irq ? vector ahbintr

Adaptec 174x controller aha0 at isa? port ``IO_AHA0'' bio irq ? drq 5 vector ahaintr

Adaptec 154x controller aic0 at isa? port 0x340 bio irq 11 vector aicintr

Adaptec 152x and sound cards using Adaptec AIC-6360 (slow!) controller nca0 at isa? port 0x1f88 bio irq 10 vector ncaintr

ProAudioSpectrum cards using NCR 5380 or Trantor T130 controller sea0 at isa? bio irq 5 iomem 0xc8000 iosiz 0x2000 vector seaintr

Seagate ST01/02 8 bit controller (slow!) controller wds0 at isa? port 0x350 bio irq 15 drq 6 vector wdsintr

Western Digital WD7000 controller controller ncr0

NCR 53C810 and 53C825 PCI SCSI controller options ``SCSI_DELAY=15''

This causes the kernel to pause 15 seconds before probing each SCSI device in your system. If you only have IDE hard drives, you can ignore this, otherwise you'll probably want to lower this number, perhaps to 5 seconds, to speed up booting. Of course if you do this, and FreeBSD has trouble recognizing your SCSI devices, you'll have to raise it back up. controller scbus0

If you have any SCSI controllers, this line provides generic SCSI support. If you do not have SCSI, you can comment this, and the following three lines, out. device sd0

Support for SCSI hard drives. device st0

Support for SCSI tape drives. device cd0

Support for SCSI CD-ROM drives.

Note that the number 0 in the above entries is slightly misleading: all these devices are automatically configured as they are found, regardless of how many of them are hooked up to the SCSI bus(es), and which target IDs they have. If you want to ``wire down'' specific target IDs to particular devices, refer to the appropriate section of the LINT kernel config file. Console, Bus Mouse, and X Server Support

You must choose one of these two console types, and, if you plan to use X Windows, enable the XSERVER option and optionally, a bus mouse or PS/2 mouse device. device sc0 at isa? port ``IO_KBD' tty irq 1 vector scintr

sc0 is the default console driver, which resembles an SCO console. Since most full-screen programs access the console through a terminal database library like termcap, it should not matter much whether you use this or vt0, the VT220 compatible console driver. When you log in, set your TERM variable to ``scoansi'' if full-screen programs have trouble running under this console. device vt0 at isa? port ``IO_KBD'' tty irq 1 vector pcrint

This is a VT220-compatible console driver, backwards compatible to VT100/102. It works well on some laptops which have hardware incompatibilities with sc0. Also, set your TERM variable to ``vt100'' or ``vt220'' when you log in. This driver might also prove useful when connecting to a large number of different machines over the network, where the termcap or terminfo entries for the sc0 device are often not available -- ``vt100'' should be available on virtually any platform. options ``PCVT_FREEBSD=210''

Required with the vt0 console driver. options XSERVER

This includes code required to run the XFree86 X Window Server. device mse0 at isa? port 0x23c tty irq 5 vector ms

Use this device if you have a Logitech or ATI InPort bus mouse card. port is enabled (probably COM1). device psm0 at isa? port ``IO_KBD'' conflicts tty irq 12 vector psmintr

Use this device if your mouse plugs into the PS/2 mouse port. Serial and Parallel Ports

Nearly all systems have these. If you are attaching a printer to one of these ports, the section of the handbook is very useful. If you are using modem, provides extensive detail on serial port configuration for use with such devices. device sio0 at isa? port ``IO_COM1'' tty irq 4 vector siointr

sio0 through sio3 are the four serial ports referred to as COM1 through COM4 in the MS-DOS world. Note that if you have an internal modem on COM4 and a serial port at COM2 you will have to change the IRQ of the modem to 2 (for obscure technical reasons IRQ 2 = IRQ 9) in order to access it from FreeBSD. If you have a multiport serial card, check the manual page for sio(4) for more information on the proper values for these lines. Some video cards (notably those based on S3 chips) use IO addresses of the form 0x*2e8, and since many cheap serial cards do not fully decode the 16-bit IO address space, they clash with these cards, making the COM4 port practically unavailable. Each serial port is required to have a unique IRQ (unless you are using one of the multiport cards where shared interrupts are supported), so the default IRQs for COM3 and COM4 cannot be used. device lpt0 at isa? port? tty irq 7 vector lptintr

lpt0 through lpt2 are the three printer ports you could conceivably have. Most people just have one, though, so feel free to comment out the other two lines if you do not have them. Networking

FreeBSD, as with Unix in general, places a big emphasis on networking. Therefore, even if you do not have an Ethernet card, pay attention to the mandatory options and the dial-up networking support. options INET Networking support. Leave it in even if you do not plan to be connected to a network. Most programs require at least loopback networking (i.e. making network connections within your PC) so this is essentially mandatory. Ethernet cards

The next lines enable support for various Ethernet cards. If you do not have a network card, you can comment out all of these lines. Otherwise, you'll want to leave in support for your particular Ethernet card(s): device de0

Digital Equipment DC21040 PCI Ethernet adapter device cx0 at isa? port 0x240 net irq 15 drq 7 vector cxintr

Cronyx/Sigma multiport sync/async (with Cisco or PPP framing) device ed0 at isa? port 0x280 net irq 5 iomem 0xd8000 vector edintr

Western Digital and SMC 80xx; Novell NE1000 and NE2000; 3Com 3C503 device el0 at isa? port 0x300 net irq 9 vector elintr

3Com 3C501 (slow!) device eg0 at isa? port 0x310 net irq 5 vector egintr

3Com 3C505 device ep0 at isa? port 0x300 net irq 10 vector epintr

3Com 3C509 (buggy) device fe0 at isa? port 0x240 net irq ? vector feintr

Fujitsu MB86960A/MB86965A Ethernet device fea0 at isa? net irq ? vector feaintr

DEC DEFEA EISA FDDI adapter device ie0 at isa? port 0x360 net irq 7 iomem 0xd0000 vector ieintr

AT&T StarLAN 10 and EN100; 3Com 3C507; unknown NI5210 device ix0 at isa? port 0x300 net irq 10 iomem 0xd0000 iosiz 32768 vector ixintr

Intel EtherExpress 16 device le0 at isa? port 0x300 net irq 5 iomem 0xd0000 vector le_intr

Digital Equipment EtherWorks 2 and EtherWorks 3 (DEPCA, DE100, DE101, DE200, DE201, DE202, DE203, DE204, DE205, DE422) device lnc0 at isa? port 0x300 net irq 10 drq 0 vector lncintr

Lance/PCnet cards (Isolan, Novell NE2100, NE32-VL) device ze0 at isa? port 0x300 net irq 5 iomem 0xd8000 vector zeintr

IBM/National Semiconductor PCMCIA ethernet controller. device zp0 at isa? port 0x300 net irq 10 iomem 0xd8000 vector zpintr

3Com PCMCIA Etherlink III pseudo-device loop

loop is the generic loopback device for TCP/IP. If you telnet or FTP to localhost (a.k.a. 127.0.0.1) it will come back at you through this pseudo-device. Mandatory. pseudo-device ether

ether is only needed if you have an Ethernet card and includes generic Ethernet protocol code. pseudo-device sl number

sl is for SLIP (Serial Line Internet Protocol) support. This has been almost entirely supplanted by PPP, which is easier to set up, better suited for modem-to-modem connections, as well as more powerful. The number after sl specifies how many simultaneous SLIP sessions to support. This handbook has more information on setting up a SLIP or . pseudo-device ppp number

ppp is for kernel-mode PPP (Point-to-Point Protocol) support for dial-up Internet connections. There is also version of PPP implemented as a user application that uses the tun and offers more flexibility and features such as demand dialing. If you still want to use this PPP driver, read the section of the handbook. As with the sl device, number specifies how many simultaneous PPP connections to support. pseudo-device tun number

tun is used by the user-mode PPP software. This program is easy to set up and very fast. It also has special features such as automatic dial-on-demand. The number after tun specifies the number of simultaneous PPP sessions to support. See the section of the handbook for more information. pseudo-device bpfilter number

Berkeley packet filter. This pseudo-device allows network interfaces to be placed in promiscuous mode, capturing every packet on a broadcast network (e.g. an ethernet). These packets can be captured to disk and/or examined with the tcpdump(1) program. Note that implementation of this capability can seriously compromise your overall network security. The number after bpfilter is the number of interfaces that can be examined simultaneously. Optional, not recommended except for those who are fully aware of the potential pitfalls. Not all network cards support this capability. Sound cards

This is the first section containing lines that are not in the GENERIC kernel. To include sound card support, you'll have to copy the appropriate lines from the LINT kernel (which contains support for every device) as follows: controller snd0

Generic sound driver code. Required for all of the following sound cards except pca. device pas0 at isa? port 0x388 irq 10 drq 6 vector pasintr

ProAudioSpectrum digital audio and MIDI. device sb0 at isa? port 0x220 irq 7 conflicts drq 1 vector sbintr

SoundBlaster digital audio. irq 7 to, for example, irq 5 and remove the conflicts keyword. Also, you must add the line: options ``SBC_IRQ=5'' device sbxvi0 at isa? drq 5

SoundBlaster 16 digital 16-bit audio. drq 5 keyword appropriately, and then add the line: options "SB16_DMA=6" device sbmidi0 at isa? port 0x330

SoundBlaster 16 MIDI interface. If you have a SoundBlaster 16, you must include this line, or the kernel will not compile. device gus0 at isa? port 0x220 irq 10 drq 1 vector gusintr

Gravis Ultrasound. device mss0 at isa? port 0x530 irq 10 drq 1 vector adintr

Microsoft Sound System. device opl0 at isa? port 0x388 conflicts

AdLib FM-synthesis audio. Include this line for AdLib, SoundBlaster, and ProAudioSpectrum users, if you want to play MIDI songs with a program such as playmidi (in the ports collection). device mpu0 at isa? port 0x330 irq 6 drq 0

Roland MPU-401 stand-alone card. device uart0 at isa? port 0x330 irq 5 vector ``m6850intr''

Stand-alone 6850 UART for MIDI. device pca0 at isa? port ``IO_TIMER1'' tty

Digital audio through PC speaker. This is going to be very poor sound quality and quite CPU-intensive, so you have been warned (but it does not require a sound card). /usr/src/sys/i386/isa/sound/sound.doc. Also, if you add any of these devices, be sure to create the sound . Pseudo-devices

Pseudo-device drivers are parts of the kernel that act like device drivers but do not correspond to any actual hardware in the machine. The pseudo-devices are in that section, while the remainder are here. pseudo-device gzip

gzip allows you to run FreeBSD programs that have been compressed with gzip. This is really only useful when you need to compress FreeBSD programs to fit on a boot floppy. You will probably never need to compress programs on your hard drive in this fashion, so you'll probably want to comment out this line. pseudo-device log

log is used for logging of kernel error messages. Mandatory. pseudo-device pty number

pty is a ``pseudo-terminal'' or simulated login port. It's used by incoming telnet and rlogin sessions, xterm, and some other applications such as emacs. The number indicates the number of ptys to create. If you need more than GENERIC default of 16 simultaneous xterm windows and/or remote logins, be sure to increase this number accordingly, up to a maximum of 64. pseudo-device snp number

Snoop device. This pseudo-device allows one terminal session to watch another using the watch(8) command. Note that implementation of this capability has important security and privacy implications. The number after snp is the total number of simultaneous snoop sessions. Optional. pseudo-device vn

Vnode driver. Allows a file to be treated as a device after being set up with the vnconfig(8) command. This driver can be useful for manipulating floppy disk images and using a file as a swap device (e.g. an MS Windows swap file). Optional. Joystick, PC Speaker, Miscellaneous

This section describes some miscellaneous hardware devices supported by FreeBSD. Note that none of these lines are included in the GENERIC kernel, you'll have to copy them from this handbook or the LINT kernel (which contains support for every device): device joy0 at isa? port ``IO_GAME''

PC joystick device. pseudo-device speaker

Supports IBM BASIC-style noises through the PC speaker. Some fun programs which use this are /usr/sbin/spkrtest, which is a shell script that plays some simple songs, and /usr/games/piano which lets you play songs using the keyboard as a simple piano (this file only exists if you've installed the games package). Also, the excellent text role-playing game NetHack (in the ports collection) can be configured to use this device to play songs when you play musical instruments in the game.

See also the device. Making Device Nodes

Almost every device in the kernel has a corresponding ``node'' entry in the /dev directory. These nodes look like regular files, but are actually special entries into the kernel which programs use to access the device. The shell script /dev/MAKEDEV, which is executed when you first install the operating system, creates nearly all of the device nodes supported. However, it does not create all of them, so when you add support for a new device, it pays to make sure that the appropriate entries are in this directory, and if not, add them. Here is a simple example: Suppose you add the IDE CD-ROM support to the kernel. The line to add is: controller wcd0 This means that you should look for some entries that start with wcd0 in the /dev directory, possibly followed by a letter, such as `c', or preceded by the letter 'r', which means a `raw' device. It turns out that those files are not there, so I must change to the /dev directory and type: # sh MAKEDEV wcd0 When this script finishes, you will find that there are now wcd0c and rwcd0c entries in /dev so you know that it executed correctly. For sound cards, the command: # sh MAKEDEV snd0 creates the appropriate entries. Follow this simple procedure for any other non-GENERIC devices which do not have entries. /dev entries, so you do not need to create these. Also, network cards and SLIP/PPP pseudo-devices do not have entries in /dev at all, so you do not have to worry about these either. If Something Goes Wrong

There are four categories of trouble that can occur when building a custom kernel. They are: Config command fails

If the config command fails when you give it your kernel description, you've probably made a simple error somewhere. Fortunately, config will print the line number that it had trouble with, so you can quickly skip to it with vi. For example, if you see: config: line 17: syntax error you can skip to the problem in vi by typing ``17G'' in command mode. Make sure the keyword is typed correctly, by comparing it to the GENERIC kernel or another reference. Make command fails

If the make command fails, it usually signals an error in your kernel description, but not severe enough for config to catch it. Again, look over your configuration, and if you still cannot resolve the problem, send mail to with your kernel configuration, and it should be diagnosed very quickly. Kernel will not boot

If your new kernel does not boot, or fails to recognize your devices, do not panic! Fortunately, BSD has an excellent mechanism for recovering from incompatible kernels. Simply type the name of the kernel you want to boot from (i.e. ``kernel.old'') at the FreeBSD boot prompt instead of pressing return. When reconfiguring a kernel, it is always a good idea to keep a kernel that is known to work on hand. After booting with a good kernel you can check over your configuration file and try to build it again. One helpful resource is the /var/log/messages file which records, among other things, all of the kernel messages from every successful boot. Also, the dmesg(8) command will print the kernel messages from the current boot. kernel.old because when installing a new kernel, kernel.old is overwritten with the last installed kernel which may be non-functional. Also, as soon as possible, move the working kernel to the proper ``kernel'' location or commands such as ps(1) will not work properly. The proper command to ``unlock'' the kernel file that make installs (in order to move another kernel back permanently) is: # chflags noschg /kernel And, if you want to ``lock'' your new kernel into place, or any file for that matter, so that it cannot be moved or tampered with: # chflags schg /kernel Kernel works, but ps does not work any more!

If you've installed a different version of the kernel from the one that the system utilities have been built with, for example, an experimental ``2.2.0'' kernel on a 2.1.0-RELEASE system, many system-status commands like ps(1) and vmstat(8) will not work any more. You must recompile the libkvm library as well as these utilities. This is one reason it is not normally a good idea to use a different version of the kernel from the rest of the operating system. diff --git a/handbook/nfs.sgml b/handbook/nfs.sgml index 2a9b604233..ed4978d4ae 100644 --- a/handbook/nfs.sgml +++ b/handbook/nfs.sgml @@ -1,79 +1,79 @@ - + NFS

Contributed by &a.john;. Certain Ethernet adapters for ISA PC systems have limitations which can lead to serious network problems, particularly with NFS. This difficulty is not specific to FreeBSD, but FreeBSD systems are affected by it. The problem nearly always occurs when (FreeBSD) PC systems are networked with high-performance workstations, such as those made by Silicon Graphics, Inc., and Sun Microsystems, Inc. The NFS mount will work fine, and some operations may succeed, but suddenly the server will seem to become unresponsive to the client, even though requests to and from other systems continue to be processed. This happens to the client system, whether the client is the FreeBSD system or the workstation. On many systems, there is no way to shut down the client gracefully once this problem has manifested itself. The only solution is often to reset the client, because the NFS situation cannot be resolved. Though the "correct" solution is to get a higher performance and capacity Ethernet adapter for the FreeBSD system, there is a simple workaround that will allow satisfactory operation. If the FreeBSD system is the SERVER, include the option "wsize=1024" on the mount from the client. If the FreeBSD system is the CLIENT, then mount the NFS file system with the option "rsize=1024". These options may be specified using the fourth field of the fstab entry on the client for automatic mounts, or by using the "-o" parameter of the mount command for manual mounts. In the following examples, "fastws" is the host (interface) name of a high-performance workstation, and "freebox" is the host (interface) name of a FreeBSD system with a lower-performance Ethernet adapter. Also, "/sharedfs" will be the exported NFS filesystem (see "man exports"), and "/project" will be the mount point on the client for the exported file system. In all cases, note that additional options, such as "hard" or "soft" and "bg" may be desirable in your application. Examples for the FreeBSD system ("freebox") as the client: - in /etc/fstab on freebox: + in /etc/fstab on freebox: fastws:/sharedfs /project nfs rw,rsize=1024 0 0 as a manual mount command on freebox: mount -t nfs -o rsize=1024 fastws:/sharedfs /project Examples for the FreeBSD system as the server: - in /etc/fstab on fastws: + in /etc/fstab on fastws: freebox:/sharedfs /project nfs rw,wsize=1024 0 0 as a manual mount command on fastws: mount -t nfs -o wsize=1024 freebox:/sharedfs /project Nearly any 16-bit Ethernet adapter will allow operation without the above restrictions on the read or write size. For anyone who cares, here is what happens when the failure occurs, which also explains why it is unrecoverable. NFS typically works with a "block" size of 8k (though it may do fragments of smaller sizes). Since the maximum Ethernet packet is around 1500 bytes, the NFS "block" gets split into multiple Ethernet packets, even though it is still a single unit to the upper-level code, and must be received, assembled, and ACKNOWLEDGED as a unit. The high-performance workstations can pump out the packets which comprise the NFS unit one right after the other, just as close together as the standard allows. On the smaller, lower capacity cards, the later packets overrun the earlier packets of the same unit before they can be transferred to the host and the unit as a whole cannot be reconstructed or acknowledged. As a result, the workstation will time out and try again, but it will try again with the entire 8K unit, and the process will be repeated, ad infinitum. By keeping the unit size below the Ethernet packet size limitation, we ensure that any complete Ethernet packet received can be acknowledged individually, avoiding the deadlock situation. Overruns may still occur when a high-performance workstations is slamming data out to a PC system, but with the better cards, such overruns are not guaranteed on NFS "units". When an overrun occurs, the units affected will be retransmitted, and there will be a fair chance that they will be received, assembled, and acknowledged. diff --git a/handbook/porting.sgml b/handbook/porting.sgml index 0a24455f80..bc40ca21d4 100644 --- a/handbook/porting.sgml +++ b/handbook/porting.sgml @@ -1,1010 +1,1010 @@ - + Porting applications

Contributed by &a.jkh;, &a.gpalmer; and &a.asami;.19 August 1995. Here are the guidelines one should follow in creating a new port for FreeBSD 2.x . This documentation will change as this process is progressively refined, so watch this space for details. The ${..} variable names you see in this document all refer to various user-overridable defaults used (and documented) by /usr/share/mk/bsd.port.mk. Please refer to that file for more details. - Before Starting the Port + Before Starting the Port

Note: Only a fraction of the overridable variables are mentioned in this document. Most (if not all) are documented at the start of the bsd.port.mk file which can be found in /usr/share/mk. This file uses a non-standard tab setting. Emacs should recognize the setting on loading the file. vi or ex can be set to using the correct value by typing `:set tabstop=4' once the file has been loaded.

You may come across code that needs modifications or conditional compilation based upon what version of UNIX it's running under. If you need to make such changes to the code for conditional compilation, make sure you make the changes as general as possible so that we can back-port code to FreeBSD 1.x systems and cross-port to other BSD systems such as 4.4BSD from CSRG, BSD/386, 386BSD and NetBSD.

The preferred way to tell 4.3BSD/Reno and newer versions of the BSD code apart is by using the `BSD' macro defined in <sys/param.h>. Hopefully that file is already included; if not, add the code: #ifdef _HAVE_PARAM_H #include #endif to the proper place in the .c file and add -D_HAVE_PARAM_H to the CFLAGS in the Makefile. Then, you may use: #if (defined(BSD) && (BSD >= 199103)) to detect if the code is being compiled on a 4.3 Net2 code base or newer (e.g. FreeBSD 1.x, 4.3/Reno, NetBSD 0.9, 386BSD, BSD/386 1.1 and below). Use: #if (defined(BSD) && (BSD >= 199306)) to detect if the code is being compiled on a 4.4 code base or newer (e.g. FreeBSD 2.x, 4.4, NetBSD 1.0, BSD/386 2.0 or above).

Use sparingly: __FreeBSD__ is defined in all versions of FreeBSD. Use it if the change you are making ONLY affects FreeBSD. Porting gotchas like the use of sys_errlist[] vs strerror() are Berkeleyisms, not FreeBSD changes. In FreeBSD 2.x, __FreeBSD__ is defined to be 2. In earlier versions, it's 1. If you need to tell the difference between a FreeBSD 1.x system and a FreeBSD 2.x system, usually the right answer is to use the BSD macros described above. If there actually is a FreeBSD specific change (such as special shared library options when using `ld') then it's OK to use __FreeBSD__ and `#if __FreeBSD_ > 1' to detect a FreeBSD 2.x system.

In the dozens of ports that have been done, there have only been one or two cases where __FreeBSD__ should have been used. Just because an earlier port screwed up and used it in the wrong place doesn't mean you should do so too. Quick Porting

This section tells you how to do a quick port. In many cases, it is not enough, but we'll see.

First, get the original tarball and put it into ${DISTDIR}, which defaults to /usr/ports/distfiles.

Note: The following assumes that the software compiled out-of-the-box, i.e., there was absolutely no change required for the port to work on your FreeBSD box. If you needed to change something, you'll have to refer to the next section too. Writing the Makefile

The minimal Makefile would look something like this: # New ports collection makefile for: oneko # Version required: 1.1b # Date created: 5 December 1994 # Whom: asami # - # $Id: porting.sgml,v 1.9 1995-12-04 08:11:58 asami Exp $ + # $Id: porting.sgml,v 1.10 1995-12-04 17:58:44 jfieber Exp $ # DISTNAME= oneko-1.1b CATEGORIES+= games MASTER_SITES= ftp://ftp.cs.columbia.edu/archives/X11R5/contrib/ MAINTAINER= asami@FreeBSD.ORG USE_IMAKE= yes .include

See if you can figure it out. Don't worry about the contents of the $Id$ line, it will be filled in automatically by CVS when the port is imported to our main ports tree. Writing the description files

There are three required description files that are required for any port, whether they actually package or not. They are COMMENT, DESCR, and PLIST, and reside in the pkg subdirectory. COMMENT

This is the one-line description of the port. It is recommended to not have the name of the package at the beginning, as in: A cat chasing a mouse all over the screen DESCR

This is a longer description of the port. One to a few paragraphs concisely explaining what the port does is sufficient. Note: This is not a manual nor an in-depth description on how to use or compile the port. In particular, please do not just copy the README file here, unless, of course, it's a concise description of the port.

It is recommended that you sign the name at the end of this file, as in: This is a port of oneko, in which a cat chases a poor mouse all over the screen. : (etc.) - Satoshi asami@cs.berkeley.edu PLIST

This file lists all the files installed by the port. It is also called the `packing list' because the package is generated by packing the files listed here. The pathnames are relative to the installation prefix (usually /usr/local or /usr/X11R6).

Here is a small example: bin/oneko man/man1/oneko.1.gz lib/X11/app-defaults/Oneko lib/X11/oneko/cat1.xpm lib/X11/oneko/cat2.xpm lib/X11/oneko/mouse.xpm Creating the checksum file

Just type `make makesum'. The ports make rules will automatically generate the file files/md5. Testing the port

You should make sure that the port rules do exactly what you want it to do, including packaging up the port. Try doing `make install', `make package' and then `pkg_delete -d <pkgname>' and see if all the files are correctly deleted. Then do a `pkg_add <pkgname>.tgz' and see if everything re-appears and works correctly. Submitting the port

Now that you're happy with your port, the only thing remaining is to put it in the main FreeBSD ports tree and make everybody else happy about it too. To accomplish this, pack the necessary files (everything described in this section -- in particular do not include the original source tarball or the `work' subdirectory) into a .tar.gz file, stick it in the directory ftp://ftp.freebsd.org/pub/FreeBSD/incoming/ and send mail to ports@freebsd.org. We will take a look, get back to you if necessary, and put it in the tree. Your name will also appear in the list of `Additional FreeBSD contributors' on the FreeBSD Handbook and other files. Isn't that great?!? :) Slow Porting

Ok, so it wasn't that simple, and the port required some modifications to get it to work. In this section, we'll explain, step by step, how to modify it to get it to work with the ports paradigm. How things work

First, this is the sequence of events which occurs when the user first types `make' in your port's directory, and you may find that having bsd.port.mk in another window while you read this really helps to understand it.

But don't worry if you don't really understand what bsd.port.mk is doing, not many people do... :> The fetch target is run. The fetch target is responsible for making sure that the tarball exists locally in ${DISTDIR}. If fetch cannot find the required files in ${DISTDIR} it will look up the ftp-URL ${MASTER_SITES}, which is set in the Makefile. It will then attempt to fetch the named distribution file with ${NCFTP}, assuming that the requesting site has direct access to the Internet. If that succeeds, it will save the file in ${DISTDIR} for future use and proceed. The extract target is run. It looks for your ports' distribution file in ${DISTDIR} (typically a gzip'd tarball) and unpacks it into a temporary subdirectory specified by ${WRKDIR} (defaults to work). The patch target is run. First, any patches defined in ${PATCHFILES} are applied. Second, if any patches are found in ${PATCHDIR} (defaults to the patches subdirectory), they are applied at this time in alphabetical order. The configure target is run. This can do any one of many different things. If it exists, scripts/configure is run. If ${HAS_CONFIGURE} or ${GNU_CONFIGURE} is set, ${WRKSRC}/configure is run. If ${USE_IMAKE} is set, ${XMKMF} (default: `xmkmf -a') is run. The build target is run. This is responsible for descending into the ports' private working directory (${WRKSRC}) and building it. If ${USE_GMAKE} is set, GNU make will be used, otherwise the system make will be used.

The above are the default actions. In addition, you can define targets `pre-<something>' or `post-<something>', or put scripts with those names, in the scripts subdirectory, and they will be run before or after the default actions are done.

For example, if you have a post-extract target defined in your Makefile, and a file pre-build in the scripts subdirectory, the post-extract target will be called after the regular extraction actions, and the pre-build script will be executed before the default build rules are done. It is recommended that you use Makefile targets if possible, because it will be easier for someone to figure out what kind of non-default action the port requires.

The default actions are done by the bsd.port.mk targets `do-<something>'. For example, the commands to extract a port are in the target `do-extract'. If you are not happy with the default target, and you can't fix it by redefining the `do-<something>' target in your Makefile.

Note that the `main' targets (e.g., extract, configure, etc.) do nothing more than make sure all the stages up to that one is completed and call the real targets or scripts, and they are not intended to be changed. If you want to fix the extraction, fix do-extract, but never ever touch extract!

Now that you understand what goes on when the user types `make', let's go through the recommended steps to create the perfect port. Getting the original sources

Get the original sources (normally) as a compressed tarball (<foo>.tar.gz or <foo>.tar.Z) and copy it into ${DISTDIR}. Always use mainstream sources when and where you can.

If you can't find a ftp site that is well-connected to the net, or can only find sites that have irritatingly non-standard formats, we can `house' it ourselves by putting it on ftp://freefall.freebsd.org/pub/FreeBSD/LOCAL_PORTS/ as the last resort. Send mail to ports@freebsd.org if you are not sure what to do.

If your port requires some additional `patches' that are available on the Internet, fetch them too and put them in ${DISTDIR}. Don't worry if they come from site other than where you got the the main source tarball, we have a way to handle these situations (see the description of ${PATCHFILES} below). Modifying the port

Unpack a copy of the tarball in a private directory and make whatever changes are necessary to get the port to compile properly under the current version of FreeBSD. Keep careful track of everything you do, as you will be automating the process shortly. Everything, including the deletion, addition or modification of files should be doable using an automated script or patch file when your port is finished.

If your port requires significant user interaction/customization to compile or install, you should take a look at one of Larry Wall's classic Configure scripts and perhaps do something similar yourself. The goal of the new ports collection is to make each port as `plug-and-play' as possible for the end-user while using a minimum of disk space. Patching

In the preparation of the port, files that have been added or changed can be picked up with a recursive diff for later feeding to patch. This is the easiest kind of change to make as it doesn't involve any mucking around with configuration files. Each set of patches you wish to apply should be collected into a file named `patch-<xx>' where <xx> denotes the sequence in which the patches will be applied -- these are done in alphabetical order, thus `aa' first, `ab' second and so on. These files should be stored in ${PATCHDIR}, from where they will be automatically applied. All patches should be relative to ${WRKSRC} (generally the directory your port's tarball unpacks itself into, that being where the make is done). To make fixes and upgrades easier you should avoid having more than one patch fix the - same file (e.g., patch-ab and patch-ab both changing + same file (e.g., patch-aa and patch-ab both changing ${WRKSRC}/foobar.c). Configuring

Include any additional customization commands to your configure script and save it in the `scripts' subdirectory. As mentioned above, you can also do this as Makefile targets and/or scripts with the name pre-configure or post-configure. Handling user input

If your port requires user input to build, configure or install, then set IS_INTERACTIVE in your Makefile. This will allow `overnight builds' to skip your port if the user sets the variable BATCH in his environment (and if the user sets the variable INTERACTIVE, then only those ports requiring interaction are built). Configuring the Makefile

Configuring the Makefile is pretty simple, and again we suggest that you look at existing examples before starting. Consider the following problems in sequence as you design your new Makefile: The original source

Does it live in ${DISTDIR} as a standard gzip'd tarball? If so, you can go on to the next step. If not, you should look at overriding any of the ${EXTRACT_CMD}, ${EXTRACT_BEFORE_ARGS}, ${EXTRACT_AFTER_ARGS}, ${EXTRACT_SUFX}, or ${DISTFILE} variables, depending on how alien a format your port's distribution file is. (The most common case is `EXTRACT_SUFX=.tar.Z', when the tarball is condensed by regular compress, not gzip.)

In the worst case, you can simply create your own `do-extract' target to override the default, though this should be rarely, if ever, necessary. DISTNAME

You should set ${DISTNAME} to be the base name of your port. The default rules expect the distribution file list (${DISTFILES}) to be named ${DISTFILE}${EXTRACT_SUFX} by default which, if it's a normal tarball, is going to be something like: foozolix-1.0.tar.gz for a setting of `DISTNAME=foozolix-1.0'. The default rules also expect the tarball(s) to extract into a subdirectory called work/${DISTNAME}, e.g. work/foozolix-1.0/ All this behavior can be overridden, of course, it simply represents the most common time-saving defaults. For a port requiring multiple distribution files, simply set ${DISTFILES} explicitly. If only a subset of ${DISTFILES} are actual extractable archives, then set them up in ${EXTRACT_ONLY}, which will override the ${DISTFILES} list when it comes to extraction, and the rest will be just left in ${DISTDIR} for later use. CATEGORIES and KEYWORDS

When a package is created, it is put under /usr/ports/packages/All and links are made from one or more subdirectories of /usr/ports/packages. The names of these subdirectories are specified by the variable ${CATEGORIES}. It is intended to make life easier for the user when he is wading through the pile of packages on the ftp site or the CD-ROM. Please take a look at the existing categories (some of them have different names from subdirectories of /usr/ports) and pick the ones that are suitable for your port. If your port truly belongs to something that is different from all the existing ones, you can even create a new category name.

If you want to add more information than just the category names, add them to ${KEYWORDS}. The value of this variable defaults to that of ${CATEGORIES}. This is currently used only as a field of the /usr/ports/INDEX file. MASTER_SITES

If you have a ftp-URL pointing at the the original tarball, record the directory containing the tarball in ${MASTER_SITES}. This will provide a backup site, as well as a direct pointer to the original source location. Don't forget the trailing slash (/)!

The make macros will try to use this specification for grabbing the distribution file with ${NCFTP} if they can't find it already on the system.

It is recommended that you put multiple sites on this list, preferably from different continents. This will safeguard against wide-area network problems, and we are even planning to add support for automatically determining the closest master site and fetching from there! PATCHFILES

If your port requires some additional patches that are available by ftp, set ${PATCHFILES} to the names of the files and ${PATCH_SITES} to the URL of the directory that contains them (the format is the same as ${MASTER_SITES}).

If the patch is not relative to the top of the source tree (i.e., ${WKRSRC}) because it contains some extra pathnames, set ${PATCH_DIST_STRIP} accordingly. For instance, if all the pathnames in the patch has an extra `foozolix-1.0/' in front of the filenames, then set `PATCH_DIST_STRIP=-p1'.

Don't worry if the patches are compressed, they will be decompressed automatically if the filenames end with `.gz' or `.Z'. MAINTAINER

Set your mail-address here. Please. :) Dependencies

Many ports depend on other ports. There are five variables that you can use to ensure that all the required bits will be on the user's machine. LIB_DEPENDS

This variable specifies the shared libraries this port depends on. It is a list of `lib:dir' pairs where lib is the name of the shared library, and dir is the directory in which to find it in case it's not available. For example, LIB_DEPENDS= tcl\\.7\\.:${PORTSDIR}/lang/tcl will check for a shared tcl library with major version 7, and descend into the lang/tcl subdirectory of your ports tree to build and install it if it's not found. Note that the lib part is just an argument given to `ldconfig -r | grep', so periods should be escaped by two backslashes like in the example above. RUN_DEPENDS

This variable specifies executables this port depends on during run-time. It is a list of `exec:dir' pairs where exec is the name of the executable, and dir is the directory in which to find it in case it's not available. For example, RUN_DEPENDS= wish:${PORTSDIR}/x11/tk will check for an executable called `wish', and descend into the x11/tk subdirectory of your ports tree to build and install it if it's not found. The dependency is checked from within the install target. Also, the name of the dependency is put in to the package so that pkg_add will automatically install it if it is not on the user's system. BUILD_DEPENDS

This variable specifies executables this port requires to build. Like RUN_DEPENDS, it is a list of `exec:dir' pairs. For example, BUILD_DEPENDS= unzip:${PORTSDIR}/archivers/unzip will check for an executable called `unzip', and descend into the archivers/unzip subdirectory of your ports tree to build and install it if it's not found. Note that `build' here means everything from extracting to compilation. The dependency is checked from within the extract target. FETCH_DEPENDS

This variable specifies executables this port requires to fetch. Like the previous two, it is a list of `exec:dir' pairs. For example, FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2 will check for an executable called `ncftp2', and descend into the net/ncftp2 subdirectory of your ports tree to build and install it if it's not found. The dependency is checked from within the fetch target. DEPENDS

If there is a dependency that doesn't fall into either of the above four categories, or your port requires to have the source of the other port extracted (i.e., having them installed is not enough), then use this variable. This is just a list of directories, as there is nothing to check, unlike the previous two. Building mechanisms

If your package uses GNU make, set `USE_GMAKE=yes'. If your package uses GNU configure, set `GNU_CONFIGURE=yes'. If you want to override the default GNU configure arguments from `--prefix=${PREFIX}' to something else, set those arguments in ${CONFIGURE_ARGS}.

If your package uses imake (e.g. is an X application that has an Imakefile), then set `USE_IMAKE=yes'. This will cause the configure stage to automatically do an xmkmf -a. If the `-a' flag is a problem for your port, set `XMKMF=xmkmf'.

If your port's source Makefile has something else than `all' as the main build target, set ${ALL_TARGET} accordingly. Same goes for `install' and ${INSTALL_TARGET}. NO_INSTALL_MANPAGES

If the port uses imake but doesn't understand the `install.man' target, `NO_INSTALL_MANPAGES=yes' should be set. In addition, the author of the original port should be shot. Licensing Problems

Some software packages have restrictive licenses or are in violation to the law (PKP's patent on public key crypto, ITAR (export of crypto software) to name just two of them). What we can do with them vary a lot, depending on the exact wordings of the respective licenses.

Note that it is your responsibility as a porter to read the licensing terms of the software and make sure that the FreeBSD project won't held accountable of violating them by redistributing the source or compiled binaries either via ftp or CD-ROM. If in doubt, please contact ports@freebsd.org.

We usually get around this problem by setting ${NO_PACKAGE} in the Makefile, and not putting the distfile up for ftp. However, for most cases, you should at least be able to make a port, so don't let the license scare you away!

Note: The GNU General Public License (GPL), both version 1 and 2, shouldn't be a problem for ports.

Note: If you are a committer, make sure you update the ports/LEGAL file too. * Upgrading

This section is still under construction, sorry. Do's and Dont's

Here's a list of common do's and dont's that you encounter during the porting process. WRKDIR

Don't leave anything valuable lying around in the `work' subdirectory, `make clean' will nuke it completely! If you need auxiliary files that aren't scripts or patches, put them in the subdirectory `files' and use the post-extract target to copy them to the `work' subdirectory. Package information

Do install package information, i.e., the three files in pkg. Note that these files are not used only for packaging anymore, and are mandatory now, even if ${NO_PACKAGE} is set. Compress manpages, strip binaries

Do compress manpages and strip binaries. If the original source already does that, fine; otherwise, you can add a post-install rule to do it yourself. Make sure that you check the variable NOMANCOMPRESS that the user can set in /etc/make.conf to disable man page compression. Here's an example: post-install: strip ${PREFIX}/bin/xdl .if !defined(NOMANCOMPRESS) gzip -9nf ${PREFIX}/man/man1/xdl.1 .endif

Use the file command on the installed executable to check whether the binary is stripped or not. If it doesn't say `not stripped', it is stripped. Custom utilities

Don't rely on custom utilities in your local configure script or anything -- they may not be there on the user's system! If you really need something else to be installed before you can work, detect this from your configure script, print a helpful message and exit with a non-zero status! At least you'll have given the user some idea of what's needed. If the custom utility or package is actually part of the ports tree, this should be dealt by the dependency mechanism of ports.

Actually, if this utility is not part of the ports tree you should probably make a port of this utility (this is how many of the ports made it into the tree!). Depending on something that is not part of the main FreeBSD distribution or the ports tree is a bad idea, and the user should be able to go to any subdirectory of /usr/ports and type `make' and have that port, as well as everything it requires, built automatically. Feedback

Do send applicable changes/patches to the original author/maintainer for inclusion in next release of the code. This will only make your job that much easier for the next release. RCS strings

Don't put RCS strings in patches. CVS will mangle them when we put the files into the ports tree, and when we check them out again, they will come out different and the patch will fail. RCS strings are surrounded by dollar (`$') signs, and typically start with `$Id' or `$RCS'. Recursive diff

Using the recurse (`-r') option to diff to generate patches is fine, but please take a look at the resulting patches to make sure you don't have any unnecessary junk in there. In particular, diffs between two backup files, Makefiles when the port uses imake or GNU configure, etc., are unnecessary and should be deleted. Also, if you had to delete a file, then you can do it in the post-extract target rather than as part of the patch. PREFIX

Do try to make your port install relative to ${PREFIX} in your Makefiles. This will normally be set to /usr/local, or /usr/X11R6 if ${USE_IMAKE} or ${USE_X11} is set, though it can be reassigned in your Makefile or in the users environment, if need be.

Not hard-coding /usr/local anywhere in your installation will make the port much more flexible and cater to the needs of other sites. Note that this doesn't count for package `packing list' files since they have their own scheme for relocating themselves and can be left independent of ${PREFIX} unless the package is one that hard-codes itself to a compiled-in location. Subdirectories

Try to let the port put things in the right subdirectories of ${PREFIX}. Some ports lump everything and put it in the subdirectory with the port's name, which is incorrect. Also, many ports put everything except binaries, header files and manual pages in the a subdirectory of `lib', which does not bode well with the BSD paradigm. Many of the files should me moved to one of the following: `etc' (setup/configuration files), `libexec' (executables started internally), `sbin' (executables for superusers/managers) or `share' (architecture independent files). See hier(7) for details, the rule governing /usr pretty much applies to /usr/local too. ldconfig

If your port installs a shared library, add a post-install target to your Makefile that runs `/sbin/ldconfig -m' on the directory where the new library is installed (usually ${PREFIX}/lib) to register it into the shared library cache.

Also, add an @exec line to your pkg/PLIST file so that a user who installed the package can start using the shared library immediately. This line should immediately follow the line for the shared library itself, as in: lib/libtcl.so.7.3 @exec /sbin/ldconfig -m %D/lib

Note: the `-m' option is new since 2.0.5 and 2.1.0-950726-SNAP, so don't be alarmed if it doesn't work on your machine.

Never, ever, ever add a line that says `ldconfig' without any arguments to your Makefile or pkg/PLIST. This will reset the shared library cache to the contents of /usr/lib only, and will royally screw up the user's machine ("Help, xinit doesn't run anymore after I install this port!"). Anybody who does this will be shot and cut into 65,536 pieces by a rusty knife and have his liver chopped out by a bunch of crows and will eternally rot to death in the deepest bowels of hell (not necessarily in that order).... If you are stuck....

Do look at existing examples and the bsd.port.mk file before asking us questions! ;)

Do ask us questions if you have any trouble! Don't just beat your head against a wall! :) A Sample Makefile

Here is a sample Makefile that you can use to create a new port. Make sure you remove all the extra comments (ones between brackets)!

It is recommended that you follow this format (ordering of variables, etc.). Not all of the existing Makefiles are in this format (mostly old ones), but we are trying to uniformize how they look. This format is designed so that the most important information is easy to locate. [the header...just to make it easier for us to identify the ports] # New ports collection makefile for: xdvi # Version required: 2.2 [things like "1.5alpha" are fine here too] # Date created: 26 May 1995 [this is the person who did the original port to FreeBSD, in particular, the person who wrote this Makefile] # Whom: Satoshi Asami # - # $Id: porting.sgml,v 1.9 1995-12-04 08:11:58 asami Exp $ + # $Id: porting.sgml,v 1.10 1995-12-04 17:58:44 jfieber Exp $ [ ^^^^ don't worry about this...it will be automatically filled in by CVS when it is committed to our repository] # [section to describe the package itself and main ftp site - DISTNAME is always first, followed by PKGNAME (if necessary), CATEGORIES, KEYWORDs (if necessary) and then MASTER_SITES, and optionally EXTRACT_SUFX or DISTFILES] DISTNAME= xdvi PKGNAME= xdvi-pl18 CATEGORIES+= printing [don't forget the trailing slash ("/")!] MASTER_SITES= ftp://crl.dec.com/pub/X11/contrib/applications/ [set this if the source is not in the standard ".tar.gz" form] EXTRACT_SUFX= .tar.Z [section for distributed patches -- can be empty] PATCH_SITES= ftp://ftp.sra.co.jp/pub/X11/japanese/ PATCHFILES= xdvi-18.patch1.gz xdvi-18.patch2.gz [maintainer; *mandatory*! This is the person (preferably with commit privileges) who a user can contact for questions and bug reports - this person should be the porter or someone who can forward questions to the original porter reasonably promptly. If you really don't want to have your address here, set it to "ports@FreeBSD.ORG".] MAINTAINER= asami@FreeBSD.ORG [dependencies -- can be empty] RUN_DEPENDS= gs:${PORTSDIR}/print/ghostscript LIB_DEPENDS= Xpm\\.4\\.:${PORTSDIR}/graphics/xpm [this section is for other standard bsd.port.mk variables that don't belong to any of the above] [If it extracts to a directory other than ${DISTNAME}...] WRKSRC= ${WRKDIR}/xdvi-new [If it asks questions during configure, build, install...] IS_INTERACTIVE= yes [If it requires "configure" in the distributed source directory to be run...] HAS_CONFIGURE= yes [If it requires GNU make, not /usr/bin/make, to build...] USE_GMAKE= yes [If it is an X application and requires "xmkmf -a" to be run...] USE_IMAKE= yes [et cetera.] [non-standard variables to be used in the rules below] MY_FAVORITE_RESPONSE= "yeah, right" [then the special rules, in the order they are called] pre-fetch: i go fetch something, yeah post-patch: i need to do something after patch, great pre-install: and then some more stuff before installing, wow [and then the epilogue] .include Package Names

The following are the conventions you should follow in naming your packages. This is to have our package directory easy to scan, as there are already lots and lots of packages and users are going to turn away if they hurt their eyes!

If your ${DISTNAME} does not look like `<name>-<version.string.numbers>', set ${PKGNAME} to something in that format. The `<name>' part should be all lowercases, except for a really large package (with lots of programs in it). Things like XFree86 (yes there really is a package of it, check it out) and ImageMagick fall into this category. Otherwise, convert the name (or at least the first letter) to lowercase. If the software in question really is called that way, you can have numbers, hyphens and underscores in the name too. The version string should be a period-separated list of integers and single lowercase alphabets. The only exception is the string `pl' (meaning `patchlevel'), which can be used only when there are no major and minor version numbers in the software.

Here are some (real) examples on how to convert a ${DISTNAME} into a suitable ${PKGNAME}: DISTNAME PKGNAME Reason mule-2.2.2 mule-2.2.2 no prob at all XFree86-3.1.2 XFree86-3.1.2 ditto EmiClock-1.0.2 emiclock-1.0.2 no uppercase names for single programs gmod1.4 gmod-1.4 need hyphen after `' xmris.4.02 xmris-4.02 ditto rdist-1.3alpha rdist-1.3a no strings like `alpha' allowed es-0.9-beta1 es-0.9b1 ditto v3.3beta021.src jpeg-5a what the heck was that anyway? ;) tvtwm tvtwm-pl11 version string always required piewm piewm-1.0 ditto xvgr-2.10pl1 xvgr-2.10.1 `pl' allowed only when no maj/minor numbers

If there is absolutely no trace of version information in the original source and it is unlikely that the original author will ever release another version, just set the version string to `1.0' (like the piewm example above). Otherwise, ask the original author or use the date string (`yy.mm.dd') as the version. That's It, Folks!

Boy, this sure was a long tutorial, wasn't it? Thanks for following us to here, really.

Well, now that you know how to do a port, let's go at it and convert everything in the world into ports! That is the easiest way to start contributing to the FreeBSD Project! :) diff --git a/handbook/ports.sgml b/handbook/ports.sgml index 2dff50c791..483052f0c2 100644 --- a/handbook/ports.sgml +++ b/handbook/ports.sgml @@ -1,239 +1,237 @@ - + The Ports collection

Contributed by &a.gpalmer; and &a.jkh;. Unfortunately, there are more variations of UN*X than most people know of, and hence not all software for UN*X available on the Internet will work on all versions of UN*X (in fact, I can guarantee it!). Hence, some software needs modifications to work under some UN*Xs. The process of making those modifications is known as ``porting'' and the result known as a ``port'' (not to be confused with the sockets on the back of your computer!). What is the FreeBSD Ports Collection?

When 2.0 was released, the FreeBSD Project decided to attempt to automate the process of ``porting'' such software to FreeBSD, and the result is the Ports Collection. The general idea was that a combination of various programming tools already available in the base FreeBSD installation would allow you to simply type `make' for a given port and have the underlying ports mechanism automatically fetch the port from a FreeBSD mirror site, apply any special configuration knowledge to it and then build it to result in a fully working version of the program. The ports collection itself normally doesn't have any of the original source code necessary for the compilation in the tree, just those shell scripts, Makefiles and source code ``diffs'' that are necessary to configure and compile the program under FreeBSD. This keeps the entire system down to a manageable size, with the current system having over 300 ports in the master source tree and yet taking -up less than ten megabytes. +up less than twenty megabytes. How does the system compile with no source code?

The Makefile for a port automatically looks in a central location on your system (usually /usr/ports/distfiles, though this value can be customized) for the associated set of original distribution files that have been ``ported''. Those not found locally are searched for wherever they're generally provided on the Internet. If you have a CDROM distribution of FreeBSD then you've already got them available on your CD for ease of use. See if you have such a CDROM distribution, otherwise skip to . Compiling ports from CDROM

The ports collection is easy to use from CDROM, and all you need to do is to create a "link tree" to it using the lndir(1) command that comes with the XFree86 distribution. Find a location with some free space and create a directory there, and make a symbolic link from /usr/ports to that directory. Then invoke the lndir(1) command with the full pathname of the ``ports'' directory on the CDROM as an argument (this might be, for example, something like: lndir /cdrom/ports). Then you can build ports directly off the CDROM by building them in the link tree you've created. Note that there are some ports for which we can't provide the original source in the CDROM due to licensing limitations. In that case, you'll need to look at the next section (). Compiling ports using an Internet connection

The ports collection can also use an auto-fetch system to keep your ports collection source tree up to date, updating the central ``distfiles'' version for you the next time you compile the port. Of course, this assumes you have a permanent network link or don't mind heavy usage of your telephone. If you don't want heavy network usage when you compile your ports tree, you can pre-fetch the necessary tarballs beforehand and put them into /usr/ports/distfiles by hand. A good way to see what files a port is going to need is to cd to that ports' directory and do a make fetch-list to see what it does. The output of make fetch-list can also be used as a shell script to fetch the ports' tarballs at a well-connected machine. You can also chose to get the source files either from the master FTP site as defined in the relevant Makefile (in the MASTER_SITES line), or some FreeBSD mirror site also carrying a set of distfiles, as does the master FTP site on ftp.FreeBSD.org (aka ftp.cdrom.com) in the directory /pub/FreeBSD/distfiles. Note that the files in that directory are not guaranteed to be kept up to date - this is a volunteer project! We can't make any guarantees about the mirror sites either - they are obviously under independent control and don't even have to mirror the distfiles directory. If you have a non-permanent link, you can fetch all the distfiles by going to the top of the tree and typing ``make fetch''. It doesn't work?!

Oh. You can do one of four (4) things : Fix it yourself. Technical details can be found in . Gripe. This is done by e-mail *ONLY*! The people at Walnut Creek are in no way responsible for the functionality (or lack thereof) of the FreeBSD system as a whole, and especially the ports system, which is mainly contributed by 3rd parties. (If you don't believe me, check the catalogue, especially the line saying "We cannot offer tech-support on this product") The e-mail address is Ports@FreeBSD.org. Please include details of the port, where you got both the port source & distfile(s) from, and what the error was. Note: At time of writing, lang/Sather doesn't seem to work on Pentium machines due to the Intel Curse (aka the Floating Point Division Bug). Please don't tell us about this - gripe to Intel instead - it's their bug! Forget it. This is the easiest for most - very few of the programs in ports can be classified as `essential'! Grab the pre-compiled package from a ftp server. The ``master'' package collection is in: ftp://ftp.FreeBSD.org/pub/FreeBSD/packages/ though check your local mirror first, please! These are more likely to work (on the whole) than trying to compile from source, and a lot faster! Use the pkg_add(1) or pkg_manage(1) program to install them to your system. I've ported a program and I want to make a port out of it. What now? -

See the file GUIDELINES, in: - ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/GUIDELINES - This contains details of the procedure and structure involved. - +

See the that + contain details of the procedure and structure involved. I've got a good port, what now?

Upload the fixed version to ftp://freefall.cdrom.com/pub/incoming or ftp://ftp.FreeBSD.org/pub/FreeBSD/incoming and send e-mail to ports@FreeBSD.org with the filename and details. Someone on the all-volunteer `ports committee' will (hopefully) look it over and commit it to the ports collection if they like the looks of it. I want to leave the compile going overnight, but some ports don't like this.

There is a way around this. Before starting the compilation, type: setenv BATCH yes # (if you use csh/tcsh) or BATCH=yes; export BATCH # (for sh/bash) This should skip ports which need user interaction to build. To compile those ports left out by doing the above, using a different login shell (or unsetting the above BATCH variable), set the INTERACTIVE variable instead (you can use the same statements as above except replace ``BATCH'' with ``INTERACTIVE'') and re-run make. This should now compile only those ports which will definitely ask for user interaction. The ports collection is weak. What can I do to help?

First read the bsd.port.mk file (which may be found in /usr/share/mk/) and the associated bsd.port.subdir.mk file. A lot of the weirdness can be explained properly in there (most of the current weirdness is due to the lack of assumptions about anything, which is necessary due to the generic nature of these files). Also check that you have an up-to-date copy, as the file can change from minute to minute. The most up-to-date copy can be found in: If you find that you still need to go in there and alter things, by all means do so, and then send the diffs to ports@FreeBSD.org if you'd like them to be a part of the default distribution. Please also remember that any changes must respect backwards-compatibility with any and all older Makefiles, unless you want a real nightmare of /usr/ports munging ahead of you! Large scale changes will generally not be warmly welcomed unless all the existing makefiles work without alteration. Sorry! This FAQ is weak. What can I do?

Send changes to ports@FreeBSD.org. Changes are most welcome! This FAQ is also very green and should be considered no more than a `good start' for now. Authors? You can come out of hiding any time now! :-) How do I get more information on all the ports?

One good method is to cd to the top of the ports tree (say /usr/ports) and type: make print-index This will print a summary of all ports in the tree. I've heard of a new checksum system. What is this for?

For various reasons, when using FTP over the Internet to obtain the source code, you may not always end up with the same copy of the code that the original porter worked from, and this can lead to problems. So a simple checksumming system has been employed to try and highlight problems in this area. To check the entire system, go to the top of the ports tree (defaults to /usr/ports) and type make checksum This will give a report on the validity of the files you have FTP'd. If some are missing, the system will attempt to retrieve them before running the checksum routine. The same technique can be applied to a single port. The system will complain if there is no pre-computed checksum available for that port. Not all ports currently have checksums, but this should be cured soon. Some older versions of the system don't recognize the ``checksum'' target. In that case, try the command make check-md5 (``check-md5'' was the pre-cursor to the ``checksum'' target). If neither work, get the latest copies of bsd.port.mk and bsd.port.subdir.mk from and install them in /usr/share/mk. This will get you the latest version of the ports system. diff --git a/handbook/ppp.sgml b/handbook/ppp.sgml index 882adf57d5..7129475533 100644 --- a/handbook/ppp.sgml +++ b/handbook/ppp.sgml @@ -1,372 +1,373 @@ - + Setting up kernel PPP

Contributed by &a.gena;. Before you start setting up PPP on your machine make sure that pppd is located in /usr/sbin and directory /etc/ppp exists. pppd can work in two modes: as a "client" , i.e. you want to connect your machine to outside world via PPP serial connection or modem line. as a "server" , i.e. your machine is located on the network and used to connect other computers using PPP. -In both cases you will need to set up an options file ( /etc/ppp/options -or ~/.ppprc if you have more then one user on your machine that uses -PPP ). +In both cases you will need to set up an options file (/etc/ppp/options +or ~/.ppprc if you have more then one user on your machine that uses +PPP). You also will need some modem/serial software ( preferably kermit ) so you can dial and establish connection with remote host. Working as a PPP client -

I used the following /etc/ppp/options to connect to CISCO terminal server PPP -line. +

I used the following /etc/ppp/options to connect to CISCO terminal +server PPP line. crtscts # enable hardware flow control modem # modem control line noipdefault # remote PPP server must supply your IP address. # if the remote host doesn't send your IP during IPCP # negotiation , remove this option passive # wait for LCP packets domain ppp.foo.com # put your domain name here : # put the IP of remote PPP host here # it will be used to route packets via PPP link # if you didn't specified the noipdefault option # change this line to : defaultroute # put this if you want that PPP server will be your # default router To connect: Dial to the remote host using kermit ( or other modem program ) enter your user name and password ( or whatever is needed to enable PPP on the remote host ) Exit kermit. ( without hanging up the line ) enter: /usr/src/usr.sbin/pppd.new/pppd /dev/tty01 19200 ( put the appropriate speed and device name ) Now your computer is connected with PPP. If the connection fails for some -reasons you can add the "debug" option to the /etc/ppp/options file +reasons you can add the "debug" option to the /etc/ppp/options file and check messages on the console to track the problem -Following /etc/ppp/pppup script will make all 3 stages automatically: +Following /etc/ppp/pppup script will make all 3 stages automatically: #!/bin/sh ps ax |grep pppd |grep -v grep pid=`ps ax |grep pppd |grep -v grep|awk '{print $1;}'` if [ "X${pid}" != "X" ] ; then echo 'killing pppd, PID=' ${pid} kill ${pid} fi ps ax |grep kermit |grep -v grep pid=`ps ax |grep kermit |grep -v grep|awk '{print $1;}'` if [ "X${pid}" != "X" ] ; then echo 'killing kermit, PID=' ${pid} kill -9 ${pid} fi ifconfig ppp0 down ifconfig ppp0 delete kermit -y /etc/ppp/kermit.dial pppd /dev/tty01 19200 -/etc/ppp/kermit.dial is kermit script that dials and makes all +/etc/ppp/kermit.dial is kermit script that dials and makes all necessary authorization on the remote host. ( Example of such script is attached to the end of this document ) -Use the following /etc/ppp/pppdown script to disconnect the PPP line: +Use the following /etc/ppp/pppdown script to disconnect the PPP line: #!/bin/sh pid=`ps ax |grep pppd |grep -v grep|awk '{print $1;}'` if [ X${pid} != "X" ] ; then echo 'killing pppd, PID=' ${pid} kill -TERM ${pid} fi ps ax |grep kermit |grep -v grep pid=`ps ax |grep kermit |grep -v grep|awk '{print $1;}'` if [ "X${pid}" != "X" ] ; then echo 'killing kermit, PID=' ${pid} kill -9 ${pid} fi /sbin/ifconfig ppp0 down /sbin/ifconfig ppp0 delete kermit -y /etc/ppp/kermit.hup /etc/ppp/ppptest -Check if PPP is still running (/usr/etc/ppp/ppptest): +Check if PPP is still running (/usr/etc/ppp/ppptest): #!/bin/sh pid=`ps ax| grep pppd |grep -v grep|awk '{print $1;}'` if [ X${pid} != "X" ] ; then echo 'pppd running: PID=' ${pid-NONE} else echo 'No pppd running.' fi set -x netstat -n -I ppp0 ifconfig ppp0 -Hangs up modem line (/etc/ppp/kermit.hup): +Hangs up modem line (/etc/ppp/kermit.hup): set line /dev/tty01 ; put your modem device here set speed 19200 set file type binary set file names literal set win 8 set rec pack 1024 set send pack 1024 set block 3 set term bytesize 8 set command bytesize 8 set flow none pau 1 out +++ inp 5 OK out ATH0\13 echo \13 exit Working as a PPP server -

/etc/ppp/options: +

/etc/ppp/options: crtscts # Hardware flow control netmask 255.255.255.0 # netmask ( not required ) 192.114.208.20:192.114.208.165 # ip's of local and remote hosts # local ip must be different from one # you assigned to the ethernet ( or other ) # interface on your machine. # remote IP is ip address that will be # assigned to the remote machine domain ppp.foo.com # your domain passive # wait for LCP modem # modem line -Following /etc/ppp/pppserv script will enable ppp server on your machine +Following /etc/ppp/pppserv script will enable ppp server on your +machine #!/bin/sh ps ax |grep pppd |grep -v grep pid=`ps ax |grep pppd |grep -v grep|awk '{print $1;}'` if [ "X${pid}" != "X" ] ; then echo 'killing pppd, PID=' ${pid} kill ${pid} fi ps ax |grep kermit |grep -v grep pid=`ps ax |grep kermit |grep -v grep|awk '{print $1;}'` if [ "X${pid}" != "X" ] ; then echo 'killing kermit, PID=' ${pid} kill -9 ${pid} fi # reset ppp interface ifconfig ppp0 down ifconfig ppp0 delete # enable autoanswer mode kermit -y /etc/ppp/kermit.ans # run ppp pppd /dev/tty01 19200 -Use this /etc/ppp/pppservdown script to stop ppp server: +Use this /etc/ppp/pppservdown script to stop ppp server: #!/bin/sh ps ax |grep pppd |grep -v grep pid=`ps ax |grep pppd |grep -v grep|awk '{print $1;}'` if [ "X${pid}" != "X" ] ; then echo 'killing pppd, PID=' ${pid} kill ${pid} fi ps ax |grep kermit |grep -v grep pid=`ps ax |grep kermit |grep -v grep|awk '{print $1;}'` if [ "X${pid}" != "X" ] ; then echo 'killing kermit, PID=' ${pid} kill -9 ${pid} fi ifconfig ppp0 down ifconfig ppp0 delete kermit -y /etc/ppp/kermit.noans Following kermit script will enable/disable autoanswer mode -on your modem (/etc/ppp/kermit.ans): +on your modem (/etc/ppp/kermit.ans): set line /dev/tty01 set speed 19200 set file type binary set file names literal set win 8 set rec pack 1024 set send pack 1024 set block 3 set term bytesize 8 set command bytesize 8 set flow none pau 1 out +++ inp 5 OK out ATH0\13 inp 5 OK echo \13 out ATS0=1\13 ; change this to out ATS0=0\13 if you want to disable ; autoanswer mod inp 5 OK echo \13 exit -This /etc/ppp/kermit.dial script is used for dialing and authorizing on remote host. -You will need to customize it for your needs. +This /etc/ppp/kermit.dial script is used for dialing and authorizing +on remote host. You will need to customize it for your needs. Put your login and password in this script , also you'll need to change input statement depending on responses from your modem and remote host. ; ; put the com line attached to the modem here: ; set line /dev/tty01 ; ; put the modem speed here: ; set speed 19200 set file type binary ; full 8 bit file xfer set file names literal set win 8 set rec pack 1024 set send pack 1024 set block 3 set term bytesize 8 set command bytesize 8 set flow none set modem hayes set dial hangup off set carrier auto ; Then SET CARRIER if necessary, set dial display on ; Then SET DIAL if necessary, set input echo on set input timeout proceed set input case ignore def \%x 0 ; login prompt counter goto slhup :slcmd ; put the modem in command mode echo Put the modem in command mode. clear ; Clear unread characters from input buffer pause 1 output +++ ; hayes escape sequence input 1 OK\13\10 ; wait for OK if success goto slhup output \13 pause 1 output at\13 input 1 OK\13\10 if fail goto slcmd ; if modem doesn't answer OK, try again :slhup ; hang up the phone clear ; Clear unread characters from input buffer pause 1 echo Hanging up the phone. output ath0\13 ; hayes command for on hook input 2 OK\13\10 if fail goto slcmd ; if no OK answer, put modem in command mode :sldial ; dial the number pause 1 echo Dialing. output atdt9,550311\13\10 ; put phone number here assign \%x 0 ; zero the time counter :look clear ; Clear unread characters from input buffer increment \%x ; Count the seconds input 1 {CONNECT } if success goto sllogin reinput 1 {NO CARRIER\13\10} if success goto sldial reinput 1 {NO DIALTONE\13\10} if success goto slnodial reinput 1 {\255} if success goto slhup reinput 1 {\127} if success goto slhup if < \%x 60 goto look else goto slhup :sllogin ; login assign \%x 0 ; zero the time counter pause 1 echo Looking for login prompt. :slloop increment \%x ; Count the seconds clear ; Clear unread characters from input buffer output \13 ; ; put your expected login prompt here: ; input 1 {Username: } if success goto sluid reinput 1 {\255} if success goto slhup reinput 1 {\127} if success goto slhup if < \%x 10 goto slloop ; try 10 times to get a login prompt else goto slhup ; hang up and start again if 10 failures :sluid ; ; put your userid here: ; output ppp-login\13 input 1 {Password: } ; ; put your password here: ; output ppp-password\13 input 1 {Entering SLIP mode.} echo quit :slnodial echo \7No dialtone. Check the telephone line!\7 exit 1 ; local variables: ; mode: csh ; comment-start: "; " ; comment-start-skip: "; " ; end: diff --git a/handbook/printing.sgml b/handbook/printing.sgml index 522749b429..aa56d9147e 100644 --- a/handbook/printing.sgml +++ b/handbook/printing.sgml @@ -1,3877 +1,3876 @@ Printing

Contributed by &a.kelly;30 September 1995 In order to use printers with FreeBSD, you'll need to set them up to work with the Berkeley line printer spooling system, also known as the LPD spooling system. It's the standard printer control system in FreeBSD. This section introduces the LPD spooling system, often simply called LPD. If you're already familiar with LPD or another printer spooling system, you may wish to skip to section . What the Spooler Does

LPD controls everything about a host's printers. It's responsible for a number of things: It controls access to attached printers and printers attached to other hosts on the network. It enables users to submit files to be printed; these submissions are known as It prevents multiple users from accessing a printer at the same time by maintaining a It can print It takes care of communications parameters for printers connected on serial ports. It can send jobs over the network to another LPD spooler on another host. It can run special filters to format jobs to be printed for various printer languages or printer capabilities. It can account for printer usage. Through a configuration file, and by providing the special filter programs, you can enable the LPD system to do all or some subset of the above for a great variety of printer hardware. Why You Should Use the Spooler

If you're the sole user of your system, you may be wondering why you should bother with the spooler when you don't need access control, header pages, or printer accounting. While it's possible to enable direct access to a printer, you should use the spooler anyway since LPD prints jobs in the background; you don't have to wait for data to be copied to the printer. LPD can conveniently run a job to be printed through filters to add date/time headers or convert a special file format (such as a TeX DVI file) into a format the printer will understand. You won't have to do these steps manually. Many free and commercial programs that provide a print feature usually expect to talk to the spooler on your system. By setting up the spooling system, you'll more easily support other software you may later add or already have. Setting Up the Spooling System

To use printers with the LPD spooling system, you'll need to set up both your printer hardware and the LPD software. This document describes two levels of setup: See section to learn how to connect a printer, tell LPD how to communicate with it, and print plain text files to the printer. See section to find out how to print a variety of special file formats, to print header pages, to print across a network, to control access to printers, and to do printer accounting. Simple Printer Setup

This section tells how to configure printer hardware and the LPD software to use the printer. It teaches the basics: Section gives some hints on connecting the printer to a port on your computer. Section shows how to setup the LPD spooler configuration file /etc/printcap. If you're setting up a printer that uses a network protocol to accept data to print instead of a serial or parallel interface, see . Although this section is called ``Simple Printer Setup,'' it's actually fairly complex. Getting the printer to work with your computer and the LPD spooler is the hardest part. The advanced options like header pages and accounting are fairly easy once you get the printer working. Hardware Setup

This section tells about the various ways you can connect a printer to your PC. It talks about the kinds of ports and cables, and also the kernel configuration you may need to enable FreeBSD to speak to the printer. If you've already connected your printer and have successfully printed with it under another operating system, you can probably skip to section . Ports and Cables

Nearly all printers you can get for a PC today support one or both of the following interfaces: Parallel interfaces are sometimes known as ``Centronics'' interfaces, named after the connector type on the printer. In general, serial interfaces are slower than parallel interfaces. Parallel interfaces usually offer just one-way communication (computer to printer) while serial gives you two-way. Many newer parallel ports can also receive data from the printer, but only few printers need to send data back to the computer. And FreeBSD doesn't support two-way parallel communication yet. Usually, the only time you need two-way communication with the printer is if the printer speaks PostScript. PostScript printers can be very verbose. In fact, PostScript jobs are actually programs sent to the printer; they needn't produce paper at all and may return results directly to the computer. PostScript also uses two-way communication to tell the computer about problems, such as errors in the PostScript program or paper jams. Your users may be appreciative of such information. Furthermore, the best way to do effective accounting with a PostScript printer requires two-way communication: you ask the printer for its page count (how many pages it's printed in its lifetime), then send the user's job, then ask again for its page count. Subtract the two values and you know how much paper to charge the user. So, which interface should you use? If you need two-way communication, use a serial port. FreeBSD does not yet support two-way communication over a parallel port. If you don't need two-way communication and can pick parallel or serial, prefer the parallel interface. It keeps a serial port free for other peripherals---such as a terminal or a modem---and is faster most of the time. It's also easier to configure. Finally, use whatever works. Parallel Ports

To hook up a printer using a parallel interface, connect the Centronics cable between the printer and the computer. The instructions that came with the printer, the computer, or both should give you complete guidance. Remember which parallel port you used on the computer. The first parallel port is /dev/lpt0 to FreeBSD; the second is /dev/lpt1, and so on. Serial Ports

To hook up a printer using a serial interface, connect the proper serial cable between the printer and the computer. The instructions that came with the printer, the computer, or both should give you complete guidance. If you're unsure what the ``proper serial cable'' is, you may wish to try one of the following alternatives: A A A You should also set up the communications parameters for the printer, usually through front-panel controls or DIP switches on the printer. Choose the highest bps (bits per second, sometimes Software Setup

This section describes the software setup necessary to print with the LPD spooling system in FreeBSD. Here's an outline of the steps involved: Configure your kernel, if necessary, for the port you're using for the printer; section tells you what you need to do. Set the communications mode for the parallel port, if you're using a parallel port; section gives details. Test if the operating system can send data to the printer. Section gives some suggestions on how to do this. Set up LPD for the printer by modifying the file /etc/printcap. Section shows you how. Kernel Configuration

The operating system kernel is compiled to work with a specific set of devices. The serial or parallel interface for your printer is a part of that set. Therefore, it might be necessary to add support for an additional serial or parallel port if your kernel isn't already configured for one. To find out if the kernel you're currently using supports a serial interface, type dmesg | grep sio where sio2 at 0x3e8-0x3ef irq 5 on isa sio2: type 16550A then the kernel supports the port. To find out if the kernel supports a parallel interface, type dmesg | grep lpt where lpt0 at 0x378-0x37f on isa then the kernel supports the port. You might have to reconfigure your kernel in order for the operating system to recognize and use the parallel or serial port you're using for the printer. To add support for a serial port, see the section on kernel configuration. To add support for a parallel port, see that section Adding /dev Entries for the Ports

Even though the kernel may support communication along a serial or parallel port, you'll still need a software interface through which programs running on the system can send and receive data. That's what entries in the /dev directory are for. To add a /dev entry for a port: Become root with the Change to the /dev directory: cd /dev Type ./MAKEDEV where Type ls -l to make sure the device entry got created. Setting the Communication Mode for the Parallel Port

When you're using the parallel interface, you can choose whether FreeBSD should use interrupt-driven or polled communication with the printer. The The The interrupt-driven method is somewhat faster but uses up a precious IRQ line. You should use whichever one works. You can set the communications mode in two ways: by configuring the kernel or by using the To set the communications mode by configuring the kernel: Edit your kernel configuration file. Look for or add an If you want interrupt-driven mode, add the device lpt0 at isa? port? tty irq where If you want polled mode, don't add the device lpt0 at isa? port? tty vector lptintr Save the file. Then configure, build, and install the kernel, then reboot. See for more details. To set the communications mode with Type lptcontrol -i -u to set interrupt-driven mode for Type lptcontrol -p -u to set polled-mode for You could put these commands in your /etc/rc.local file to set the mode each time your system boots. See lptcontrol(8) for more information. Checking Printer Communications

Before proceeding to configure the spooling system, you should make sure the operating system can successfully send data to your printer. It's a lot easier to debug printer communication and the spooling system separately. To test the printer, we'll send some text to it. For printers that can immediately print characters sent to them, the program %!PS 100 100 moveto 300 300 lineto stroke 310 310 moveto /Helvetica findfont 12 scalefont setfont (Is this thing working?) show showpage Checking a Parallel Printer

This section tells you how to check if FreeBSD can communicate with a printer connected to a parallel port. To test a printer on a parallel port: Become root with Send data to the printer. If the printer can print plain text, then use lptest > /dev/lpt where If the printer understands PostScript or other printer language, then send a small program to the printer. Type cat > /dev/lpt Then, line by line, type the program Alternatively, you can put the program in a file and type cat /dev/lpt where You should see something print. Don't worry if the text doesn't look right; we'll fix such things later. Checking a Serial Printer

This section tells you how to check if FreeBSD can communicate with a printer on a serial port. To test a printer on a serial port: Become root with Edit the file /etc/remote. Add the following entry: printer:dv=/dev/ where Here's a sample entry for a printer connected via a serial line to the third serial port at 19200 bps with no parity: printer:dv=/dev/ttyd2:br#19200:pa=none Connect to the printer with tip printer If this step doesn't work, edit the file /etc/remote again and try using /dev/cuaa instead of /dev/ttyd. Send data to the printer. If the printer can print plain text, then use ~$lptest If the printer understands PostScript or other printer language, then send a small program to the printer. Type the program, line by line, Alternatively, you can put the program in a file and type ˜> where You should see something print. Don't worry if the text doesn't look right; we'll fix that later. Enabling the Spooler: The /etc/printcap File

At this point, your printer should be hooked up, your kernel configured to communicate with it (if necessary), and you've been able to send some simple data to the printer. Now, we're ready to configure LPD to control access to your printer. You configure LPD by editing the file /etc/printcap. The LPD spooling system reads this file each time the spooler is used, so updates to the file take immediate effect. The format of the /etc/printcap. The format is identical to other capability files like /usr/share/misc/termcap and /etc/remote. For complete information about the format, see the cgetent(3). The simple spooler configuration consists of the following steps: Pick a name (and a few convenient aliases) for the printer, and put them in the /etc/printcap file; see . Turn off header pages (which are on by default) by inserting the . Make a spooling directory, and specify its location with the . Set the /dev entry to use for the printer, and note it in /etc/printcap with the . Also, if the printer's on a serial port, set up the communication parameters with the . Install a plain text input filter; see Test the setup by printing something with the and . tells how to do this. Naming the Printer

The first (easy) step is to pick a name for your printer. It really doesn't matter whether you choose functional or whimsical names since you can also provide a number aliases for the printer. At least one of the printers specified in the /etc/printcap should have the alias /etc/printcap file. The name of the printer should start in the leftmost column. Separate each alias with a vertical bar and put a colon after the last alias. In the following example, we start with a skeletal /etc/printcap that defines two printers (a Diablo 630 line printer and a Panasonic KX-P4455 PostScript laser printer): # # /etc/printcap for host rose # rattan|line|diablo|lp|Diablo 630 Line Printer: bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4: In this example, the first printer is named Suppressing Header Pages

The LPD spooling system will by default print a /etc/printcap. Here's the example /etc/printcap with # # /etc/printcap for host rose - no header pages anywhere # rattan|line|diablo|lp|Diablo 630 Line Printer:\ :sh: bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ :sh: Note how we used the correct format: the first line starts in the leftmost column, and subsequent lines are indented with a single TAB. Every line in an entry except the last ends in a backslash character. Making the Spooling Directory

The next step in the simple spooler setup is to make a /var/spool. It's not necessary to backup the contents of spooling directories, either. Recreating them is as simple as running mkdir /var/spool/printer-name However, if you have a lot of printers on your network, you might want to put the spooling directories under a single directory that you reserve just for printing with LPD. We'll do this for our two example printers mkdir /var/spool/lpd mkdir /var/spool/lpd/rattan mkdir /var/spool/lpd/bamboo chown daemon.daemon /var/spool/lpd/rattan chown daemon.daemon /var/spool/lpd/bamboo chmod 770 /var/spool/lpd/rattan chmod 770 /var/spool/lpd/bamboo Finally, you need to tell LPD about these directories using the /etc/printcap file. You specify the pathname of the spooling directory with the # # /etc/printcap for host rose - added spooling directories # rattan|line|diablo|lp|Diablo 630 Line Printer:\ :sh:sd=/var/spool/lpd/rattan: bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ :sh:sd=/var/spool/lpd/bamboo: Note that the name of the printer starts in the first column but all other entries describing the printer should be indented with a tab and each line escaped with a backslash. If you don't specify a spooling directory with /var/spool/lpd as a default. Identifying the Printer Device

In section , we identified which entry in the /dev directory FreeBSD will use to communicate with the printer. Now, we tell LPD that information. When the spooling system has a job to print, it will open the specified device on behalf of the filter program (which is responsible for passing data to the printer). List the /dev entry pathname in the /etc/printcap file using the /etc/printcap: # # /etc/printcap for host rose - identified what devices to use # rattan|line|diablo|lp|Diablo 630 Line Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0: bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ :sh:sd=/var/spool/lpd/bamboo:\ :lp=/dev/ttyd5: If you don't specify the /etc/printcap file, LPD uses /dev/lp as a default. /dev/lp currently doesn't exist in FreeBSD. If the printer you're installing is connected to a parallel port, skip to the section . Otherwise, be sure to follow the instructions in the next section. Configuring Spooler Communication Parameters

For printers on serial ports, LPD can set up the bps rate, parity, and other serial communication parameters on behalf of the filter program that sends data to the printer. This is advantageous since It lets you try different communication parameters by simply editing the /etc/printcap file; you don't have to recompile the filter program. It enables the spooling system to use the same filter program for multiple printers which may have different serial communication settings. The following /etc/printcap capabilities control serial communication parameters of the device listed in the br#/ Sets the communications speed of the device to fc#/ Clears the flag bits fs#/ Sets the flag bits xc#/ Clears local mode bits xs#/ Sets local mode bits For more information on the bits for the /usr/include/sys/ioctl_compat.h. When LPD opens the device specified by the bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ :sh:sd=/var/spool/lpd/bamboo:\ :lp=/dev/ttyd5:fs#0x82000c1:xs#0x820: Installing the Text Filter

We're now ready to tell LPD what text filter to use to send jobs to the printer. A . For our simple printer setup, the text filter can be a small shell script that just executes /bin/cat to send the job to the printer. FreeBSD comes with another filter called . First, let's make the shell script /usr/local/libexec/if-simple be a simple text filter. Put the following text into that file with your favorite text editor: #!/bin/sh # # if-simple - Simple text input filter for lpd # Installed in /usr/local/libexec/if-simple # # Simply copies stdin to stdout. Ignores all filter arguments. /bin/cat &ero;&ero; exit 0 exit 2 Make the file executable: chmod 555 /usr/local/libexec/if-simple And then tell LPD to use it by specifying it with the /etc/printcap. We'll add it to the two printers we have so far in the example /etc/printcap: # # /etc/printcap for host rose - added text filter # rattan|line|diablo|lp|Diablo 630 Line Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ :if=/usr/local/libexec/if-simple: bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ :sh:sd=/var/spool/lpd/bamboo:\ :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:\ :if=/usr/local/libexec/if-simple: Trying It Out

You've reached the end of the simple LPD setup. Unfortunately, congratulations are not quite yet in order, since we've still got to test the setup and correct any problems. To test the setup, try printing something. To print with the LPD system, you use the command to generate some test text. To test the simple LPD setup:

Type: lptest 20 5 | lpr -P where /etc/printcap. To test the default printer, type !"#$%&ero;'()*+,-./01234 "#$%&ero;'()*+,-./012345 #$%&ero;'()*+,-./0123456 $%&ero;'()*+,-./01234567 %&ero;'()*+,-./012345678 To further test the printer, try downloading larger programs (for language-based printers) or running . Troubleshooting

After performing the simple test with /usr/local/libexec/if-simple prints a form feed after it sends the job to the printer: #!/bin/sh # # if-simple - Simple text input filter for lpd # Installed in /usr/local/libexec/if-simple # # Simply copies stdin to stdout. Ignores all filter arguments. # Writes a form feed character (\f) after printing job. /bin/cat &ero;&ero; printf "\f" &ero;&ero; exit 0 exit 2 !"#$%&ero;'()*+,-./01234 "#$%&ero;'()*+,-./012345 #$%&ero;'()*+,-./0123456 - $%&ero;'()*+,-./01234567 You've become another victim of the Printer received CR Printer prints CR Printer received LF Printer prints CR + LF Here are some ways to achieve this: Use the printer's configuration switches or control panel to alter its interpretation of these characters. Check your printer's manual to find out how to do this.

Have FreeBSD's serial line driver automatically convert LF to CR+LF. Of course, this works with printers on serial ports /etc/printcap file for the printer. Send an Here's an example text filter for printers that understand the Hewlett-Packard PCL escape codes. This filter makes the printer treat LF characters as a LF and CR; then it sends the job; then it sends a form feed to eject the last page of the job. It should work with nearly all Hewlett Packard printers. #!/bin/sh # # hpif - Simple text input filter for lpd for HP-PCL based printers # Installed in /usr/local/libexec/hpif # # Simply copies stdin to stdout. Ignores all filter arguments. # Tells printer to treat LF as CR+LF. Writes a form feed character # after printing job. printf "\033&ero;k2G" &ero;&ero; cat &ero;&ero; printf "\f" &ero;&ero; exit 0 exit 2 Here's an example /etc/printcap from a host called orchid. It has a single printer attached to its first parallel port, a Hewlett Packard LaserJet 3Si named # # /etc/printcap for host orchid # teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ :lp=/dev/lpt0:sh:sd=/var/spool/lpd/teak:mx#0:\ :if=/usr/local/libexec/hpif: Printer received CR Printer prints CR Printer received LF Printer prints CR + LF If the printer supports XON/XOFF flow control, have FreeBSD use it by specifying the TANDEM bit in the If the printer supports carrier flow control, specify the MDMBUF bit in the If the printer doesn't support any flow control, use some combination of the NLDELAY, TBDELAY, CRDELAY, VTDELAY, and BSDELAY bits in the /etc/printcap file. /etc/printcap file. For example, here's the entry for rattan|line|diablo|lp|Diablo 630 Line Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ :if=/usr/local/libexec/if-simple:\ :lf=/var/log/rattan.log Then, try printing again. Check the log file (in our example, /var/log/rattan.log) to see any error messages that might appear. Based on the messages you see, try to correct the problem. If you don't specify a /dev/console as a default. Using Printers

This section tells you how to use printers you've setup with FreeBSD. Here's an overview of the user-level commands: There's also an administrative command, , used to control printers and their queues. All three of the commands /etc/printcap file. This enables you to submit, remove, and check on jobs for various printers. If you don't use the Printing Jobs

To print files, type lpr This prints each of the listed files to the default printer. If you list no files, lpr /etc/host.conf /etc/hosts.equiv To select a specific printer, type lpr -P This example prints a long listing of the current directory to the printer named ls -l | lpr -P rattan Because no files were listed for the . Checking Jobs

When you print with lpq -P bamboo shows the queue for the printer named bamboo is ready and printing Rank Owner Job Files Total Size active kelly 9 /etc/host.conf, /etc/hosts.equiv 88 bytes 2nd kelly 10 (standard input) 1635 bytes 3rd mary 11 ... 78519 bytes This shows three jobs in the queue for for details. Job number nine consists of two files; multiple files given on the waiting for bamboo to become ready (offline ?) kelly: 1st [job 009rose] /etc/host.conf 73 bytes /etc/hosts.equiv 15 bytes kelly: 2nd [job 010rose] (standard input) 1635 bytes mary: 3rd [job 011rose] /home/orchid/mary/research/venus/alpha-regio/mapping 78519 bytes Removing Jobs

If you change your mind about printing a job, you can remove the job from the queue with the To remove the job from a specific printer, add the lprm -P bamboo 10 The Just use the lprm -P rattan - rose% lpr -P rattan myfile rose% rlogin orchid orchid% lpq -P rattan Rank Owner Job Files Total Size active seeyan 12 ... 49123 bytes 2nd kelly 13 myfile 12 bytes orchid% lprm -P rattan 13 rose: Permission denied orchid% logout rose% lprm -P rattan 13 dfA013rose dequeued cfA013rose dequeued rose% Beyond Plain Text: Printing Options

The Formatting and Conversion Options

The following lpr -P bamboo -d fish-report.dvi These options apply to every file in the job, so you can't mix (say) DVI and ditroff files together in a job. Instead, submit the files as separate jobs, using a different conversion option for each job. gives details. Here's an example: this command prints a nicely formatted version of the zcat /usr/share/man/man1/ls.1.gz | troff -t -man | lpr -t The Job Handling Options

The following options to .

This example prints three copies of lpr -#3 parser.c parser.h Header Page Options

These options to for information about setting up header pages. for details. Administrating Printers

As an administrator for your printers, you've had to install, set up, and test them. Using the Start and stop the printers Enable and disable their queues Rearrange the order of the jobs in each queue. First, a note about terminology: if a printer is /etc/printcap. Advanced Printer Setup

This section describes filters for printing specially formatted files, header pages, printing across networks, and restricting and accounting for printer usage. Filters

Although LPD handles network protocols, queuing, access control, and other aspects of printing, most of the ). However, in order to take advantage of format conversion, printer accounting, specific printer quirks, and so on, you should understand how filters work. It will ultimately be the filter's responsibility to handle these aspects. And the bad news is that most of the time /usr/libexec/lpr/lpf, that works with many printers that can print plain text. (It handles backspacing and tabs in the file, and does accounting, but that's about all it does.) There are also several filters and filter components in the FreeBSD ports collection. Here's what you'll find in this section: Section , tries to give an overview of a filter's role in the printing process. You should read this section to get an understanding of what's happening ``under the hood'' when LPD uses filters. This knowledge could help you anticipate and debug problems you might encounter as you install more and more filters on each of your printers. LPD expects every printer to be able to print plain text by default. This presents a problem for PostScript (or other language-based printers) which can't directly print plain text. Section tells you what you should do to overcome this problem. I recommend reading this section if you have a PostScript printer. PostScript is a popular output format for many programs. Even some people (myself included) write PostScript code directly. But PostScript printers are expensive. Section tells how you can further modify a printer's text filter to accept and print PostScript data on a Section tells about a way you can automate the conversion of specific file formats, such as graphic or typesetting data, into formats your printer can understand. After reading this section, you should be able to set up your printers such that users can type Section tells all about a not often used feature of LPD: output filters. Unless you're printing header pages (see ), you can probably skip that section altogether. Section describes How Filters Work

As mentioned before, a filter is an executable program started by LPD to handle the device-dependent part of communicating with the printer. When LPD wants to print a file in a job, it starts a filter program. It sets the filter's standard input to the file to print, its standard output to the printer, and its standard error to the error logging file (specified in the /etc/printcap, or /dev/console by default). Which filter LPD starts and the filter's arguments depend on what's listed in the /etc/printcap file and what arguments the user specified for the job on the for details). There are three kinds filters you can specify in /etc/printcap: The [-c] -w where /etc/printcap, default 132 A tells all about them. Conversion filters also need to do accounting, if you need printer accounting. Conversion filters are started with the following arguments: -x where The describe them. There are only two arguments to an output filter: -w which are identical to the text filters Filters should also The text filter that comes with the FreeBSD release, /usr/libexec/lpr/lpf, takes advantage of the page width and length arguments to determine when to send a form feed and how to account for printer usage. It uses the login, host, and accounting file arguments to make the accounting entries. If you're shopping for filters, see if they're LPD-compatible. If they are, they must support the argument lists described above. If you plan on writing filters for general use, then have them support the same argument lists and exit codes. Accommodating Plain Text Jobs on PostScript Printers

If you're the only user of your computer and PostScript (or other language-based) printer, and you promise to never send plain text to your printer and to never use features of various programs that will want to send plain text to your printer, then you don't need to worry about this section at all. But, if you would like to send both PostScript and plain text jobs to the printer, then you're urged to augment your printer setup. To do so, we have the text filter detect if the arriving job is plain text or PostScript. All PostScript jobs must start with ); if not, it should be shortly. You can fetch, build and install it yourself, of course. After installing /etc/printcap: :if=/usr/local/libexec/psif: You should also specify the #!/bin/sh # # psif - Print PostScript or plain text on a PostScript printer # Script version; NOT the version that comes with lprps # Installed in /usr/local/libexec/psif # read first_line first_two_chars=`expr "$first_line" : '\(..\)'` if [ "$first_two_chars" = "%!" ]; then # # PostScript job, print it. # echo $first_line &ero;&ero; cat &ero;&ero; printf "\004" &ero;&ero; exit 0 exit 2 else # # Plain text, convert it, then print it. # ( echo $first_line; cat ) | /usr/local/bin/textps &ero;&ero; printf "\004" &ero;&ero; exit 0 exit 2 fi In the above script, ) includes a full featured text-to-PostScript program called Simulating PostScript on Non-PostScript Printers

PostScript is the #!/bin/sh # # ifhp - Print Ghostscript-simulated PostScript on a DesJet 500 # Installed in /usr/local/libexec/hpif # # Treat LF as CR+LF: # printf "\033&ero;k2G" || exit 2 # # Read first two characters of the file # read first_line first_two_chars=`expr "$first_line" : '\(..\)'` if [ "$first_two_chars" = "%!" ]; then # # It's PostScript; use Ghostscript to scan-convert and print it # /usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 -sOutputFile=- - \ &ero;&ero; exit 0 else # # Plain text or HP/PCL, so just print it directly; print a form # at the end to eject the last page. # echo $first_line &ero;&ero; cat &ero;&ero; printf "\f" &ero;&ero; exit 2 fi exit 2 Finally, you need to notify LPD of the filter via the :if=/usr/local/libexec/hpif: That's it. You can type Conversion Filters

After completing the simple setup described in , the first thing you'll probably want to do is install conversion filters for your favorite file formats (besides plain ASCII text). Why Install Conversion Filters?

Conversion filters make printing various kinds of files easy. As an example, suppose we do a lot of work with the TeX typesetting system, and we have a PostScript printer. Every time we generate a DVI file from TeX, we can't print it directly until we convert the DVI file into PostScript. The command sequence goes like this: dvips seaweed-analysis.dvi lpr seaweed-analysis.ps By installing a conversion filter for DVI files, we can skip the hand conversion step each time by having LPD do it for us. Now, each time we get a DVI file, we're just one step away from printing it: lpr -d seaweed-analysis.dvi We got LPD to do the DVI file conversion for us by specifying the lists the conversion options. For each of the conversion options you want a printer to support, install a /etc/printcap. A conversion filter is like the text filter for the simple printer setup (see section ) except that instead of printing plain text, the filter converts the file into a format the printer can understand. Which Conversions Filters Should I Install?

You should install the conversion filters you expect to use. If you print a lot of DVI data, then a DVI conversion filter is in order. If you've got plenty of troff to print out, then you probably want a troff filter. The following table summarizes the filters that LPD works with, their capability entries for the /etc/printcap file, and how to invoke them with the /etc/printcap File type Capability lpr option ------------ ------------- ---------- cifplot cf -c DVI df -d plot gf -g ditroff nf -n FORTRAN text rf -f troff tf -t raster vf -v plain text if none, -p, or -l In our example, using /etc/printcap. Despite what others might contend, formats like FORTRAN text and plot are probably obsolete. At your site, you can give new meanings to these or any of the formatting options just by installing custom filters. For example, suppose you'd like to directly print Printerleaf files (files from the Interleaf desktop publishing program), but will never print plot files. You could install a Printerleaf conversion filter under the Installing Conversion Filters

Since conversion filters are programs you install outside of the base FreeBSD installation, they should probably go under /usr/local. The directory /usr/local/libexec is a popular location, since they they're specialized programs that only LPD will run; regular users shouldn't ever need to run them. To enable a conversion filter, specify its pathname under the appropriate capability for the destination printer in /etc/printcap. In our example, we'll add the DVI conversion filter to the entry for the printer named /etc/printcap file again, with the new # # /etc/printcap for host rose - added df filter for bamboo # rattan|line|diablo|lp|Diablo 630 Line Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ :if=/usr/local/libexec/if-simple: bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ :sh:sd=/var/spool/lpd/bamboo:\ :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ :if=/usr/local/libexec/psif:\ :df=/usr/local/libexec/psdf: The DVI filter is a shell script named /usr/local/libexec/psdf. Here's that script: #!bin/sh # # DVI to PostScript printer filter # Installed in /usr/local/libexec/psdf # # Invoked by lpd when user runs lpr -d # exec /usr/local/bin/dvips -f | /usr/local/libexec/lprps "$@" This script runs ) with the arguments LPD passed to this script. More Conversion Filter Examples

Since there's no fixed set of steps to install conversion filters, let me instead provide more examples. Use these as guidance to making your own filters. Use them directly, if appropriate. This example script is a raster (well, GIF file, actually) conversion filter for a Hewlett Packard LaserJet III-Si printer: #!/bin/sh # # hpvf - Convert GIF files into HP/PCL, then print # Installed in /usr/local/libexec/hpvf PATH=/usr/X11R6/bin:$PATH; export PATH giftopnm | ppmtopgm | pgmtopbm | pbmtolj -resolution 300 \ && exit 0 \ || exit 2 It works by converting the GIF file into a portable anymap, converting that into a portable graymap, converting that into a portable bitmap, and converting that into LaserJet/PCL-compatible data. Here's the /etc/printcap file with an entry for a printer using the above filter: # # /etc/printcap for host orchid # teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ :lp=/dev/lpt0:sh:sd=/var/spool/lpd/teak:mx#0:\ :if=/usr/local/libexec/hpif:\ :vf=/usr/local/libexec/hpvf: The following script is a conversion filter for troff data from the groff typesetting system for the PostScript printer named #!/bin/sh # # pstf - Convert groff's troff data into PS, then print. # Installed in /usr/local/libexec/pstf # exec grops | /usr/local/libexec/lprps "$@" The above script makes use of #!/bin/sh # # pstf - Convert groff's troff data into PS, then print. # Installed in /usr/local/libexec/pstf # exec grops That's it. Here's the entry we need to add to /etc/printcap to enable the filter: :tf=/usr/local/libexec/pstf: Here's an example that might make old hands at FORTRAN blush. It's a FORTRAN-text filter for any printer that can directly print plain text. We'll install it for the printer #!/bin/sh # # hprf - FORTRAN text filter for LaserJet 3si: # Installed in /usr/local/libexec/hprf # printf "\033&ero;k2G" &ero;&ero; fpr &ero;&ero; printf "\f" &ero;&ero; exit 0 exit 2 And we'll add this line to the /etc/printcap for the printer :rf=/usr/local/libexec/hprf: Here's one final, somewhat complex example. We'll add a DVI filter to the LaserJet printer /etc/printcap with the location of the DVI filter: :df=/usr/local/libexec/hpdf: Now, for the hard part: making the filter. For that, we need a DVI-to-LaserJet/PCL conversion program. The FreeBSD ports collection (see ) has one: /dev/fd/0 for standard input is problematic. We can get around that problem by linking (symbolically) a temporary file name (one that ends in /dev/fd/0, thereby forcing /tmp directory has the sticky bit set. The filter can create the link, but it won't be able clean up when done and remove it since the link will belong to a different user. Instead, the filter will make the symbolic link in the current working directory, which is the spooling directory (specified by the /etc/printcap). This is a perfect place for filters to do their work, especially since there's (sometimes) more free disk space in the spooling directory than under /tmp. Here, finally, is the filter: #!/bin/sh # # hpdf - Print DVI data on HP/PCL printer # Installed in /usr/local/libexec/hpdf PATH=/usr/local/bin:$PATH; export PATH # # Define a function to clean up our temporary files. These exist # in the current directory, which will be the spooling directory # for the printer. # cleanup() { rm -f hpdf$$.dvi } # # Define a function to handle fatal errors: print the given message # and exit 2. Exiting with 2 tells LPD to don't try to reprint the # job. # fatal() { echo "$@" 1>&ero;2 cleanup exit 2 } # # If user removes the job, LPD will send SIGINT, so trap SIGINT # (and a few other signals) to clean up after ourselves. # trap cleanup 1 2 15 # # Make sure we're not colliding with any existing files. # cleanup # # Link the DVI input file to standard input (the file to print). # ln -s /dev/fd/0 hpdf$$.dvi || fatal "Cannot symlink /dev/fd/0" # # Make LF = CR+LF # printf "\033&ero;k2G" || fatal "Cannot initialize printer" # # Convert and print. Return value from dvilj2p doesn't seem to be # reliable, so we ignore it. # dvilj2p -M1 -q -e- dfhp$$.dvi # # Clean up and exit # cleanup exit 0 Automated Conversion: An Alternative To Conversion Filters

All these conversion filters accomplish a lot for your printing environment, but at the cost forcing the user to specify (on the Output Filters

The LPD spooling system supports one other type of filter that we've not yet explored: an output filter. An output filter is intended for printing plain text only, like the text filter, but with many simplifications. If you're using an output filter but no text filter, then LPD starts an output filter once for the entire job instead of once for each file in the job. LPD doesn't make any provision to identify the start or the end of files within the job for the output filter. LPD doesn't pass the user's login or host to the filter, so it's not intended to do accounting. In fact, it gets only two arguments: -w where Don't be seduced by an output filter's simplicity. If you'd like each file in a job to start on a different page an output filter . Furthermore, an output filter is actually ) only. LPD then expects the output filter to

The program /usr/libexec/lpr/lpf that comes with FreeBSD binary distribution is a text filter (input filter) that can indent output (job submitted with /etc/printcap file. It uses these values to determine how much text can fit on a page and how many pages were in a user's job. For more information on printer accounting, see . Header Pages

If you've got . Enabling Header Pages

In the , we turned off header pages by specifying /etc/printcap file. To enable header pages for a printer, just remove the #!/bin/sh # # hpof - Output filter for Hewlett Packard PCL-compatible printers # Installed in /usr/local/libexec/hpof printf "\033&ero;k2G" || exit 2 exec /usr/libexec/lpr/lpf Specify the path to the output filter in the for more information. Here's an example /etc/printcap file for the printer # # /etc/printcap for host orchid # teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:\ :if=/usr/local/libexec/hpif:\ :vf=/usr/local/libexec/hpvf:\ :of=/usr/local/libexec/hpof: Now, when users print jobs to for more /etc/printcap. Controlling Header Pages

By enabling header pages, LPD will produce a k ll ll k l l k l l k k eeee l l y y k k e e l l y y k k eeeeee l l y y kk k e l l y y k k e e l l y yy k k eeee lll lll yyy y y y y yyyy ll t l i t l oooo u u ttttt l ii n nnn eeee o o u u t l i nn n e e o o u u t l i n n eeeeee o o u u t l i n n e o o u uu t t l i n n e e oooo uuu u tt lll iii n n eeee r rrr oooo ssss eeee rr r o o s s e e r o o ss eeeeee r o o ss e r o o s s e e r oooo ssss eeee Job: outline Date: Sun Sep 17 11:04:58 1995 LPD appends a form feed after this text so the job starts on a new page (unless you've got /etc/printcap). If you prefer, LPD can make a /etc/printcap file. The header page will look like this: rose:kelly Job: outline Date: Sun Sep 17 11:07:51 1995 Also by default, LPD prints the header page first, then the job. To reverse that, specify /etc/printcap. Accounting for Header Pages

Using LPD's built-in header pages enforces a particular paradigm when it comes to printer accounting: header pages must be Accept LPD's paradigm and make header pages free. Install an alternative to LPD, such as LPDng or PLP. Section tells more about other spooling software you can substitute for LPD. Write a /etc/printcap. Then again, all that might be too much trouble, and users will certainly appreciate the more generous system administrator who makes header pages free. Header Pages on PostScript Printers

As described above, LPD can generate a plain text header page suitable for many printers. Of course, PostScript can't directly print plain text, so the header page feature of LPD is useless---or mostly so. One obvious way to get header pages is to have every conversion filter and the text filter generate the header page. The filters should should use the user and host arguments to generate a suitable header page. The drawback of this method is that users will always get a header page, even if they submit jobs with #!/bin/sh # # make-ps-header - make a PostScript header page on stdout # Installed in /usr/local/libexec/make-ps-header # # # These are PostScript units (72 to the inch). Modify for A4 or # whatever size paper you're using: # page_width=612 page_height=792 border=72 # # Check arguments # if [ $# -ne 3 ]; then echo "Usage: `basename $0` " 1>&ero;2 exit 1 fi # # Save these, mostly for readability in the PostScript, below. # user=$1 host=$2 job=$3 date=`date` # # Send the PostScript code to stdout. # exec cat < Now, each of the conversion filters and the text filter can call this script to first generate the header page, and then print the user's job. Here's the DVI conversion filter from earlier in this document, modified to make a header page: #!/bin/sh # # DVI to PostScript printer filter # Installed in /usr/local/libexec/psdf # # Invoked by lpd when user runs lpr -d # orig_args="$@" fail() { echo "$@" 1>&ero;2 exit 2 } while getopts "x:y:n:h:" option; do case $option in x|y) ;; # Ignore n) login=$OPTARG ;; h) host=$OPTARG ;; *) echo "LPD started `basename $0` wrong." 1>&ero;2 exit 2 ;; esac done [ "$login" ] || fail "No login name" [ "$host" ] || fail "No host name" ( /u/kelly/freebsd/printing/filters/make-ps-header $login $host "DVI File" /usr/local/bin/dvips -f ) | eval /usr/local/libexec/lprps $orig_args Notice how the filter has to parse the argument list in order to determine the user and host name. The parsing for the other conversion filters is identical. The text filter takes a slightly different set of arguments, though (see section ). As we've mentioned before, the above scheme, though fairly simple, disables the ``suppress header page'' option (the : write an output filter that parses the LPD-generated header page and produces a PostScript version. If the user submits the job with Networked Printing

FreeBSD supports networked printing: sending jobs to remote printers. Networked printing generally refers to two different things: Accessing a printer attached to a remote host. You install a printer that has a conventional serial or parallel interface on one host. Then, you set up LPD to enable access to the printer from other hosts on the network. Section tells how to do this. Accessing a printer attached directly to a network. The printer has a network interface in addition (or in place of) a more conventional serial or parallel interface. Such a printer might work as follows: It might understand the LPD protocol and can even queue jobs from remote hosts. In this case, it acts just like a regular host running LPD. Follow the same procedure in section to set up such a printer. It might support a data stream network connection. In this case, you ``attach'' the printer to one host on the network by making that host responsible for spooling jobs and sending them to the printer. Section gives some suggestions on installing such printers. Printers Installed on Remote Hosts

The LPD spooling system has built-in support for sending jobs to other hosts also running LPD (or are compatible with LPD). This feature enables you to install a printer on one host and make it accessible from other hosts. It also works with printers that have network interfaces that understand the LPD protocol. To enable this kind of remote printing, first install a printer on one host, the . Do any advanced setup in that you need. Make sure to test the printer and see if it works with the features of LPD you've enabled. If you're using a printer with a network interface that's compatible with LPD, then the /etc/printcap files with the following: Name the entry anything you want. For simplicity, though, you probably want to use the same name and aliases as on the printer host. Leave the Make a spooling directory and specify its location in the Place the name of the printer host in the Place the printer name on the That's it. You don't need to list conversion filters, page dimensions, or anything else in the /etc/printcap file. Here's an example. The host rose has two printers, /etc/printcap file for orchid (back from section ). It already had the entry for the printer # # /etc/printcap for host orchid - added (remote) printers on rose # # # teak is local; it's connected directly to orchid: # teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:\ :if=/usr/local/libexec/ifhp:\ :vf=/usr/local/libexec/vfhp:\ :of=/usr/local/libexec/ofhp: # # rattan is connected to rose; send jobs for rattan to rose: # rattan|line|diablo|lp|Diablo 630 Line Printer:\ :lp=:rm=rose:rp=rattan:sd=/var/spool/lpd/rattan: # # bamboo is connected to rose as well: # bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ :lp=:rm=rose:rp=bamboo:sd=/var/spool/lpd/bamboo: Then, we just need to make spooling directories on orchid: mkdir -p /var/spool/lpd/rattan /var/spool/lpd/bamboo chmod 770 /var/spool/lpd/rattan /var/spool/lpd/bamboo chown daemon.daemon /var/spool/lpd/rattan /var/spool/lpd/bamboo Now, users on orchid can print to lpr -P bamboo -d sushi-review.dvi the LPD system on orchid would copy the job to the spooling directory /var/spool/lpd/bamboo and note that it was a DVI job. As soon as the host rose has room in its Printers with Networked Data Stream Interfaces

Often, when you buy a network interface card for a printer, you can get two versions: one which emulates a spooler (the more expensive version), or one which just lets you send data to it as if you were using a serial or parallel port (the cheaper version). This section tells how to use the cheaper version. For the more expensive - version, see the previous section . The format of the /etc/printcap file lets you specify what serial or parallel interface to use, and (if you're using a serial interface), what baud rate, whether to use flow control, delays for tabs, conversion of newlines, and more. But there's no way to specify a connection to a printer that's listening on a TCP/IP or other network port. To send data to a networked printer, you need to develop a communications program that can be called by the text and conversion filters. Here's one such example: the script #!/usr/bin/perl # # netprint - Text filter for printer attached to network # Installed in /usr/local/libexec/netprint # $#ARGV eq 1 || die "Usage: $0 "; $printer_host = $ARGV[0]; $printer_port = $ARGV[1]; require 'sys/socket.ph'; ($ignore, $ignore, $protocol) = getprotobyname('tcp'); ($ignore, $ignore, $ignore, $ignore, $address) = gethostbyname($printer_host); $sockaddr = pack('S n a4 x8', &ero;AF_INET, $printer_port, $address); socket(PRINTER, &ero;PF_INET, &ero;SOCK_STREAM, $protocol) || die "Can't create TCP/IP stream socket: $!"; connect(PRINTER, $sockaddr) || die "Can't contact $printer_host: $!"; while () { print PRINTER; } exit 0; We can then use this script in various filters. Suppose we had a Diablo 750-N line printer connected to the network. The printer accepts data to print on port number 5100. The host name of the printer is scrivener. Here's the text filter for the printer: #!/bin/sh # # diablo-if-net - Text filter for Diablo printer `scrivener' listening # on port 5100. Installed in /usr/local/libexec/diablo-if-net # exec /usr/libexec/lpr/lpf "$@" | /usr/local/libexec/netprint scrivener 5100 Restricting Printer Usage

This section gives information on restricting printer usage. The LPD system lets you control who can access a printer, both locally or remotely, whether they can print multiple copies, how large their jobs can be, and how large the printer queues can get. Restricting Multiple Copies

The LPD system makes it easy for users to print multiple copies of a file. Users can print jobs with /etc/printcap file. When users submit jobs with the lpr: multiple copies are not allowed Note that if you've set up access to a printer remotely (see section ), you need the /etc/printcap files as well, or else users will still be able to submit multiple-copy jobs by using another host. Here's an example. This is the /etc/printcap file for the host rose. The printer # # /etc/printcap for host rose - restrict multiple copies on bamboo # rattan|line|diablo|lp|Diablo 630 Line Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ :if=/usr/local/libexec/if-simple: bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ :sh:sd=/var/spool/lpd/bamboo:sc:\ :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ :if=/usr/local/libexec/psif:\ :df=/usr/local/libexec/psdf: Now, we also need to add the /etc/printcap (and while we're at it, let's disable multiple copies for the printer # # /etc/printcap for host orchid - no multiple copies for local # printer teak or remote printer bamboo teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:sc:\ :if=/usr/local/libexec/ifhp:\ :vf=/usr/local/libexec/vfhp:\ :of=/usr/local/libexec/ofhp: rattan|line|diablo|lp|Diablo 630 Line Printer:\ :lp=:rm=rose:rp=rattan:sd=/var/spool/lpd/rattan: bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ :lp=:rm=rose:rp=bamboo:sd=/var/spool/lpd/bamboo:sc: By using the lpr forsale.sign forsale.sign forsale.sign forsale.sign forsale.sign There are many ways to prevent this abuse (including ignoring it) which you are free to explore. Restricting Access To Printers

You can control who can print to what printers by using the UNIX group mechanism and the /etc/printcap. Just place the users you want to have access to a printer in a certain group, and then name that group in the lpr: Not a member of the restricted group if they try to print to the controlled printer. As with the ). For example, we'll let anyone access the printer /etc/printcap for host rose: # # /etc/printcap for host rose - restricted group for bamboo # rattan|line|diablo|lp|Diablo 630 Line Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ :if=/usr/local/libexec/if-simple: bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:\ :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ :if=/usr/local/libexec/psif:\ :df=/usr/local/libexec/psdf: Let's leave the other example /etc/printcap file (for the host orchid) alone. Of course, anyone on orchid can print to Controlling Sizes of Jobs Submitted

If you have many users accessing the printers, you probably need to put an upper limit on the sizes of the files users can submit to print. After all, there's only so much free space on the filesystem that houses the spooling directories, and you also need to make sure there's room for the jobs of other users. LPD enables you to limit the maximum byte size a file in a job can be with the # # /etc/printcap for host rose # # # No limit on job size: # rattan|line|diablo|lp|Diablo 630 Line Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ :if=/usr/local/libexec/if-simple: # # Limit of five megabytes: # bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:mx#5000:\ :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ :if=/usr/local/libexec/psif:\ :df=/usr/local/libexec/psdf: Again, the limits apply to the local users only. If you've set up access to your printers remotely, remote users won't get those limits. You'll need to specify the /etc/printcap files as well. See section for more information on remote printing. There's another specialized way to limit job sizes from remote printers; see section . Restricting Jobs from Remote Printers

The LPD spooling system provides several ways to restrict print jobs submitted from remote hosts: /etc/hosts.equiv and /etc/hosts.lpd. LPD checks to see if an incoming request is from a host listed in either one of these files. If not, LPD refuses the request. The format of these files is simple: one host name per line. Note that the file /etc/hosts.equiv is also used by the ruserok(3) protocol, and affects programs like /etc/hosts.lpd file on the host rose: orchid violet madrigal.fishbaum.de This means rose will accept requests from the hosts orchid, violet, and madrigal.fishbaum.de. If any other host tries to access rose's LPD, LPD will refuse them. /etc/printcap to find the spooling directory for this printer; here's bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:mx#5000:\ :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:mx#5000:\ :if=/usr/local/libexec/psif:\ :df=/usr/local/libexec/psdf: The spooling directory is the given in the echo 6144 > /var/spool/lpd/bamboo/minfree /etc/printcap. When /usr/bin/false. Accounting for Printer Usage

So, you need to charge for printouts. And why not? Paper and ink cost money. And then there are maintenance costs---printers are loaded with moving parts and tend to break down. You've examined your printers, usage patterns, and maintenance fees and have come up with a per-page (or per-foot, per-meter, or per-whatever) cost. Now, how do you actually start accounting for printouts? Well, the bad news is the LPD spooling system doesn't provide much help in this department. Accounting is highly dependent on the kind of printer in use, the formats being printed, and . Generally, there are two ways to do accounting: The LPD spooling system supports both methods easily: since you have to provide the filters (well, most of the time), you also have to provide the accounting code. But there is a bright side: you have enormous flexibility in your accounting methods. For example, you choose whether to use periodic or timely accounting. You choose what information to log: user names, host names, job types, pages printed, square footage of paper used, how long the job took to print, and so forth. And you do so by modifying the filters to save this information. Quick and Dirty Printer Accounting

FreeBSD comes with two programs that can get you set up with simple periodic accounting right away. They are the text filter , and ), LPD starts the text and the conversion filters with the name of the accounting file to use on the filter command line. The filters can use this argument to know where to write an accounting file entry. The name of this file comes from the /etc/printcap, and if not specified as an absolute path, is relative to the spooling directory. LPD starts 2.00 rose:andy 3.00 rose:kelly 3.00 orchid:mary 5.00 orchid:mary 2.00 orchid:zhang You should use a separate accounting file for each printer, as /etc/printcap. Then, each accounting file will be in the spooling directory for a printer, in a file named Login pages/feet runs price orchid:kelly 5.00 1 $ 0.10 orchid:mary 31.00 3 $ 0.62 orchid:zhang 9.00 1 $ 0.18 rose:andy 2.00 1 $ 0.04 rose:kelly 177.00 104 $ 3.54 rose:mary 87.00 32 $ 1.74 rose:root 26.00 12 $ 0.52 total 337.00 154 $ 6.74 These are the arguments /etc/printcap. /etc/printcap, or two cents (the default). You can specify In the default summary that Login pages/feet runs price andy 2.00 1 $ 0.04 kelly 182.00 105 $ 3.64 mary 118.00 35 $ 2.36 root 26.00 12 $ 0.52 zhang 9.00 1 $ 0.18 total 337.00 154 $ 6.74 To compute the dollar amount due, /etc/printcap file (default of 200, or 2 cents per page). Specify, in hundreths of cents, the price per page or per foot you want to charge for printouts in this capability. You can override this value when you run pac -p1.50 makes each page cost one dollar and fifty cents. You can really rake in the profits by using this option. Finally, running How Can You Count Pages Printed?

In order to perform even remotely accurate accounting, you need to be able to determine how much paper a job uses. This is the essential problem of printer accounting. For plain text jobs, the problem's not that hard to solve: you count how many lines are in a job and compare it to how many lines per page your printer supports. Don't forget to take into account backspaces in the file which overprint lines, or long logical lines that wrap onto one or more additional physical lines. The text filter ) takes into account these things when it does accounting. If you're writing a text filter which needs to do accounting, you might want to examine Alternatives to the Standard Spooler

If you've been reading straight through this manual, by now you've learned just about everything there is to know about the LPD spooling system that comes with FreeBSD. You can probably appreciate many of its shortcomings, which naturally leads to the question: ``What other spooling systems are out there (and work with FreeBSD)?'' Unfortunately, I've located only . There's also a . It's quite similar to the BSD LPD spooler, but boasts a host of features, including: Better network support, including built-in support for networked printers, NIS-maintained printcaps, and NFS-mounted spooling directories Sophisticated queue management, allowing multiple printers on a queue, transfer of jobs between queues, and queue redirection Remote printer control functions Prioritization of jobs Expansive security and access options . Acknowledgments

I'd like to thank the following people who've assisted in the development of this document: diff --git a/handbook/scsi.sgml b/handbook/scsi.sgml index 52ac1544c0..947d627f8b 100644 --- a/handbook/scsi.sgml +++ b/handbook/scsi.sgml @@ -1,794 +1,798 @@ - + What is SCSI?

Copyright © 1995, &a.wilko;.3 September 1995. SCSI is an acronym for Small Computer Systems Interface. It is an ANSI standard that has become one of the leading I/O buses in the computer industry. The foundation of the SCSI standard was laid by Shugart Associates (the same guys that gave the world the first mini floppy disks) when they introduced the SASI bus (Shugart Associates Standard Interface). After some time an industry effort was started to come to a more strict standard allowing devices from different vendors to work together. This effort was recognized in the ANSI SCSI-1 standard. The SCSI-1 standard (approx 1985) is now more or less obsolete. The current standard is SCSI-2 (see ), with SCSI-3 on the drawing boards. In addition to a physical interconnection standard, SCSI defines a logical (command set) standard to which disk devices must adhere. This standard is called the Common Command Set (CCS) and was developed more or less in parallel with ANSI SCSI-1. SCSI-2 includes the (revised) CCS as part of the standard itself. The commands are dependent on the type of device at hand. It does not make much sense of course to define a Write command for a scanner. The SCSI bus is a parallel bus, which comes in a number of variants. The oldest and most used is an 8 bit wide bus, with single-ended signals, carried on 50 wires. (If you don't know what single-ended means, don't worry, that is what this document is all about.) Modern designs also use 16 bit wide buses, with differential signals. This allows transfer speeds of 20Mbytes/second, on cables lengths of up to 25 meters. SCSI-2 allows a maximum bus width of 32 bits, using an additional cable. Of course the SCSI bus not only has data lines, but also a number of control signals. A very elaborate protocol is part of the standard to allow multiple devices to share the bus in an efficient manner. In SCSI-2, the data is always checked using a separate parity line. In pre-SCSI-2 designs parity was optional. In SCSI-3 even faster bus types are introduced, along with a serial SCSI bus that reduces the cabling overhead and allows a higher maximum bus length. As you could have guessed from the description above, SCSI devices are intelligent. They have to be to adhere to the SCSI standard (which is over 2 inches thick BTW). So, for a hard disk drive for instance you do not specify a head/cylinder/sector to address a particular block, but simply the number of the block you want. Elaborate caching schemes, automatic bad block replacement etc are all made possible by this 'intelligent device' approach. On a SCSI bus, each possible pair of devices can communicate. Whether their function allows this is another matter, but the standard does not restrict it. To avoid signal contention, the 2 devices have to arbitrate for the bus before using it. The philosophy of SCSI is to have a standard that allows older-standard devices to work with newer-standard ones. So, an old SCSI-1 device should normally work on a SCSI-2 bus. I say Normally, because it is not absolutely sure that the implementation of an old device follows the (old) standard closely enough to be acceptable on a new bus. Modern devices are usually more well-behaved, because the standardization has become more strict and is better adhered to by the device manufacturers. Generally speaking, the chances of getting a working set of devices on a single bus is better when all the devices are SCSI-2 or newer. This does not imply that you have to dump all your old stuff when you get that shiny 2Gb disk: I own a system on which a pre-SCSI-1 disk, a SCSI-2 QIC tape unit, a SCSI-1 helical scan tape unit and 2 SCSI-1 disks work together quite happily. Components of SCSI

As said before, SCSI devices are smart. The idea is to put the knowledge about intimate hardware details onto the SCSI device itself. In this way, the host system does not have to worry about things like how many heads are hard disks has, or how many tracks there are on a specific tape device. If you are curious, the standard specifies commands with which you can query your devices on their hardware particulars. The advantage of intelligent devices is obvious: the device drivers on the host can be made in a much more generic fashion, there is no longer a need to change (and qualify!) drivers for every odd new device that is introduced. For cabling and connectors there is a golden rule: get good stuff. With bus speeds going up all the time you will save yourself a lot of grief by using good material. So, gold plated connectors, shielded cabling, sturdy connector hoods with strain reliefs etc are the way to go. Second golden rule: don't use cables longer than necessary. I once spent 3 days hunting down a problem with a flaky machine only to discover that shortening the SCSI bus by 1 meter solved the problem. And the original bus length was well within the SCSI specification. SCSI bus types

From an electrical point of view, there are two incompatible bus types: single-ended and differential. This means that there are two different main groups of SCSI devices and controllers, which cannot be mixed on the same bus. It is possible however to use special converter hardware to transform a single-ended bus into a differential one (and vice versa). The differences between the bus types are explained in the next sections. In lots of SCSI related documentation there is a sort of jargon in use to abbreviate the different bus types. A small list: FWD: Fast Wide Differential FND: Fast Narrow Differential SE: Single Ended FN: Fast Narrow etc. With a minor amount of imagination one can usually imagine what is meant. Wide is a bit ambiguous, it can indicate 16 or 32 bit buses. As far as I know, the 32 bit variant is not (yet) in use, so wide normally means 16 bit. Fast means that the timing on the bus is somewhat different, so that on a narrow (8 bit) bus 10 Mbytes/sec are possible instead of 5 Mbytes/sec for 'slow' SCSI. More on this later. It should be noted that the data lines > 8 are only used for data transfers and device addressing. The transfers of commands and status messages etc are only performed on the lowest 8 data lines. The standard allows narrow devices to operate on a wide bus. The usable bus width is negotiated between the devices. You have to watch your device addressing closely when mixing wide and narrow. Single ended buses

A single-ended SCSI bus uses signals that are either 5 Volts or 0 Volts (indeed, TTL levels) and are relative to a COMMON ground reference. A singled ended 8 bit SCSI bus has approximately 25 ground lines, who are all tied to a single `rail' on all devices. A standard single ended bus has a maximum length of 6 meters. If the same bus is used with fast-SCSI devices, the maximum length allowed drops to 3 meters. Fast-SCSI means that instead of 5Mbytes/sec the bus allows 10Mbytes/sec transfers. Please note that this means that if some devices on your bus use 'fast' to communicate your bus must adhere to the length restrictions for fast buses! It is obvious that with the newer fast-SCSI devices the bus length can become a real bottleneck. This is why the differential SCSI bus was introduced in the SCSI-2 standard. For connector pinning and connector types please refer to the SCSI-2 standard (see ) itself, connectors etc are listed there in painstaking detail. Beware of devices using non-standard cabling. For instance Apple uses a 25pin D-type connecter (like the one on serial ports and parallel printers). Considering that the official SCSI bus needs 50 pins you can imagine the use of this connector needs some 'creative cabling'. The reduction of the number of ground wires they used is a bad idea, you better stick to 50 pins cabling in accordance with the SCSI standard. Differential buses

A differential SCSI bus has a maximum length of 25 meters. Quite a difference from the 3 meters for a single-ended fast-SCSI bus. The idea behind differential signals is that each bus signal has it's own return wire. So, each signal is carried on a (preferably twisted) pair of wires. The voltage difference between these two wires determines whether the signal is asserted or de-asserted. To a certain extent the voltage difference between ground and the signal wire pair is not relevant (don't try 10 kVolts though..). It is beyond the scope of this document to explain why this differential idea is so much better. Just accept that electrically seen the use of differential signals gives a much better noise margin. You will normally find differential buses in use for inter-cabinet connections. Because of the lower cost single ended is mostly used for shorter buses like inside cabinets. There is nothing that stops you from using differential stuff with FreeBSD, as long as you use a controller that has device driver support in FreeBSD. As an example, Adaptec marketed the AH1740 as a single ended board, whereas the AH1744 was differential. The software interface to the host is identical for both. Terminators

Terminators in SCSI terminology are resistor networks that are used to get a correct impedance matching. Impedance matching is important to get clean signals on the bus, without reflections or ringing. If you once made a long distance telephone call on a bad line you probably know what reflections are. With 20Mbytes/sec travelling over your SCSI bus, you don't want signals echoing back. Terminators come in various incarnations, with more or less sophisticated designs. Of course, there are internal and external variants. Almost every SCSI device comes with a number of sockets in which a number of resistor networks can (must be!) installed. If you remove terminators from a device, carefully store 'm. You will need them when you ever decide to reconfigure your SCSI bus. There is enough variation in even these simple tiny things to make finding the exact replacement a frustrating business. There are also SCSI devices that have a single jumper to enable or disable a built-in terminator. There are special terminators you can stick onto a flat cable bus. Others look like external connectors, or a connector hood without a cable. So, lots of choice as you can see. There is much debate going on if and when you should switch from simple resistor (passive) terminators to active terminators. Active terminators contain slightly more elaborate circuit to give cleaner bus signals. The general consensus seems to be that the usefulness of active termination increases when you have long buses and/or fast devices. If you ever have problems with your SCSI buses you might consider trying an active terminator. Try to borrow one first, they reputedly are quite expensive. Please keep in mind that terminators for differential and single-ended buses are not identical. You should not mix the two variants. OK, and now where should you install your terminators? This is by far the most misunderstood part of SCSI. And it is by far the simplest.. The rule is: every SCSI bus has 2 (two) terminators, one at each end of the bus. So, two and not one or three or whatever. Do yourself a favour and stick to this rule. It will save you endless grief, because wrong termination has the potential to introduce highly mysterious bugs. A common pitfall is to have an internal (flat)cable in a machine and also an external cable attached to the controller. It seems almost everybody forgets to remove the terminators from the controller. The terminator must now be on the last external device, and not on the controller! In general, every reconfiguration of a SCSI bus must pay attention to this. What I did myself is remove all terminators from my SCSI devices and controllers. I own a couple of external terminators, for both the Centronics-type external cabling and for the internal flat cable connectors. This makes reconfiguration much easier. Terminator power

The terminators discussed in the previous chapter need power to operate properly. On the SCSI bus, a line is dedicated to this purpose. So, simple huh? Not so. Each device can provide it's own terminator power to the terminator sockets it has on-device. But if you have external terminators, or when the device supplying the terminator power to the SCSI bus line is switched off you are in trouble. The idea is that initiators (these are devices that initiate actions on the bus, a discussion follows) must supply terminator power. All SCSI devices are allowed (but not required) to supply terminator power. To allow for switched-off devices on a bus, the terminator power must be supplied to the bus via a diode. This prevents the backflow of current to switched-off devices. To prevent all kinds of nastiness, the terminator power is usually fused. As you can imagine, fuses might blow. This can, but does not have to, lead to a non functional bus. If multiple devices supply terminator power, a single blown fuse will not put you out of business. A single supplier with a blown fuse certainly will. Clever external terminators sometimes have a LED indication that shows whether terminator power is present. In newer designs auto-restoring fuses that 'reset' themselves after some time are sometimes used. On modern devices, sometimes integrated terminators are used. These things are special purpose integrated circuits that can be dis/en-abled with a control pin. It is not necessary to physically remove them from a device. You may find them on newer host adapters, sometimes they even are software configurable, using some sort of setup tool. Consult you documentation! Device addressing

Because the SCSI bus is, ehh, a bus there must be a way to distinguish or address the different devices connected to it. This is done by means of the SCSI or target ID. Each device has a unique target ID. You can select the ID to which a device must respond using a set of jumpers, or a dip switch, or something similar. Consult the documentation of your device for more information. Beware of multiple devices configured to use the same ID. Chaos normally reigns in this case. For an 8 bit bus, a maximum of 8 targets is possible. The maximum is 8 because the selection is done bitwise using the 8 data lines on the bus. For wide this increases to the number of data lines. The higher the SCSI target ID, the higher the priority the devices has. When it comes to arbitration between devices that want to use the bus at the same time, the device that has the highest SCSI ID will win. This also means that the SCSI host adapter usually uses target ID 7 (for narrow buses). For a further subdivision, the standard allows for Logical Units or LUNs for short. A single target ID may have multiple LUNs. For example, a tape device including a tape changer may have LUN 0 for the tape device itself, and LUN 1 for the tape changer. In this way, the host system can address each of the parts of the tape unit as desired. Bus layout

SCSI buses are linear. So, not shaped like Y-junctions, star topologies, cobwebs or whatever else people might want to invent. You might notice that the terminator issue discussed earlier becomes rather hairy if your bus is not linear.. The electrical characteristics, it's noise margins and ultimately the reliability of it all are tightly related to linear bus rule. Stick to the linear bus rule! Using SCSI with FreeBSD

About translations, BIOSes and magic...

As stated before, you should first make sure that you have a electrically sound bus. When you want to use a SCSI disk on your PC as boot disk, you must aware of some quirks related to PC BIOSes. The PC BIOS in it's first incarnation used a low level physical interface to the hard disk. So, you had to tell the BIOS (using a setup tool or a BIOS built-in setup) how your disk physically looked like. This involved stating number of heads, number of cylinders, number of sectors per track, obscure things like precompensation and reduced write current cylinder etc. One might be inclined to think that since SCSI disks are smart you can forget about this. Alas, the arcane setup issue is still present today. The system BIOS needs to know how to access your SCSI disk with the head/cyl/sector method in order to load the FreeBSD kernel during boot. The SCSI host adapter or SCSI controller you have put in your AT/EISA/PCI/whatever bus to connect your disk therefore has it's own on-board BIOS. During system startup, the SCSI BIOS takes over the hard disk interface routines from the system BIOS. To fool the system BIOS, the system setup is normally set to No hard disk present. Obvious, isn't it? The SCSI BIOS itself presents to the system a so called translated drive. This means that a fake drive table is constructed that allows the PC to boot the drive. This translation is often (but not always) done using a pseudo drive with 64 heads and 32 sectors per track. By varying the number of cylinders, the SCSI BIOS adapts to the actual drive size. It is useful to note that 32 * 64 / 2 = the size of your drive in megabytes. The division by 2 is to get from disk blocks that are normally 512 bytes in size to Kbytes. Right.. All is well now?! No, it isn't. The system BIOS has another quirk you might run into. The number of cylinders of a bootable hard disk cannot be greater than 1024. Using the translation above, this is a show-stopper for disks greater than 1 Gb. With disk capacities going up all the time this is causing problems. Fortunately, the solution is simple: just use another translation, e.g. with 128 heads instead of 32. In most cases new SCSI BIOS versions are available to upgrade older SCSI host adapters. Some newer adapters have an option, in the form of a jumper or software setup selection, to switch the translation the SCSI BIOS uses. It is very important that all operating systems on the disk use the same translation to get the right idea about where to find the relevant partitions. So, when installing FreeBSD you must answer any questions about heads/cylinders etc using the translated values your host adapter uses. Failing to observe the translation issue might lead to un-bootable systems or operating systems overwriting each others partitions. Using fdisk you should be able to see all partitions. You might have heard some talk of 'lying' devices? Older FreeBSD kernels used to report the geometry of SCSI disks when booting. An example from one of my systems: aha0 targ 0 lun 0: sd0: 636MB (1303250 total sec), 1632 cyl, 15 head, 53 sec, bytes/sec 512 Newer kernels usually don't report this information.. e.g. (bt0:0:0): "SEAGATE ST41651 7574" type 0 fixed SCSI 2 sd0(bt0:0:0): Direct-Access 1350MB (2766300 512 byte sectors) Why has this changed? This info is retrieved from the SCSI disk itself. Newer disks often use a technique called zone bit recording. The idea is that on the outer cylinders of the drive there is more space so more sectors per track can be put on them. This results in disks that have more tracks on outer cylinders than on the inner cylinders and, last but not least, have more capacity. You can imagine that the value reported by the drive when inquiring about the geometry now becomes suspect at best, and nearly always misleading. When - asked fro a geometry , it is nearly always better to supply the + asked for a geometry , it is nearly always better to supply the geometry used by the BIOS, or if the BIOS is never going to know about this disk, (e.g. it is not a booting disk) to supply a ficticious geometry that is convenient. SCSI subsystem design

FreeBSD uses a layered SCSI subsystem. For each different controller card a device driver is written. This driver knows all the intimate details about the hardware it controls. The driver has a interface to the upper layers of the SCSI subsystem through which it receives it's commands and reports back any status. On top of the card drivers there are a number of more generic drivers for a class of devices. More specific: a driver for tape devices (abbreviation: st), magnetic disks (sd), cdroms (cd) etc. In case you are wondering where you can find this stuff, it all lives in /sys/scsi. See the man pages in section 4 for more details. The multi level design allows a decoupling of low-level bit banging and more high level stuff. Adding support for another piece of hardware is a much more managable problem. Kernel configuration

Dependent on your hardware, the kernel configuration file must contain one or more lines describing your host adapter(s). This includes I/O addresses, interrupts etc. Consult the man page for your adapter driver to get more info. Apart from that, check out /sys/i386/conf/LINT for an overview of a kernel config file. LINT contains every possible option you can dream of. It does not imply LINT will actually get you to a working kernel at all. Although it is probably stating the obvious: the kernel config file should reflect your actual hardware setup. So, interrupts, I/O addresses etc must match the kernel config file. During system boot messages will be displayed to indicate whether the configured hardware was actually found. An example loosely based on the FreeBSD 2.0.5-Release kernel config file LINT with some added comments (between []): # SCSI host adapters: `aha', `ahb', `aic', `bt', `nca' # # aha: Adaptec 154x # ahb: Adaptec 174x # ahc: Adaptec 274x/284x/294x # aic: Adaptec 152x and sound cards using the Adaptec AIC-6360 (slow!) # bt: Most Buslogic controllers # nca: ProAudioSpectrum cards using the NCR 5380 or Trantor T130 # uha: UltraStore 14F and 34F # sea: Seagate ST01/02 8 bit controller (slow!) # wds: Western Digital WD7000 controller (no scatter/gather!). # [For an Adaptec AHA274x, 284x etc controller] controller ahc0 at isa? bio irq ? vector ahcintr # port??? iomem? [For an Adaptec AHA174x controller] controller ahb0 at isa? bio irq ? vector ahbintr [For an Ultrastor adapter] controller uha0 at isa? port "IO_UHA0" bio irq ? drq 5 vector uhaintr # Map SCSI buses to specific SCSI adapters controller scbus0 at ahc0 controller scbus2 at ahb0 controller scbus1 at uha0 # The actual SCSI devices disk sd0 at scbus0 target 0 unit 0 [SCSI disk 0 is at scbus 0, LUN 0] disk sd1 at scbus0 target 1 [implicit LUN 0 if omitted] disk sd2 at scbus1 target 3 [SCSI disk on the uha0] disk sd3 at scbus2 target 4 [SCSI disk on the ahb0] tape st1 at scbus0 target 6 [SCSI tape at target 6] device cd0 at scbus? [the first ever CDROM found, no wiring] The example above tells the kernel to look for a ahc (Adaptec 274x) controller, then for an Adaptec 174x board, and so on. The lines following the controller specifications tell the kernel to configure specific devices but only attach them when they match the target ID and LUN specified on the corresponding bus. Wired down devices get 'first shot' at the unit numbers so the first non 'wired down' device, is allocated the unit number one greater than the highest 'wired down' unit number for that kind of device. So, if you had a SCSI tape at target ID 2 it would be configured as st2, as the tape at target ID 6 is wired down to unit number 1. Note that wired down devices need not be found to get their unit number. The unit number for a wired down device is reserved for thet device, even if it is turned off at boot time. This allows the device to be turned on and brought on-line at a later time, without rebooting. Notice that a device's unit number has no relationship with it's target ID on the SCSI bus. Below is another example of a kernel config file as used by FreeBSD version < 2.0.5. The difference with the first example is that devices are not 'wired down'. 'Wired down' means that you specify which SCSI target belongs to which device. A kernel built to the config file below will attach the first SCSI disk it finds to sd0, the second disk to sd1 etc. If you ever removed or added a disk, all other devices of the same type (disk in this case) would 'move around'. - This implies you have to change /etc/fstab each time. + This implies you have to change /etc/fstab each time. Although the old style still works, you are strongly recommended to use this new feature. It will save you a lot of grief whenever you shift your hardware around on the SCSI buses. So, when you re-use your old trusty config file after upgrading from a pre-FreeBSD2.0.5.R system check this out. -controller ahb0 at isa? bio irq 11 vector ahbintr [driver for Adaptec 174x] -controller aha0 at isa? port "IO_AHA0" bio irq 11 drq 5 vector ahaintr [for Adaptec 154x] -controller sea0 at isa? bio irq 5 iomem 0xc8000 iosiz 0x2000 vector seaintr [for Seagate -ST01/02] +[driver for Adaptec 174x] +controller ahb0 at isa? bio irq 11 vector ahbintr +[for Adaptec 154x] +controller aha0 at isa? port "IO_AHA0" bio irq 11 drq 5 vector ahaintr +[for Seagate ST01/02] +controller sea0 at isa? bio irq 5 iomem 0xc8000 iosiz 0x2000 vector seaintr controller scbus0 device sd0 [support for 4 SCSI harddisks, sd0 up sd3] device st0 [support for 2 SCSI tapes] -device cd0 #Only need one of these, the code dynamically grows [for the cdrom] +[for the cdrom] +device cd0 #Only need one of these, the code dynamically grows Both examples support SCSI disks. If during boot more devices of a specific type (e.g. sd disks) are found than are configured in the booting kernel, the system will simply allocate more devices, incrementing the unit number starting at the last number 'wired down'. If there are no 'wired down' devices then counting starts at unit 0. Use man 4 scsi to check for the latest info on the SCSI subsystem. For more detailed info on host adapter drivers use eg man 4 aha for info on the Adaptec 154x driver. Tuning your SCSI kernel setup

Experience has shown that some devices are slow to respond to INQUIRY commands after a SCSI bus reset (which happens at Boot time). An INQUIRY command is sent by the kernel on boot to see what kind of device (disk, tape, cdrom etc) is connected to a specific target ID. This process is called device probing by the way. To work around this problem, FreeBSD allows a tunable delay time before the SCSI devices are probed following a SCSI bus reset. You can set this delay time in your kernel configuration file using a line like: options "SCSI_DELAY=15" #Be pessimistic about Joe SCSI device This line sets the delay time to 15 seconds. On my own system I had to use 3 seconds minimum to get my trusty old CDROM drive to be recognized. Start with a high value (say 30 seconds or so) when you have problems with device recognition. If this helps, tune it back until it just stays working. Rogue SCSI devices

Although the SCSI standard tries to be complete and concise, it is a complex standard and implementing things correctly is no easy task. Some vendors do a better job then others. This is exactly where the 'rogue' devices come into view. Rogues are devices that are recognized by the FreeBSD kernel as behaving slightly (...) non-standard. Rogue devices are reported by the kernel when booting. An example for two of my cartridge tape units: Feb 25 21:03:34 yedi /386bsd: ahb0 targ 5 lun 0: Feb 25 21:03:34 yedi /386bsd: st0: Tandberg tdc3600 is a known rogue Mar 29 21:16:37 yedi /386bsd: aha0 targ 5 lun 0: Mar 29 21:16:37 yedi /386bsd: st1: Archive Viper 150 is a known rogue For instance, there are devices that respond to all LUNs on a certain target ID, even if they are actually only one device. It is easy to see that the kernel might be fooled into believing that there are 8 LUNs at that particular target ID. The confusion this causes is left as an exercise to the reader. The SCSI subsystem of FreeBSD recognizes devices with bad habits by looking at the INQUIRY response they send when probed. Because the INQUIRY response also includes the version number of the device firmware, it is even possible that for different firmware versions different workarounds are used. This scheme works fine, but keep in mind that it of course only works for devices that are KNOWN to be weird. If you are the first to connect your bogus Mumbletech SCSI cdrom you might be the one that has to define which workaround is needed. Busmaster host adapters

Most, but not all, SCSI host adapters are bus mastering controllers. This means that they can do I/O on their own without putting load onto the host CPU for data movement. This is of course an advantage for a multitasking operating system like FreeBSD. It must be noted however that there might be some rough edges. For instance an Adaptec 1542 controller can be set to use different transfer speeds on the host bus (ISA or AT in this case). The controller is settable to different rates because not all motherboards can handle the higher speeds. Problems like hangups, bad data etc might be the result of using a higher data transfer rate then your motherboard can stomach. The solution is of course obvious: switch to a lower data transfer rate and try if that works better. In the case of a Adaptec 1542, there is an option that can be put into the kernel config file to allow dynamic determination of the right, read: fastest feasible, transfer rate. This option is disabled by default: options "TUNE_1542" #dynamic tune of bus DMA speed Check the man pages for the host adapter that you use. Or better still, use the ultimate documentation (read: driver source). Tracking down problems

The following list is an attempt to give a guideline for the most common SCSI problems and their solutions. It is by no means complete. Check for loose connectors and cables. Check and doublecheck the location and number of your terminators. Check if your bus has at least one supplier of terminator power (especially with external terminators. Check if no double target IDs are used. Check if at least one device provides terminator power to the bus. Check if all devices to be used are powered up. Make a minimal bus config with as little devices as possible. If possible, configure your host adapter to use slow bus speeds. If you can compile a kernel, make one with the SCSIDEBUG option, and try accessing the device with debugging turned on for that device. If your device doesn't even probe at startup, you may have to define the address of the device that - is failing, and the desired debug level in /sys/scsi/scsidebug.h. + is failing, and the desired debug level in + /sys/scsi/scsidebug.h. If it probes but just doesn't work, you can use the scsi(8) command to dynamically set a debug level to it in a running kernel (if SCSIDEBUG is defined). This will give you COPIOUS debugging output with which to confuse the gurus. see man 4 scsi for more exact information. Also look at man 8 scsi. Further reading

If you intend to do some serious SCSI hacking, you might want to have the official standard at hand: Approved American National Standards can be purchased from ANSI at 11 West 42nd Street, 13th Floor, New York, NY 10036, Sales Dept: (212) 642-4900. You can also buy many ANSI standards and most committee draft documents from Global Engineering Documents, 15 Inverness Way East, Englewood, CO 80112-5704, Phone: (800) 854-7179, Outside USA and Canada: (303) 792-2181, FAX: (303) 792- 2192. Many X3T10 draft documents are available electronically on the SCSI BBS (719-574-0424) and on the ncrinfo.ncr.com anonymous ftp site. Latest X3T10 committee documents are: AT Attachment (ATA or IDE) [X3.221-1994] (Approved) ATA Extensions (ATA-2) [X3T10/948D Rev 2i] Enhanced Small Device Interface (ESDI) [X3.170-1990/X3.170a-1991] (Approved) Small Computer System Interface - 2 (SCSI-2) [X3.131-1994] (Approved) SCSI-2 Common Access Method Transport and SCSI Interface Module (CAM) [X3T10/792D Rev 11] Other publications that might provide you with additional information are: "SCSI: Understanding the Small Computer System Interface", written by NCR Corporation. Available from: Prentice Hall, Englewood Cliffs, NJ, 07632 Phone: (201) 767-5937 ISBN 0-13-796855-8 "Basics of SCSI", a SCSI tutorial written by Ancot Corporation Contact Ancot for availability information at: Phone: (415) 322-5322 Fax: (415) 322-0455 "SCSI Interconnection Guide Book", an AMP publication (dated 4/93, Catalog 65237) that lists the various SCSI connectors and suggests cabling schemes. Available from AMP at (800) 522-6752 or (717) 564-0100 "Fast Track to SCSI", A Product Guide written by Fujitsu. Available from: Prentice Hall, Englewood Cliffs, NJ, 07632 Phone: (201) 767-5937 ISBN 0-13-307000-X "The SCSI Bench Reference", "The SCSI Encyclopedia", and the "SCSI Tutor", ENDL Publications, 14426 Black Walnut Court, Saratoga CA, 95070 Phone: (408) 867-6642 "Zadian SCSI Navigator" (quick ref. book) and "Discover the Power of SCSI" (First book along with a one-hour video and tutorial book), Zadian Software, Suite 214, 1210 S. Bascom Ave., San Jose, CA 92128, (408) 293-0800 On Usenet the newsgroups and are noteworthy places to look for more info. You can also find the SCSI-Faq there, which is posted periodically. Most major SCSI device and host adapter suppliers operate ftp sites and/or BBS systems. They may be valuable sources of information about the devices you own. diff --git a/handbook/slipc.sgml b/handbook/slipc.sgml index 1c666f9e06..1f6819ffb7 100644 --- a/handbook/slipc.sgml +++ b/handbook/slipc.sgml @@ -1,193 +1,193 @@ - + Setting up a SLIP client

Contributed by &a.asami;8 Aug 1995. The following is one way to set up a FreeBSD machine for SLIP on a static host network. For dynamic hostname assignments (i.e., your address changes each time you dial up), you probably need to do something much fancier. First, determine which serial port your modem is connected to. I have a symbolic link /dev/modem -> cuaa1, and only use the modem name in my configuration files. It can become quite cumbersome when you need to fix a bunch of files in /etc and .kermrc's all over the system! (Note that /dev/cuaa0 is COM1, cuaa1 is COM2, etc.) Make sure you have pseudo-device sl 1 in your kernel's config file. It is included in the GENERIC kernel, so this won't be a problem unless you deleted it. Things you have to do only once

Add your home machine, the gateway and nameservers to your - /etc/hosts file. Mine looks like this: + /etc/hosts file. Mine looks like this: 127.0.0.1 localhost loghost 136.152.64.181 silvia.HIP.Berkeley.EDU silvia.HIP silvia 136.152.64.1 inr-3.Berkeley.EDU inr-3 slip-gateway 128.32.136.9 ns1.Berkeley.edu ns1 128.32.136.12 ns2.Berkeley.edu ns2 By the way, silvia is the name of the car that I had when I was back in Japan (it's called 2?0SX here in U.S.). -Make sure you have "hosts" before "bind" in your /etc/host.conf. +Make sure you have "hosts" before "bind" in your /etc/host.conf. Otherwise, funny things may happen. -Edit the file /etc/sysconfig. +Edit the file /etc/sysconfig. Set your hostname by editing the line that says: hostname=myname.my.domain You should give it your full Internet hostname. Add sl0 to the list of network interfaces by changing the line that says: network_interfaces="lo0" to: network_interfaces="lo0 sl0" Set the startup flags of sl0 by adding a line: ifconfig_sl0="inet ${hostname} slip-gateway netmask 0xffffff00 up" Designate the default router by changing the line: defaultrouter=NO to: defaultrouter=slip-gateway -Make a file /etc/resolv.conf which contains: +Make a file /etc/resolv.conf which contains: domain HIP.Berkeley.EDU nameserver 128.32.136.9 nameserver 128.32.136.12 As you can see, these set up the nameserver hosts. Of course, the actual domain names and addresses depend on your environment. Set the password for root and toor (and any other accounts that - doesn't have a password). Use passwd, don't edit the passwd or - passwd.master files! + doesn't have a password). Use passwd, don't edit the /etc/passwd + or /etc/master.passwd files! Reboot your machine and make sure it comes up with the correct hostname. Making a SLIP connection

Dial up, type "slip" at the prompt, enter your machine name and password. The things you need to enter depends on your environment. I use kermit, with a script like this: # kermit setup set modem hayes set line /dev/modem set speed 115200 set parity none set flow rts/cts set terminal bytesize 8 set file type binary # The next macro will dial up and login define slip dial 643-9600, input 10 =>, if failure stop, - output slip\x0d, input 10 Username:, if failure stop, - output silvia\x0d, input 10 Password:, if failure stop, - output ***\x0d, echo \x0aCONNECTED\x0a (of course, you have to change the hostname and password to fit yours). Then you can just type "slip" from the kermit prompt to get connected. - Note: leaving your password in plain text anywhere in the + Note: leaving your password in plain text anywhere in the filesystem is generally a BAD idea. Do it at your own risk. I'm just too lazy. Leave the kermit there (you can suspend it by "z") and as root, type slattach -h -c -s 115200 /dev/modem if you are able to "ping" hosts on the other side of the router, you are connected! If it doesn't work, you might want to try "-a" instead of "-c" as an argument to slattach. How to shutdown the connection

Type "kill -INT `cat /var/run/slattach.modem.pid`" (as root) to kill slattach. Then go back to kermit ("fg" if you suspended it) and exit from it ("q"). The slattach man page says you have to use "ifconfig sl0 down" to mark the interface down, but this doesn't seem to make any difference for me. ("ifconfig sl0" reports the same thing.) Some times, your modem might refuse to drop the carrier (mine often does). In that case, simply start kermit and quit it again. It usually goes out on the second try. Troubleshooting

If it doesn't work, feel free to ask me. The things that people tripped over so far: Not using "-c" or "-a" in slattach (I have no idea why this can be fatal, but adding this flag solved the problem for at least one person) Using "s10" instead of "sl0" (might be hard to see the difference on some fonts. Try "ifconfig sl0" to see your interface status. I get: silvia# ifconfig sl0 sl0: flags=10 inet 136.152.64.181 --> 136.152.64.1 netmask ffffff00 -Also, "netstat -r" will give the routing table, in case you get the -"no route to host" messages from ping. Mine looks like: +Also, netstat -r will give the routing table, in case you get +the "no route to host" messages from ping. Mine looks like: silvia# netstat -r Routing tables Destination Gateway Flags Refs Use IfaceMTU Rtt Netmasks: (root node) (root node) Route Tree for Protocol Family inet: (root node) => default inr-3.Berkeley.EDU UG 8 224515 sl0 - - localhost.Berkel localhost.Berkeley UH 5 42127 lo0 - 0.438 inr-3.Berkeley.E silvia.HIP.Berkele UH 1 0 sl0 - - silvia.HIP.Berke localhost.Berkeley UGH 34 47641234 lo0 - 0.438 (root node) (this is after transferring a bunch of files, your numbers should be smaller). diff --git a/handbook/userppp.sgml b/handbook/userppp.sgml index 9265825b71..2901d5930f 100644 --- a/handbook/userppp.sgml +++ b/handbook/userppp.sgml @@ -1,360 +1,363 @@ - + Setting up user PPP

Contributed by &a.nik; 28 July 1995.

User PPP was intruduced to FreeBSD in release 2.0.5 as an addition to the exisiting kernel implementation of PPP. So, what is different about this new PPP that warrants its addition? To quote from the manual page: This is a user process PPP software package. Normally, PPP is implemented as a part of the kernel (e.g. as managed by pppd) and it's thus somewhat hard to debug and/or modify its behavior. However, in this implementation PPP is done as a user process with the help of the tunnel device driver (tun). In essence, this means that rather than running a PPP daemon, the ppp program can be run as and when desired. No PPP interface needs to be compiled into the kernel, as the program can use the generic tunnel device to to get data into and out of the kernel. From here on out, user ppp will be referred to as simply as ppp unless a distinction need to be made be it and any other PPP client/server software. Unless otherwise stated, all commands in this section should be executed as root. Parts in this section marked with an asterisk (*) are incomplete. Comments and suggestions are appreciated and should be submitted to &a.nik;. Thanks to Rob Snow <rsnow@txdirect.net> who proved to be a mine of useful information when I was first experimenting with user ppp. Before you start

This document assumes you're in roughly this position: You have an account with an Internet Service Provider (ISP) which lets you use PPP. Further, you have a modem (or other device) connected and configured correctly which allows you to connect to your ISP. You are going to need the following information to hand: IP address of your ISP's gateway Your ISP's netmask setting IP adresses of one or more nameservers If your ISP allocates you a static IP address and/or hostname then you will need that as well. If not, you will need to know from what range of IP addresses your allocated IP address will fall in. If you do not have any of this information then contact your ISP and make sure they provide it to you. As well as this, you may need the files required to recompile your kernel. Check for more information on how to acquire these. In addition, I've assumed that because your connection to the Internet is not full time you are not running a name server (named(8)). Building a ppp ready kernel

As the description states, ``ppp'' uses the kernel ``tun'' device. It is necessary to make sure that your kernel has support for this device compiled in. To check this, go to your kernel compile directory (probably /sys/i386/conf) and examine your kernel configuration file. It needs to have the line pseudo-device tun 1 in it somewhere. The stock GENERIC kernel has this as standard, so if you have not installed a custom kernel you don't have to change anything. If your kernel configuration file does not have this line in it then you should add the line, re-compile and then re-install the kernel. Boot from this new kernel. Check the tun device

My experiences with ppp have only been with one ``tun'' device (tun0). If you have used more (i.e., a number other than `1' in the pseudo-device line in the kernel configuration file) then alter all references to ``tun0'' below to reflect whichever device number you are using. The easiest way to make sure that the tun0 device is configured correctly is - to re-make it. To this end, execute the following commands, + to re-make it. To this end, execute the following commands: # cd /dev # ./MAKEDEV tun0 PPP Configuration

The meat of the problem. Confusingly, it appears that both user ppp and pppd (the kernel level implementation of PPP) both assume configuration files kept in /etc/ppp. However, the sample configuration files provided are good for - user ppp, so keep them around for reference. The easiest way to do this is, + user ppp, so keep them around for reference. The easiest way to do this is: # cd /etc # mv ppp ppp.orig # mkdir ppp Configuring ppp requires that you edit somewhere between one and three files, depending on your requirements. What you put in them depends to some extent on whether your ISP allocates IP addresses statically (i.e., you get given one IP address, and always use that one) or dynamically (i.e., your IP address can be different during different PPP sessions). However, there are a few things that you should do first, regardless of whether you are using static or dynamic IP addresses. Configure the resolver(5)

The resolver is the part of the networking system that turns IP addresses into hostnames. It can be configured to look for maps that describe IP to hostname mappings in one of two places. - The first is a file called /etc/hosts (``hosts'' in section 5 of the - manual). The second is the Internet Domain Name Service, a distributed + The first is a file called /etc/hosts (man 5 hosts). + The second is the Internet Domain Name Service, a distributed data base, the discussion of which is beyond the realm of this document. The resolver is a set of system calls that do the mappings, and you have to tell them where to get their information - from. You do this by editing the file /etc/host.conf. Do - not call this file /etc/hosts.conf (note the extra + from. You do this by editing the file /etc/host.conf. Do + not call this file /etc/hosts.conf (note the extra ``s'') as the results can be confusing. This file should contain the following two lines, hosts bind - which instruct the resolver to look in the file /etc/hosts first, and - then to consult the DNS if the name was not found in the /etc/hosts file. + which instruct the resolver to look in the file /etc/hosts first, + and then to consult the DNS if the name was not found in the + /etc/hosts file. It's probably a good idea to make sure you are not running the ``named'' - service. Check your /etc/sysconfig file for the line that refers to - ``namedflags'', and make sure the line reads + service. Check your /etc/sysconfig file for the line that refers + to ``namedflags'', and make sure the line reads namedflags="NO" Create the /etc/hosts(5) file

This file should contain the IP addresses and names of machines on your network. At a bare minimum it should contain entries for the machine which will be running ppp. Assuming that you're machine is called - foo.bar.com with the IP address 10.0.0.1, /etc/hosts should contain + foo.bar.com with the IP address 10.0.0.1, /etc/hosts should + contain: 127.0.0.0 localhost 10.0.0.1 foo.bar.com foo The first line defines the alias ``localhost'' as a synonym for the current machine. Regardless of your own IP address, the IP address for this line should always be 127.0.0.1. The second line maps the name ``foo.bar.com'' (and the shorthand ``foo'') to the IP address 10.0.0.1. If your provider allocates you a static IP address then use this in place of 10.0.0.1. Create the /etc/resolv.conf file -

/etc/resolv.conf contains some extra information required when you are - not running a nameserver. It points the resolver routines at real +

/etc/resolv.conf contains some extra information required when + you are not running a nameserver. It points the resolver routines at real nameservers, and specifies some other information. - At the very least, /etc/resolv.conf should contain one line with a - nameserver which can be queried. You should enter this as an IP - address. My /etc/resolv.conf contains + At the very least, /etc/resolv.conf should contain one line with + a nameserver which can be queried. You should enter this as an IP + address. My /etc/resolv.conf contains: nameserver 158.152.1.193 nameserver 158.152.1.65 Which are Demon Internet's two nameservers. Add as many ``nameserver'' lines as your ISP provides nameservers. PPP and static IP addresses

Probably the easiest to configure for. You will need to create three files - in the /etc/ppp directory. + in the /etc/ppp directory. - The first of these is ppp.conf. It should look similar to the example - below. Note that lines that end in a ``:'' start in column 1, all other - lines should be indented as shown. + The first of these is ppp.conf. It should look similar to the + example below. Note that lines that end in a ``:'' start in column 1, all + other lines should be indented as shown. - /etc/ppp/ppp.conf + /etc/ppp/ppp.conf 1 default: 2 set device /dev/cuaa0 3 set speed 9600 4 disable lqr 5 deny lqr 6 set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \"\" ATE1Q0 OK-AT-OK \\dATDT\\T TIMEOUT 40 CONNECT" 7 provider: 8 set phone 01234567890 9 set login "TIMEOUT 10 gin:-BREAK-gin: foo word: bar col: ppp" 10 set timeout 120 11 set ifaddr x.x.x.x y.y.y.y Don't include the line numbers, they're just for this discussion. /dev/cuaa0 and COM2: is /dev/cuaa1. chat(8) + language. Check the manual page for information on the features + of this language. J. Random Provider login: foo password: bar protocol: ppp You will need to alter this script to suit your own needs. It is - written in the chat(8) language. + written in the chat(8) language. - Now you have to edit the file /etc/ppp/ppp.linkup: + Now you have to edit the file /etc/ppp/ppp.linkup: x.x.x.x: add 0 0 HISADDR Replace x.x.x.x with your IP address as before. This file is used to automatically add a default route from your ISP (who's address is automatically inserted with the HISADDR macro) to you. - Finally, you can create the file /etc/ppp/ppp.secret, which sets some - passwords to prevent people messing around with ppp on your system. You - may or may not want to do this, depending on how many people have access - to your ppp system. + Finally, you can create the file /etc/ppp/ppp.secret, which sets + some passwords to prevent people messing around with ppp on your system. + You may or may not want to do this, depending on how many people have + access to your ppp system. PPP and Dynamic IP configuration

If you service provider does not assign static IP numbers, ppp can be configured to negotiate the local address. This is done by specifying 0 as the local IP address: set ifaddr 0 0 See the ppp(8) manual page for more detailed information. Final system configuration

You now have PPP configured, but there's a few more things to do before - it's ready to work. They all involve editing the /etc/sysconfig file. + it's ready to work. They all involve editing the /etc/sysconfig + file. Working from the top down in this file, make sure the ``hostname='' line is set, e.g., hostname=foo.bar.com Look for the network_interfaces variable, and make sure the tun0 device is added to the list. My line looks like network_interfaces="lo0 tun0 ep0" but I have an ethernet card (ep0) to configure as well. Now add an ifconfig line for the tun0 device. It should look something like ifconfig_tun0="inet foo.bar.com y.y.y.y netmask 0xffffffff" as before, change ``foo.bar.com'' to be your hostname, y.y.y.y is the IP address of your providers gateway, and 0xffffffff is the netmask they provided you with (in hexadecimal). Two common values for the netmask are 255.255.255.255 = 0xffffffff 255.255.255.0 = 0xffffff00 Set the routed flags to ``-s'' with the line routedflags=-s It's probably worth your while ensuring that the ``sendmail_flags'' line does not include the ``-q'' option, otherwise sendmail will attempt to do a network lookup every now and then, possibly causing your machine to dial out. My sendmail line looks like sendmail_flags="-bd" The upshot of this is that I must force sendmail to re-examine the mailqueue whenever I have the PPP link up, by typing # /usr/sbin/sendmail -q That should be about all you need to do to get PPP working with a static IP address. All that's left is to reboot the machine. During startup the tun0 device should be detected, and two lines like the following should be printed, tun0: flags=51 mtu 1500 inet x.x.x.x --> y.y.y.y netmask 0xffffffff At this point, it should all be working. You can now either type # ppp and then ``dial provider'' to start the PPP session, or, if you want ppp to establish sessions automatically when there is outbound traffic, type # ppp -auto provider - This line could be added to your /etc/rc.local file. + This line could be added to your /etc/rc.local file.