FreeBSD Handbook

The FreeBSD Documentation Project

Revision: 42118

Copyright

Redistribution and use in source (XML DocBook) and 'compiled' forms (XML, HTML, PDF, PostScript, RTF and so forth) with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code (XML DocBook) must retain the above copyright notice, this list of conditions and the following disclaimer as the first lines of this file unmodified.

  2. Redistributions in compiled form (transformed to other DTDs, converted to PDF, PostScript, RTF and other formats) must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Important:

THIS DOCUMENTATION IS PROVIDED BY THE FREEBSD DOCUMENTATION PROJECT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FREEBSD DOCUMENTATION PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FreeBSD is a registered trademark of the FreeBSD Foundation.

3Com and HomeConnect are registered trademarks of 3Com Corporation.

3ware and Escalade are registered trademarks of 3ware Inc.

ARM is a registered trademark of ARM Limited.

Adaptec is a registered trademark of Adaptec, Inc.

Adobe, Acrobat, Acrobat Reader, and PostScript are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries.

Apple, AirPort, FireWire, Mac, Macintosh, Mac OS, Quicktime, and TrueType are trademarks of Apple Computer, Inc., registered in the United States and other countries.

Sound Blaster is a trademark of Creative Technology Ltd. in the United States and/or other countries.

CVSup is a registered trademark of John D. Polstra.

Heidelberg, Helvetica, Palatino, and Times Roman are either registered trademarks or trademarks of Heidelberger Druckmaschinen AG in the U.S. and other countries.

IBM, AIX, EtherJet, Netfinity, OS/2, PowerPC, PS/2, S/390, and ThinkPad are trademarks of International Business Machines Corporation in the United States, other countries, or both.

IEEE, POSIX, and 802 are registered trademarks of Institute of Electrical and Electronics Engineers, Inc. in the United States.

Intel, Celeron, EtherExpress, i386, i486, Itanium, Pentium, and Xeon are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

Intuit and Quicken are registered trademarks and/or registered service marks of Intuit Inc., or one of its subsidiaries, in the United States and other countries.

Linux is a registered trademark of Linus Torvalds.

LSI Logic, AcceleRAID, eXtremeRAID, MegaRAID and Mylex are trademarks or registered trademarks of LSI Logic Corp.

M-Systems and DiskOnChip are trademarks or registered trademarks of M-Systems Flash Disk Pioneers, Ltd.

Macromedia, Flash, and Shockwave are trademarks or registered trademarks of Macromedia, Inc. in the United States and/or other countries.

Microsoft, IntelliMouse, MS-DOS, Outlook, Windows, Windows Media and Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.

GateD and NextHop are registered and unregistered trademarks of NextHop in the U.S. and other countries.

Motif, OSF/1, and UNIX are registered trademarks and IT DialTone and The Open Group are trademarks of The Open Group in the United States and other countries.

Oracle is a registered trademark of Oracle Corporation.

RealNetworks, RealPlayer, and RealAudio are the registered trademarks of RealNetworks, Inc.

Red Hat, RPM, are trademarks or registered trademarks of Red Hat, Inc. in the United States and other countries.

SAP, R/3, and mySAP are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world.

Sun, Sun Microsystems, Java, Java Virtual Machine, JavaServer Pages, JDK, JRE, JSP, JVM, Netra, OpenJDK, Solaris, StarOffice, Sun Blade, Sun Enterprise, Sun Fire, SunOS, Ultra and VirtualBox are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.

MATLAB is a registered trademark of The MathWorks, Inc.

SpeedTouch is a trademark of Thomson.

U.S. Robotics and Sportster are registered trademarks of U.S. Robotics Corporation.

VMware is a trademark of VMware, Inc.

Waterloo Maple and Maple are trademarks or registered trademarks of Waterloo Maple Inc.

Mathematica is a registered trademark of Wolfram Research, Inc.

XFree86 is a trademark of The XFree86 Project, Inc.

Ogg Vorbis and Xiph.Org are trademarks of Xiph.Org.

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this document, and the FreeBSD Project was aware of the trademark claim, the designations have been followed by the or the ® symbol.

Last modified on 2013-07-02 by wblock.
Abstract

Welcome to FreeBSD! This handbook covers the installation and day to day use of FreeBSD 8.4-RELEASE and FreeBSD 9.1-RELEASE. This manual is a work in progress and is the work of many individuals. As such, some sections may become dated and require updating. If you are interested in helping out with this project, send email to the FreeBSD documentation project mailing list. The latest version of this document is always available from the FreeBSD web site (previous versions of this handbook can be obtained from http://docs.FreeBSD.org/doc/). It may also be downloaded in a variety of formats and compression options from the FreeBSD FTP server or one of the numerous mirror sites. If you would prefer to have a hard copy of the handbook, you can purchase one at the FreeBSD Mall. You may also want to search the handbook.


Table of Contents
Preface
I. Getting Started
1. Introduction
1.1. Synopsis
1.2. Welcome to FreeBSD!
1.3. About the FreeBSD Project
2. Installing FreeBSD 9.X and Later
2.1. Synopsis
2.2. Hardware Requirements
2.3. Pre-Installation Tasks
2.4. Starting the Installation
2.5. Introducing bsdinstall
2.6. Installing from the Network
2.7. Allocating Disk Space
2.8. Committing to the Installation
2.9. Post-Installation
2.10. Troubleshooting
2.11. Using the Live CD
3. Installing FreeBSD 8.X
3.1. Synopsis
3.2. Hardware Requirements
3.3. Pre-installation Tasks
3.4. Starting the Installation
3.5. Introducing sysinstall(8)
3.6. Allocating Disk Space
3.7. Choosing What to Install
3.8. Choosing the Installation Media
3.9. Committing to the Installation
3.10. Post-installation
3.11. Troubleshooting
3.12. Advanced Installation Guide
3.13. Preparing Custom Installation Media
4. UNIX Basics
4.1. Synopsis
4.2. Virtual Consoles and Terminals
4.3. Permissions
4.4. Directory Structure
4.5. Disk Organization
4.6. Mounting and Unmounting File Systems
4.7. Processes
4.8. Daemons, Signals, and Killing Processes
4.9. Shells
4.10. Text Editors
4.11. Devices and Device Nodes
4.12. For More Information
5. Installing Applications: Packages and Ports
5.1. Synopsis
5.2. Overview of Software Installation
5.3. Finding Software
5.4. Using Binary Packages
5.5. Using pkgng for Binary Package Management
5.6. Using the Ports Collection
5.7. Post-Installation Considerations
5.8. Dealing with Broken Ports
6. The X Window System
6.1. Synopsis
6.2. Understanding X
6.3. Installing X11
6.4. X11 Configuration
6.5. Using Fonts in X11
6.6. The X Display Manager
6.7. Desktop Environments
II. Common Tasks
7. Desktop Applications
7.1. Synopsis
7.2. Browsers
7.3. Productivity
7.4. Document Viewers
7.5. Finance
8. Multimedia
8.1. Synopsis
8.2. Setting Up the Sound Card
8.3. MP3 Audio
8.4. Video Playback
8.5. Setting Up TV Cards
8.6. MythTV
8.7. Image Scanners
9. Configuring the FreeBSD Kernel
9.1. Synopsis
9.2. Why Build a Custom Kernel?
9.3. Finding the System Hardware
9.4. Kernel Drivers, Subsystems, and Modules
9.5. Building and Installing a Custom Kernel
9.6. The Configuration File
9.7. If Something Goes Wrong
10. Printing
10.1. Synopsis
10.2. Introduction
10.3. Basic Setup
10.4. Advanced Printer Setup
10.5. Using Printers
10.6. Alternatives to the Standard Spooler
10.7. Troubleshooting
11. Linux® Binary Compatibility
11.1. Synopsis
11.2. Installation
11.3. Installing Mathematica®
11.4. Installing Maple
11.5. Installing MATLAB®
11.6. Installing Oracle®
11.7. Advanced Topics
III. System Administration
12. Configuration and Tuning
12.1. Synopsis
12.2. Initial Configuration
12.3. Core Configuration
12.4. Application Configuration
12.5. Starting Services
12.6. Configuring cron(8)
12.7. Using rc(8) Under FreeBSD
12.8. Setting Up Network Interface Cards
12.9. Virtual Hosts
12.10. Configuring the System Logger, syslogd
12.11. Configuration Files
12.12. Tuning with sysctl(8)
12.13. Tuning Disks
12.14. Tuning Kernel Limits
12.15. Adding Swap Space
12.16. Power and Resource Management
12.17. Using and Debugging FreeBSD ACPI
13. The FreeBSD Booting Process
13.1. Synopsis
13.2. The Booting Problem
13.3. The Boot Manager and Boot Stages
13.4. Kernel Interaction During Boot
13.5. Device Hints
13.6. Init: Process Control Initialization
13.7. Shutdown Sequence
14. Users and Basic Account Management
14.1. Synopsis
14.2. Introduction
14.3. Modifying Accounts
14.4. Limiting Users
14.5. Groups
14.6. Becoming Superuser
15. Security
15.1. Synopsis
15.2. Introduction
15.3. Securing FreeBSD
15.4. DES, Blowfish, MD5, SHA256, SHA512, and Crypt
15.5. One-time Passwords
15.6. TCP Wrappers
15.7. Kerberos5
15.8. OpenSSL
15.9. VPN over IPsec
15.10. OpenSSH
15.11. Filesystem Access Control Lists (ACL)s
15.12. Monitoring Third Party Security Issues
15.13. FreeBSD Security Advisories
15.14. Process Accounting
15.15. Resource Limits
16. Jails
16.1. Synopsis
16.2. Terms Related to Jails
16.3. Introduction
16.4. Creating and Controlling Jails
16.5. Fine Tuning and Administration
16.6. Application of Jails
17. Mandatory Access Control
17.1. Synopsis
17.2. Key Terms in This Chapter
17.3. Explanation of MAC
17.4. Understanding MAC Labels
17.5. Planning the Security Configuration
17.6. Module Configuration
17.7. The MAC See Other UIDs Policy
17.8. The MAC BSD Extended Policy
17.9. The MAC Interface Silencing Policy
17.10. The MAC Port Access Control List Policy
17.11. The MAC Partition Policy
17.12. The MAC Multi-Level Security Module
17.13. The MAC Biba Module
17.14. The MAC LOMAC Module
17.15. Nagios in a MAC Jail
17.16. User Lock Down
17.17. Troubleshooting the MAC Framework
18. Security Event Auditing
18.1. Synopsis
18.2. Key Terms in This Chapter
18.3. Installing Audit Support
18.4. Audit Configuration
18.5. Administering the Audit Subsystem
19. Storage
19.1. Synopsis
19.2. Device Names
19.3. Adding Disks
19.4. USB Storage Devices
19.5. Creating and Using CD Media
19.6. Creating and Using DVD Media
19.7. Creating and Using Floppy Disks
19.8. Creating and Using Data Tapes
19.9. Backup Strategies
19.10. Backup Basics
19.11. Network, Memory, and File-Backed File Systems
19.12. File System Snapshots
19.13. File System Quotas
19.14. Encrypting Disk Partitions
19.15. Encrypting Swap Space
19.16. Highly Available Storage (HAST)
20. GEOM: Modular Disk Transformation Framework
20.1. Synopsis
20.2. GEOM Introduction
20.3. RAID0 - Striping
20.4. RAID1 - Mirroring
20.5. Software RAID Devices
20.6. RAID3 - Byte-level Striping with Dedicated Parity
20.7. GEOM Gate Network Devices
20.8. Labeling Disk Devices
20.9. UFS Journaling Through GEOM
21. File Systems Support
21.1. Synopsis
21.2. The Z File System (ZFS)
21.3. Linux® Filesystems
22. Virtualization
22.1. Synopsis
22.2. FreeBSD as a Guest OS
22.3. FreeBSD as a Host
23. Localization - i18n/L10n Usage and Setup
23.1. Synopsis
23.2. The Basics
23.3. Using Localization
23.4. Compiling i18n Programs
23.5. Localizing FreeBSD to Specific Languages
24. Updating and Upgrading FreeBSD
24.1. Synopsis
24.2. FreeBSD Update
24.3. Portsnap: a Ports Collection Update Tool
24.4. Updating the Documentation Set
24.5. Tracking a Development Branch
24.6. Synchronizing Source
24.7. Rebuilding world
24.8. Tracking for Multiple Machines
25. DTrace
25.1. Synopsis
25.2. Implementation Differences
25.3. Enabling DTrace Support
25.4. Using DTrace
25.5. The D Language
IV. Network Communication
26. Serial Communications
26.1. Synopsis
26.2. Introduction
26.3. Terminals
26.4. Dial-in Service
26.5. Dial-out Service
26.6. Setting Up the Serial Console
27. PPP and SLIP
27.1. Synopsis
27.2. Using User PPP
27.3. Troubleshooting PPP Connections
27.4. Using PPP over Ethernet (PPPoE)
27.5. Using PPP over ATM (PPPoA)
28. Electronic Mail
28.1. Synopsis
28.2. Using Electronic Mail
28.3. Sendmail Configuration
28.4. Changing the Mail Transfer Agent
28.5. Troubleshooting
28.6. Advanced Topics
28.7. Setting Up to Send Only
28.8. Using Mail with a Dialup Connection
28.9. SMTP Authentication
28.10. Mail User Agents
28.11. Using fetchmail
28.12. Using procmail
29. Network Servers
29.1. Synopsis
29.2. The inetd Super-Server
29.3. Network File System (NFS)
29.4. Network Information System (NIS/YP)
29.5. FreeBSD and LDAP
29.6. Automatic Network Configuration (DHCP)
29.7. Domain Name System (DNS)
29.8. Apache HTTP Server
29.9. File Transfer Protocol (FTP)
29.10. File and Print Services for Microsoft® Windows® Clients (Samba)
29.11. Clock Synchronization with NTP
29.12. Remote Host Logging with syslogd
30. Firewalls
30.1. Introduction
30.2. Firewall Concepts
30.3. Firewall Packages
30.4. PF and ALTQ
30.5. The IPFILTER (IPF) Firewall
30.6. IPFW
31. Advanced Networking
31.1. Synopsis
31.2. Gateways and Routes
31.3. Wireless Networking
31.4. Bluetooth
31.5. Bridging
31.6. Link Aggregation and Failover
31.7. Diskless Operation
31.8. PXE Booting with an NFS Root File System
31.9. Network Address Translation
31.10. IPv6
31.11. Asynchronous Transfer Mode (ATM)
31.12. Common Address Redundancy Protocol (CARP)
V. Appendices
A. Obtaining FreeBSD
A.1. CDROM and DVD Publishers
A.2. FTP Sites
A.3. Anonymous CVS (Deprecated)
A.4. Using CTM
A.5. Using Subversion
A.6. Subversion Mirror Sites
A.7. Using CVSup (Deprecated)
A.8. CVS Tags
A.9. rsync Sites
B. Bibliography
B.1. Books & Magazines Specific to FreeBSD
B.2. Users' Guides
B.3. Administrators' Guides
B.4. Programmers' Guides
B.5. Operating System Internals
B.6. Security Reference
B.7. Hardware Reference
B.8. UNIX® History
B.9. Magazines and Journals
C. Resources on the Internet
C.1. Mailing Lists
C.2. Usenet Newsgroups
C.3. World Wide Web Servers
C.4. Email Addresses
D. PGP Keys
D.1. Officers
D.2. Core Team Members
D.3. Developers
D.4. Other Cluster Account Holders
FreeBSD Glossary
Index
List of Figures
2.1. FreeBSD Boot Loader Menu
2.2. Typical Device Probe Results
2.3. Selecting Installation Media Mode
2.4. Keymap Selection
2.5. Selecting Keyboard Menu
2.6. Setting the Hostname
2.7. Selecting Components to Install
2.8. Installing from the Network
2.9. Choosing a Mirror
2.10. Selecting Guided or Manual Partitioning
2.11. Selecting from Multiple Disks
2.12. Selecting Entire Disk or Partition
2.13. Review Created Partitions
2.14. Manually Create Partitions
2.15. Manually Create Partitions
2.16. Manually Create Partitions
2.17. Final Confirmation
2.18. Fetching Distribution Files
2.19. Verifying Distribution Files
2.20. Extracting Distribution Files
2.21. Setting the root Password
2.22. Choose a Network Interface
2.23. Scanning for Wireless Access Points
2.24. Choosing a Wireless Network
2.25. WPA2 Setup
2.26. Choose IPv4 Networking
2.27. Choose IPv4 DHCP Configuration
2.28. IPv4 Static Configuration
2.29. Choose IPv6 Networking
2.30. Choose IPv6 SLAAC Configuration
2.31. IPv6 Static Configuration
2.32. DNS Configuration
2.33. Select Local or UTC Clock
2.34. Select a Region
2.35. Select a Country
2.36. Select a Time Zone
2.37. Confirm Time Zone
2.38. Selecting Additional Services to Enable
2.39. Enabling Crash Dumps
2.40. Add User Accounts
2.41. Enter User Information
2.42. Exit User and Group Management
2.43. Final Configuration
2.44. Manual Configuration
2.45. Complete the Installation
3.1. FreeBSD Boot Loader Menu
3.2. Typical Device Probe Results
3.3. Selecting Country Menu
3.4. Selecting Keyboard Menu
3.5. Selecting Usage from Sysinstall Main Menu
3.6. Selecting Documentation Menu
3.7. Sysinstall Documentation Menu
3.8. Sysinstall Main Menu
3.9. Sysinstall Keymap Menu
3.10. Sysinstall Main Menu
3.11. Sysinstall Options
3.12. Begin Standard Installation
3.13. Select Drive for FDisk
3.14. Typical Default FDisk Partitions
3.15. Fdisk Partition Using Entire Disk
3.16. Sysinstall Boot Manager Menu
3.17. Exit Select Drive
3.18. Sysinstall Disklabel Editor
3.19. Sysinstall Disklabel Editor with Auto Defaults
3.20. Free Space for Root Partition
3.21. Edit Root Partition Size
3.22. Choose the Root Partition Type
3.23. Choose the Root Mount Point
3.24. Sysinstall Disklabel Editor
3.25. Choose Distributions
3.26. Confirm Distributions
3.27. Choose Installation Media
3.28. Selecting an Ethernet Device
3.29. Set Network Configuration for ed0
3.30. Editing inetd.conf
3.31. Default Anonymous FTP Configuration
3.32. Edit the FTP Welcome Message
3.33. Editing exports
3.34. System Console Configuration Options
3.35. Screen Saver Options
3.36. Screen Saver Timeout
3.37. System Console Configuration Exit
3.38. Select the Region
3.39. Select the Country
3.40. Select the Time Zone
3.41. Select Mouse Protocol Type
3.42. Set Mouse Protocol
3.43. Configure Mouse Port
3.44. Setting the Mouse Port
3.45. Enable the Mouse Daemon
3.46. Test the Mouse Daemon
3.47. Select Package Category
3.48. Select Packages
3.49. Install Packages
3.50. Confirm Package Installation
3.51. Select User
3.52. Add User Information
3.53. Exit User and Group Management
3.54. Exit Install
3.55. Network Configuration Upper-level
3.56. Select a Default MTA
3.57. Ntpdate Configuration
3.58. Network Configuration Lower-level
31.1. PXE Booting Process with NFS Root Mount
List of Tables
2.1. Partitioning Schemes
3.1. Sample Device Inventory
3.2. Partition Layout for First Disk
3.3. Partition Layout for Subsequent Disks
3.4. FreeBSD ISO Image Names and Meanings
4.1. Disk Device Codes
19.1. Physical Disk Naming Conventions
26.1. DB-25 to DB-25 Null-Modem Cable
26.2. DB-9 to DB-9 Null-Modem Cable
26.3. DB-9 to DB-25 Null-Modem Cable
26.4. Signal Names
31.1. Station Capability Codes
31.2. Reserved IPv6 Addresses
List of Examples
2.1. Using an Existing Partition
2.2. Shrinking an Existing Partition
2.3. Creating Traditional Split Filesystem Partitions
3.1. Using an Existing Partition Unchanged
3.2. Shrinking an Existing Partition
4.1. Sample Disk, Slice, and Partition Names
4.2. Conceptual Model of a Disk
12.1. Creating a Swapfile on FreeBSD
13.1. boot0 Screenshot
13.2. boot2 Screenshot
13.3. An Insecure Console in /etc/ttys
14.1. Adding a User on FreeBSD
14.2. rmuser Interactive Account Removal
14.3. Interactive chpass by Superuser
14.4. Interactive chpass by Normal User
14.5. Changing Your Password
14.6. Changing Another User's Password as the Superuser
14.7. Adding a Group Using pw(8)
14.8. Adding User Accounts to a New Group Using pw(8)
14.9. Adding a New Member to a Group Using pw(8)
14.10. Using id(1) to Determine Group Membership
14.11. Install a Program As The Superuser
15.1. Using ssh(1) to Create a Secure Tunnel for SMTP
19.1. Using dump over ssh
19.2. Using dump over ssh with RSH Set
19.3. Using mdconfig to Mount an Existing File System Image
19.4. Creating a New File-Backed Disk with mdconfig
19.5. Configure and Mount a File-Backed Disk with mdmfs
19.6. Creating a New Memory-Based Disk with mdconfig
19.7. Creating a New Memory-Based Disk with mdmfs
20.1. Labeling Partitions on the Boot Disk
26.1. Adding Terminal Entries to /etc/ttys
28.1. Configuring the Sendmail Access Database
28.2. Mail Aliases
28.3. Example Virtual Domain Mail Map
29.1. Reloading the inetd Configuration File
29.2. Mounting an Export with amd
29.3. Installing Django with Apache2, mod_python3, and PostgreSQL
29.4. Apache Configuration for Django/mod_python
31.1. LACP Aggregation with a Cisco® Switch
31.2. Failover Mode
31.3. Failover Mode Between Wired and Wireless Interfaces

Preface

Intended Audience

The FreeBSD newcomer will find that the first section of this book guides the user through the FreeBSD installation process and gently introduces the concepts and conventions that underpin UNIX®. Working through this section requires little more than the desire to explore, and the ability to take on board new concepts as they are introduced.

Once you have traveled this far, the second, far larger, section of the Handbook is a comprehensive reference to all manner of topics of interest to FreeBSD system administrators. Some of these chapters may recommend that you do some prior reading, and this is noted in the synopsis at the beginning of each chapter.

For a list of additional sources of information, please see Appendix B, Bibliography.

Changes from the Third Edition

The current online version of the Handbook represents the cumulative effort of many hundreds of contributors over the past 10 years. The following are some of the significant changes since the two volume third edition was published in 2004:

Changes from the Second Edition (2004)

The third edition was the culmination of over two years of work by the dedicated members of the FreeBSD Documentation Project. The printed edition grew to such a size that it was necessary to publish as two separate volumes. The following are the major changes in this new edition:

  • Chapter 12, Configuration and Tuning, Configuration and Tuning, has been expanded with new information about the ACPI power and resource management, the cron system utility, and more kernel tuning options.

  • Chapter 15, Security, Security, has been expanded with new information about virtual private networks (VPNs), file system access control lists (ACLs), and security advisories.

  • Chapter 17, Mandatory Access Control, Mandatory Access Control (MAC), is a new chapter with this edition. It explains what MAC is and how this mechanism can be used to secure a FreeBSD system.

  • Chapter 19, Storage, Storage, has been expanded with new information about USB storage devices, file system snapshots, file system quotas, file and network backed filesystems, and encrypted disk partitions.

  • A troubleshooting section has been added to Chapter 27, PPP and SLIP, PPP and SLIP.

  • Chapter 28, Electronic Mail, Electronic Mail, has been expanded with new information about using alternative transport agents, SMTP authentication, UUCP, fetchmail, procmail, and other advanced topics.

  • Chapter 29, Network Servers, Network Servers, is all new with this edition. This chapter includes information about setting up the Apache HTTP Server, ftpd, and setting up a server for Microsoft® Windows® clients with Samba. Some sections from Chapter 31, Advanced Networking, Advanced Networking, were moved here to improve the presentation.

  • Chapter 31, Advanced Networking, Advanced Networking, has been expanded with new information about using Bluetooth® devices with FreeBSD, setting up wireless networks, and Asynchronous Transfer Mode (ATM) networking.

  • A glossary has been added to provide a central location for the definitions of technical terms used throughout the book.

  • A number of aesthetic improvements have been made to the tables and figures throughout the book.

Changes from the First Edition (2001)

The second edition was the culmination of over two years of work by the dedicated members of the FreeBSD Documentation Project. The following were the major changes in this edition:

  • A complete Index has been added.

  • All ASCII figures have been replaced by graphical diagrams.

  • A standard synopsis has been added to each chapter to give a quick summary of what information the chapter contains, and what the reader is expected to know.

  • The content has been logically reorganized into three parts: Getting Started, System Administration, and Appendices.

  • Chapter 3, Installing FreeBSD 8.X (Installing FreeBSD) was completely rewritten with many screenshots to make it much easier for new users to grasp the text.

  • Chapter 4, UNIX Basics (UNIX® Basics) has been expanded to contain additional information about processes, daemons, and signals.

  • Chapter 5, Installing Applications: Packages and Ports (Installing Applications) has been expanded to contain additional information about binary package management.

  • Chapter 6, The X Window System (The X Window System) has been completely rewritten with an emphasis on using modern desktop technologies such as KDE and GNOME on XFree86™ 4.X.

  • Chapter 13, The FreeBSD Booting Process (The FreeBSD Booting Process) has been expanded.

  • Chapter 19, Storage (Storage) has been written from what used to be two separate chapters on Disks and Backups. We feel that the topics are easier to comprehend when presented as a single chapter. A section on RAID (both hardware and software) has also been added.

  • Chapter 26, Serial Communications (Serial Communications) has been completely reorganized and updated for FreeBSD 4.X/5.X.

  • Chapter 27, PPP and SLIP (PPP and SLIP) has been substantially updated.

  • Many new sections have been added to Chapter 31, Advanced Networking (Advanced Networking).

  • Chapter 28, Electronic Mail (Electronic Mail) has been expanded to include more information about configuring sendmail.

  • Chapter 11, Linux® Binary Compatibility (Linux® Compatibility) has been expanded to include information about installing Oracle® and SAP® R/3®.

  • The following new topics are covered in this second edition:

Organization of This Book

This book is split into five logically distinct sections. The first section, Getting Started, covers the installation and basic usage of FreeBSD. It is expected that the reader will follow these chapters in sequence, possibly skipping chapters covering familiar topics. The second section, Common Tasks, covers some frequently used features of FreeBSD. This section, and all subsequent sections, can be read out of order. Each chapter begins with a succinct synopsis that describes what the chapter covers and what the reader is expected to already know. This is meant to allow the casual reader to skip around to find chapters of interest. The third section, System Administration, covers administration topics. The fourth section, Network Communication, covers networking and server topics. The fifth section contains appendices of reference information.

Chapter 1, Introduction, Introduction

Introduces FreeBSD to a new user. It describes the history of the FreeBSD Project, its goals and development model.

Chapter 3, Installing FreeBSD 8.X, Installation of FreeBSD 8.x and Earlier

Walks a user through the entire installation process of FreeBSD 8.x and earlier using sysinstall. Some advanced installation topics, such as installing through a serial console, are also covered.

Chapter 2, Installing FreeBSD 9.X and Later, Installation of FreeBSD 9.x and Later

Walks a user through the entire installation process of FreeBSD 9.x and later using bsdinstall.

Chapter 4, UNIX Basics, UNIX® Basics

Covers the basic commands and functionality of the FreeBSD operating system. If you are familiar with Linux® or another flavor of UNIX® then you can probably skip this chapter.

Chapter 5, Installing Applications: Packages and Ports, Installing Applications

Covers the installation of third-party software with both FreeBSD's innovative Ports Collection and standard binary packages.

Chapter 6, The X Window System, The X Window System

Describes the X Window System in general and using X11 on FreeBSD in particular. Also describes common desktop environments such as KDE and GNOME.

Chapter 7, Desktop Applications, Desktop Applications

Lists some common desktop applications, such as web browsers and productivity suites, and describes how to install them on FreeBSD.

Chapter 8, Multimedia, Multimedia

Shows how to set up sound and video playback support for your system. Also describes some sample audio and video applications.

Chapter 9, Configuring the FreeBSD Kernel, Configuring the FreeBSD Kernel

Explains why you might need to configure a new kernel and provides detailed instructions for configuring, building, and installing a custom kernel.

Chapter 10, Printing, Printing

Describes managing printers on FreeBSD, including information about banner pages, printer accounting, and initial setup.

Chapter 11, Linux® Binary Compatibility, Linux® Binary Compatibility

Describes the Linux® compatibility features of FreeBSD. Also provides detailed installation instructions for many popular Linux® applications such as Oracle® and Mathematica®.

Chapter 12, Configuration and Tuning, Configuration and Tuning

Describes the parameters available for system administrators to tune a FreeBSD system for optimum performance. Also describes the various configuration files used in FreeBSD and where to find them.

Chapter 13, The FreeBSD Booting Process, Booting Process

Describes the FreeBSD boot process and explains how to control this process with configuration options.

Chapter 14, Users and Basic Account Management, Users and Basic Account Management

Describes the creation and manipulation of user accounts. Also discusses resource limitations that can be set on users and other account management tasks.

Chapter 15, Security, Security

Describes many different tools available to help keep your FreeBSD system secure, including Kerberos, IPsec and OpenSSH.

Chapter 16, Jails, Jails

Describes the jails framework, and the improvements of jails over the traditional chroot support of FreeBSD.

Chapter 17, Mandatory Access Control, Mandatory Access Control

Explains what Mandatory Access Control (MAC) is and how this mechanism can be used to secure a FreeBSD system.

Chapter 18, Security Event Auditing, Security Event Auditing

Describes what FreeBSD Event Auditing is, how it can be installed, configured, and how audit trails can be inspected or monitored.

Chapter 19, Storage, Storage

Describes how to manage storage media and filesystems with FreeBSD. This includes physical disks, RAID arrays, optical and tape media, memory-backed disks, and network filesystems.

Section 20.1, “Synopsis”, GEOM

Describes what the GEOM framework in FreeBSD is and how to configure various supported RAID levels.

Chapter 21, File Systems Support, File Systems Support

Examines support of non-native file systems in FreeBSD, like the Z File System from Sun™.

Chapter 22, Virtualization, Virtualization

Describes what virtualization systems offer, and how they can be used with FreeBSD.

Chapter 23, Localization - i18n/L10n Usage and Setup, Localization

Describes how to use FreeBSD in languages other than English. Covers both system and application level localization.

Chapter 24, Updating and Upgrading FreeBSD, Updating and Upgrading FreeBSD

Explains the differences between FreeBSD-STABLE, FreeBSD-CURRENT, and FreeBSD releases. Describes which users would benefit from tracking a development system and outlines that process. Covers the methods users may take to update their system to the latest security release.

Chapter 25, DTrace, DTrace

Describes how to configure and use the DTrace tool from Sun™ in FreeBSD. Dynamic tracing can help locate performance issues, by performing real time system analysis.

Chapter 26, Serial Communications, Serial Communications

Explains how to connect terminals and modems to your FreeBSD system for both dial in and dial out connections.

Chapter 27, PPP and SLIP, PPP and SLIP

Describes how to use PPP, SLIP, or PPP over Ethernet to connect to remote systems with FreeBSD.

Chapter 28, Electronic Mail, Electronic Mail

Explains the different components of an email server and dives into simple configuration topics for the most popular mail server software: sendmail.

Chapter 29, Network Servers, Network Servers

Provides detailed instructions and example configuration files to set up your FreeBSD machine as a network filesystem server, domain name server, network information system server, or time synchronization server.

Chapter 30, Firewalls, Firewalls

Explains the philosophy behind software-based firewalls and provides detailed information about the configuration of the different firewalls available for FreeBSD.

Chapter 31, Advanced Networking, Advanced Networking

Describes many networking topics, including sharing an Internet connection with other computers on your LAN, advanced routing topics, wireless networking, Bluetooth®, ATM, IPv6, and much more.

Appendix A, Obtaining FreeBSD, Obtaining FreeBSD

Lists different sources for obtaining FreeBSD media on CDROM or DVD as well as different sites on the Internet that allow you to download and install FreeBSD.

Appendix B, Bibliography, Bibliography

This book touches on many different subjects that may leave you hungry for a more detailed explanation. The bibliography lists many excellent books that are referenced in the text.

Appendix C, Resources on the Internet, Resources on the Internet

Describes the many forums available for FreeBSD users to post questions and engage in technical conversations about FreeBSD.

Appendix D, PGP Keys, PGP Keys

Lists the PGP fingerprints of several FreeBSD Developers.

Conventions used in this book

To provide a consistent and easy to read text, several conventions are followed throughout the book.

Typographic Conventions

Italic

An italic font is used for filenames, URLs, emphasized text, and the first usage of technical terms.

Monospace

A monospaced font is used for error messages, commands, environment variables, names of ports, hostnames, user names, group names, device names, variables, and code fragments.

Bold

A bold font is used for applications, commands, and keys.

User Input

Keys are shown in bold to stand out from other text. Key combinations that are meant to be typed simultaneously are shown with `+' between the keys, such as:

Ctrl+Alt+Del

Meaning the user should type the Ctrl, Alt, and Del keys at the same time.

Keys that are meant to be typed in sequence will be separated with commas, for example:

Ctrl+X, Ctrl+S

Would mean that the user is expected to type the Ctrl and X keys simultaneously and then to type the Ctrl and S keys simultaneously.

Examples

Examples starting with E:\> indicate a MS-DOS® command. Unless otherwise noted, these commands may be executed from a Command Prompt window in a modern Microsoft® Windows® environment.

E:\> tools\fdimage floppies\kern.flp A:

Examples starting with # indicate a command that must be invoked as the superuser in FreeBSD. You can login as root to type the command, or login as your normal account and use su(1) to gain superuser privileges.

# dd if=kern.flp of=/dev/fd0

Examples starting with % indicate a command that should be invoked from a normal user account. Unless otherwise noted, C-shell syntax is used for setting environment variables and other shell commands.

% top

Acknowledgments

The book you are holding represents the efforts of many hundreds of people around the world. Whether they sent in fixes for typos, or submitted complete chapters, all the contributions have been useful.

Several companies have supported the development of this document by paying authors to work on it full-time, paying for publication, etc. In particular, BSDi (subsequently acquired by Wind River Systems) paid members of the FreeBSD Documentation Project to work on improving this book full time leading up to the publication of the first printed edition in March 2000 (ISBN 1-57176-241-8). Wind River Systems then paid several additional authors to make a number of improvements to the print-output infrastructure and to add additional chapters to the text. This work culminated in the publication of the second printed edition in November 2001 (ISBN 1-57176-303-1). In 2003-2004, FreeBSD Mall, Inc, paid several contributors to improve the Handbook in preparation for the third printed edition.

Part I. Getting Started

This part of the FreeBSD Handbook is for users and administrators who are new to FreeBSD. These chapters:

  • Introduce you to FreeBSD.

  • Guide you through the installation process.

  • Teach you UNIX® basics and fundamentals.

  • Show you how to install the wealth of third party applications available for FreeBSD.

  • Introduce you to X, the UNIX® windowing system, and detail how to configure a desktop environment that makes you more productive.

We have tried to keep the number of forward references in the text to a minimum so that you can read this section of the Handbook from front to back with the minimum page flipping required.

Table of Contents
1. Introduction
1.1. Synopsis
1.2. Welcome to FreeBSD!
1.3. About the FreeBSD Project
2. Installing FreeBSD 9.X and Later
2.1. Synopsis
2.2. Hardware Requirements
2.3. Pre-Installation Tasks
2.4. Starting the Installation
2.5. Introducing bsdinstall
2.6. Installing from the Network
2.7. Allocating Disk Space
2.8. Committing to the Installation
2.9. Post-Installation
2.10. Troubleshooting
2.11. Using the Live CD
3. Installing FreeBSD 8.X
3.1. Synopsis
3.2. Hardware Requirements
3.3. Pre-installation Tasks
3.4. Starting the Installation
3.5. Introducing sysinstall(8)
3.6. Allocating Disk Space
3.7. Choosing What to Install
3.8. Choosing the Installation Media
3.9. Committing to the Installation
3.10. Post-installation
3.11. Troubleshooting
3.12. Advanced Installation Guide
3.13. Preparing Custom Installation Media
4. UNIX Basics
4.1. Synopsis
4.2. Virtual Consoles and Terminals
4.3. Permissions
4.4. Directory Structure
4.5. Disk Organization
4.6. Mounting and Unmounting File Systems
4.7. Processes
4.8. Daemons, Signals, and Killing Processes
4.9. Shells
4.10. Text Editors
4.11. Devices and Device Nodes
4.12. For More Information
5. Installing Applications: Packages and Ports
5.1. Synopsis
5.2. Overview of Software Installation
5.3. Finding Software
5.4. Using Binary Packages
5.5. Using pkgng for Binary Package Management
5.6. Using the Ports Collection
5.7. Post-Installation Considerations
5.8. Dealing with Broken Ports
6. The X Window System
6.1. Synopsis
6.2. Understanding X
6.3. Installing X11
6.4. X11 Configuration
6.5. Using Fonts in X11
6.6. The X Display Manager
6.7. Desktop Environments

Chapter 1. Introduction

Restructured, reorganized, and parts rewritten by Jim Mock.

1.1. Synopsis

Thank you for your interest in FreeBSD! The following chapter covers various aspects of the FreeBSD Project, such as its history, goals, development model, and so on.

After reading this chapter, you will know:

  • How FreeBSD relates to other computer operating systems.

  • The history of the FreeBSD Project.

  • The goals of the FreeBSD Project.

  • The basics of the FreeBSD open-source development model.

  • And of course: where the name FreeBSD comes from.

1.2. Welcome to FreeBSD!

FreeBSD is a 4.4BSD-Lite based operating system for Intel (x86 and Itanium®), AMD64, Sun UltraSPARC® computers. Ports to other architectures are also underway. You can also read about the history of FreeBSD, or the current release. If you are interested in contributing something to the Project (code, hardware, funding), see the Contributing to FreeBSD article.

1.2.1. What Can FreeBSD Do?

FreeBSD has many noteworthy features. Some of these are:

  • Preemptive multitasking with dynamic priority adjustment to ensure smooth and fair sharing of the computer between applications and users, even under the heaviest of loads.

  • Multi-user facilities which allow many people to use a FreeBSD system simultaneously for a variety of things. This means, for example, that system peripherals such as printers and tape drives are properly shared between all users on the system or the network and that individual resource limits can be placed on users or groups of users, protecting critical system resources from over-use.

  • Strong TCP/IP networking with support for industry standards such as SCTP, DHCP, NFS, NIS, PPP, SLIP, IPsec, and IPv6. This means that your FreeBSD machine can interoperate easily with other systems as well as act as an enterprise server, providing vital functions such as NFS (remote file access) and email services or putting your organization on the Internet with WWW, FTP, routing and firewall (security) services.

  • Memory protection ensures that applications (or users) cannot interfere with each other. One application crashing will not affect others in any way.

  • The industry standard X Window System (X11R7) provides a graphical user interface (GUI) for the cost of a common VGA card and monitor and comes with full sources.

  • Binary compatibility with many programs built for Linux, SCO, SVR4, BSDI and NetBSD.

  • Thousands of ready-to-run applications are available from the FreeBSD ports and packages collection. Why search the net when you can find it all right here?

  • Thousands of additional and easy-to-port applications are available on the Internet. FreeBSD is source code compatible with most popular commercial UNIX® systems and thus most applications require few, if any, changes to compile.

  • Demand paged virtual memory and merged VM/buffer cache design efficiently satisfies applications with large appetites for memory while still maintaining interactive response to other users.

  • SMP support for machines with multiple CPUs.

  • A full complement of C and C++ development tools. Many additional languages for advanced research and development are also available in the ports and packages collection.

  • Source code for the entire system means you have the greatest degree of control over your environment. Why be locked into a proprietary solution at the mercy of your vendor when you can have a truly open system?

  • Extensive online documentation.

  • And many more!

FreeBSD is based on the 4.4BSD-Lite release from Computer Systems Research Group (CSRG) at the University of California at Berkeley, and carries on the distinguished tradition of BSD systems development. In addition to the fine work provided by CSRG, the FreeBSD Project has put in many thousands of hours in fine tuning the system for maximum performance and reliability in real-life load situations. As many of the commercial giants struggle to field PC operating systems with such features, performance and reliability, FreeBSD can offer them now!

The applications to which FreeBSD can be put are truly limited only by your own imagination. From software development to factory automation, inventory control to azimuth correction of remote satellite antennae; if it can be done with a commercial UNIX® product then it is more than likely that you can do it with FreeBSD too! FreeBSD also benefits significantly from literally thousands of high quality applications developed by research centers and universities around the world, often available at little to no cost. Commercial applications are also available and appearing in greater numbers every day.

Because the source code for FreeBSD itself is generally available, the system can also be customized to an almost unheard of degree for special applications or projects, and in ways not generally possible with operating systems from most major commercial vendors. Here is just a sampling of some of the applications in which people are currently using FreeBSD:

  • Internet Services: The robust TCP/IP networking built into FreeBSD makes it an ideal platform for a variety of Internet services such as:

    • FTP servers

    • World Wide Web servers (standard or secure [SSL])

    • IPv4 and IPv6 routing

    • Firewalls and NAT (IP masquerading) gateways

    • Electronic Mail servers

    • USENET News or Bulletin Board Systems

    • And more...

    With FreeBSD, you can easily start out small with an inexpensive 386 class PC and upgrade all the way up to a quad-processor Xeon with RAID storage as your enterprise grows.

  • Education: Are you a student of computer science or a related engineering field? There is no better way of learning about operating systems, computer architecture and networking than the hands on, under the hood experience that FreeBSD can provide. A number of freely available CAD, mathematical and graphic design packages also make it highly useful to those whose primary interest in a computer is to get other work done!

  • Research: With source code for the entire system available, FreeBSD is an excellent platform for research in operating systems as well as other branches of computer science. FreeBSD's freely available nature also makes it possible for remote groups to collaborate on ideas or shared development without having to worry about special licensing agreements or limitations on what may be discussed in open forums.

  • Networking: Need a new router? A name server (DNS)? A firewall to keep people out of your internal network? FreeBSD can easily turn that unused 386 or 486 PC sitting in the corner into an advanced router with sophisticated packet-filtering capabilities.

  • X Window workstation: FreeBSD is a fine choice for an inexpensive X terminal solution, using the freely available X11 server. Unlike an X terminal, FreeBSD allows many applications to be run locally if desired, thus relieving the burden on a central server. FreeBSD can even boot diskless, making individual workstations even cheaper and easier to administer.

  • Software Development: The basic FreeBSD system comes with a full complement of development tools including the renowned GNU C/C++ compiler and debugger.

FreeBSD is available in both source and binary form on CD-ROM, DVD, and via anonymous FTP. Please see Appendix A, Obtaining FreeBSD for more information about obtaining FreeBSD.

1.2.2. Who Uses FreeBSD?

FreeBSD is used as a platform for devices and products from many of the world's largest IT companies, including:

FreeBSD is also used to power some of the biggest sites on the Internet, including:

and many more.

1.3. About the FreeBSD Project

The following section provides some background information on the project, including a brief history, project goals, and the development model of the project.

1.3.1. A Brief History of FreeBSD

The FreeBSD Project had its genesis in the early part of 1993, partially as an outgrowth of the Unofficial 386BSDPatchkit by the patchkit's last 3 coordinators: Nate Williams, Rod Grimes and Jordan Hubbard.

The original goal was to produce an intermediate snapshot of 386BSD in order to fix a number of problems with it that the patchkit mechanism just was not capable of solving. The early working title for the project was 386BSD 0.5 or 386BSD Interim in reference of that fact.

386BSD was Bill Jolitz's operating system, which had been up to that point suffering rather severely from almost a year's worth of neglect. As the patchkit swelled ever more uncomfortably with each passing day, they decided to assist Bill by providing this interim cleanup snapshot. Those plans came to a rude halt when Bill Jolitz suddenly decided to withdraw his sanction from the project without any clear indication of what would be done instead.

The trio thought that the goal remained worthwhile, even without Bill's support, and so they adopted the name "FreeBSD" coined by David Greenman. The initial objectives were set after consulting with the system's current users and, once it became clear that the project was on the road to perhaps even becoming a reality, Jordan contacted Walnut Creek CDROM with an eye toward improving FreeBSD's distribution channels for those many unfortunates without easy access to the Internet. Walnut Creek CDROM not only supported the idea of distributing FreeBSD on CD but also went so far as to provide the project with a machine to work on and a fast Internet connection. Without Walnut Creek CDROM's almost unprecedented degree of faith in what was, at the time, a completely unknown project, it is quite unlikely that FreeBSD would have gotten as far, as fast, as it has today.

The first CD-ROM (and general net-wide) distribution was FreeBSD 1.0, released in December of 1993. This was based on the 4.3BSD-Lite (Net/2) tape from U.C. Berkeley, with many components also provided by 386BSD and the Free Software Foundation. It was a fairly reasonable success for a first offering, and they followed it with the highly successful FreeBSD 1.1 release in May of 1994.

Around this time, some rather unexpected storm clouds formed on the horizon as Novell and U.C. Berkeley settled their long-running lawsuit over the legal status of the Berkeley Net/2 tape. A condition of that settlement was U.C. Berkeley's concession that large parts of Net/2 were encumbered code and the property of Novell, who had in turn acquired it from AT&T some time previously. What Berkeley got in return was Novell's blessing that the 4.4BSD-Lite release, when it was finally released, would be declared unencumbered and all existing Net/2 users would be strongly encouraged to switch. This included FreeBSD, and the project was given until the end of July 1994 to stop shipping its own Net/2 based product. Under the terms of that agreement, the project was allowed one last release before the deadline, that release being FreeBSD 1.1.5.1.

FreeBSD then set about the arduous task of literally re-inventing itself from a completely new and rather incomplete set of 4.4BSD-Lite bits. The Lite releases were light in part because Berkeley's CSRG had removed large chunks of code required for actually constructing a bootable running system (due to various legal requirements) and the fact that the Intel port of 4.4 was highly incomplete. It took the project until November of 1994 to make this transition, at which point it released FreeBSD 2.0 to the net and on CD-ROM (in late December). Despite being still more than a little rough around the edges, the release was a significant success and was followed by the more robust and easier to install FreeBSD 2.0.5 release in June of 1995.

Since that time, FreeBSD has made a series of releases each time improving the stability, speed, and feature set of the previous version.

For now, long-term development projects continue to take place in the 10.X-CURRENT (trunk) branch, and snapshot releases of 10.X are continually made available from the snapshot server as work progresses.

1.3.2. FreeBSD Project Goals

Contributed by Jordan Hubbard.

The goals of the FreeBSD Project are to provide software that may be used for any purpose and without strings attached. Many of us have a significant investment in the code (and project) and would certainly not mind a little financial compensation now and then, but we are definitely not prepared to insist on it. We believe that our first and foremost mission is to provide code to any and all comers, and for whatever purpose, so that the code gets the widest possible use and provides the widest possible benefit. This is, I believe, one of the most fundamental goals of Free Software and one that we enthusiastically support.

That code in our source tree which falls under the GNU General Public License (GPL) or Library General Public License (LGPL) comes with slightly more strings attached, though at least on the side of enforced access rather than the usual opposite. Due to the additional complexities that can evolve in the commercial use of GPL software we do, however, prefer software submitted under the more relaxed BSD copyright when it is a reasonable option to do so.

1.3.3. The FreeBSD Development Model

Contributed by Satoshi Asami.

The development of FreeBSD is a very open and flexible process, being literally built from the contributions of hundreds of people around the world, as can be seen from our list of contributors. FreeBSD's development infrastructure allow these hundreds of developers to collaborate over the Internet. We are constantly on the lookout for new developers and ideas, and those interested in becoming more closely involved with the project need simply contact us at the FreeBSD technical discussions mailing list. The FreeBSD announcements mailing list is also available to those wishing to make other FreeBSD users aware of major areas of work.

Useful things to know about the FreeBSD Project and its development process, whether working independently or in close cooperation:

The SVN repositories

For several years, the central source tree for FreeBSD was maintained by CVS (Concurrent Versions System), a freely available source code control tool that comes bundled with FreeBSD. In June 2008, the Project switched to using SVN (Subversion). The switch was deemed necessary, as the technical limitations imposed by CVS were becoming obvious due to the rapid expansion of the source tree and the amount of history already stored. The Documentation Project and Ports Collection repositories also moved from CVS to SVN in May 2012 and July 2012, respectively. Please refer to the Synchronizing your source tree section for more information on obtaining the FreeBSD src/ repository and Using the Ports Collection for details on obtaining the FreeBSD Ports Collection.

The committers list

The committers are the people who have write access to the Subversion tree, and are authorized to make modifications to the FreeBSD source (the term committer comes from the source control commit command, which is used to bring new changes into the repository). The best way of making submissions for review by the committers list is to use the send-pr(1) command. If something appears to be jammed in the system, then you may also reach them by sending mail to the FreeBSD committer's mailing list.

The FreeBSD core team

The FreeBSD core team would be equivalent to the board of directors if the FreeBSD Project were a company. The primary task of the core team is to make sure the project, as a whole, is in good shape and is heading in the right directions. Inviting dedicated and responsible developers to join our group of committers is one of the functions of the core team, as is the recruitment of new core team members as others move on. The current core team was elected from a pool of committer candidates in July 2012. Elections are held every 2 years.

Some core team members also have specific areas of responsibility, meaning that they are committed to ensuring that some large portion of the system works as advertised. For a complete list of FreeBSD developers and their areas of responsibility, please see the Contributors List

Note:

Most members of the core team are volunteers when it comes to FreeBSD development and do not benefit from the project financially, so commitment should also not be misconstrued as meaning guaranteed support. The board of directors analogy above is not very accurate, and it may be more suitable to say that these are the people who gave up their lives in favor of FreeBSD against their better judgement!

Outside contributors

Last, but definitely not least, the largest group of developers are the users themselves who provide feedback and bug fixes to us on an almost constant basis. The primary way of keeping in touch with FreeBSD's more non-centralized development is to subscribe to the FreeBSD technical discussions mailing list where such things are discussed. See Appendix C, Resources on the Internet for more information about the various FreeBSD mailing lists.

The FreeBSD Contributors List is a long and growing one, so why not join it by contributing something back to FreeBSD today?

Providing code is not the only way of contributing to the project; for a more complete list of things that need doing, please refer to the FreeBSD Project web site.

In summary, our development model is organized as a loose set of concentric circles. The centralized model is designed for the convenience of the users of FreeBSD, who are provided with an easy way of tracking one central code base, not to keep potential contributors out! Our desire is to present a stable operating system with a large set of coherent application programs that the users can easily install and use — this model works very well in accomplishing that.

All we ask of those who would join us as FreeBSD developers is some of the same dedication its current people have to its continued success!

1.3.4. Third Party Programs

In addition to the base distributions, FreeBSD offers a ported software collection with thousands of commonly sought-after programs. At the time of this writing, there were over 24,000 ports! The list of ports ranges from http servers, to games, languages, editors, and almost everything in between. The entire Ports Collection requires approximately 500 MB. To compile a port, you simply change to the directory of the program you wish to install, type make install, and let the system do the rest. The full original distribution for each port you build is retrieved dynamically so you need only enough disk space to build the ports you want. Almost every port is also provided as a pre-compiled package, which can be installed with a simple command (pkg_add) by those who do not wish to compile their own ports from source. More information on packages and ports can be found in Chapter 5, Installing Applications: Packages and Ports.

1.3.5. Additional Documentation

All recent FreeBSD versions provide an option in the installer (either sysinstall(8) or bsdinstall(8)) to install additional documentation under /usr/local/share/doc/freebsd during the initial system setup. Documentation may also be installed at any later time using packages as described in Section 24.4.6.2, “Using Documentation Packages”. You may view the locally installed manuals with any HTML capable browser using the following URLs:

You can also view the master (and most frequently updated) copies at http://www.FreeBSD.org/.

Chapter 2. Installing FreeBSD 9.X and Later

Restructured, reorganized, and parts rewritten by Jim Mock.
The sysinstall walkthrough, screenshots, and general copy by Randy Pratt.
Updated for bsdinstall by Gavin Atkinson and Warren Block.

2.1. Synopsis

FreeBSD comes with a text-based, easy to use installation program. FreeBSD 9.0-RELEASE and later use an installation program called bsdinstall, while releases prior to FreeBSD 9.0-RELEASE using sysinstall for installation. This chapter describes the use of bsdinstall. The use of sysinstall is covered in Chapter 3, Installing FreeBSD 8.X.

After reading this chapter, you will know:

  • How to create the FreeBSD installation media.

  • How FreeBSD subdivides and refers to hard disks.

  • How to start bsdinstall.

  • The questions bsdinstall will ask you, what they mean, and how to answer them.

Before reading this chapter, you should:

  • Read the supported hardware list that shipped with the version of FreeBSD you are installing, and verify that your hardware is supported.

Note:

In general, these installation instructions are written for i386™ (PC compatible) architecture computers. Where applicable, instructions specific to other platforms will be listed. There may be minor differences between the installer and what is shown here, so use this chapter as a general guide rather than as exact literal instructions.

2.2. Hardware Requirements

2.2.1. Minimal Configuration

The minimal configuration to install FreeBSD varies with the FreeBSD version and the hardware architecture.

A summary of this information is given in the following sections. Depending on the method you choose to install FreeBSD, you may also need a supported CDROM drive, and in some cases a network adapter. This will be covered by Section 2.3.5, “Prepare the Installation Media”.

2.2.1.1. FreeBSD/i386

FreeBSD/i386 requires a 486 or better processor and at least 64 MB of RAM. At least 1.1 GB of free hard drive space is needed for the most minimal installation.

Note:

On old computers, increasing RAM and hard drive space is usually more effective at improving performance than installing a faster processor.

2.2.1.2. FreeBSD/amd64

There are two classes of processors capable of running FreeBSD/amd64. The first are AMD64 processors, including the AMD Athlon™64, AMD Athlon™64-FX, AMD Opteron™ or better processors.

The second class of processors that can use FreeBSD/amd64 includes those using the Intel® EM64T architecture. Examples of these processors include the Intel® Core™ 2 Duo, Quad, Extreme processor families, the Intel® Xeon™ 3000, 5000, and 7000 sequences of processors, and the Intel® Core™ i3, i5 and i7 processors.

If you have a machine based on an nVidia nForce3 Pro-150, you must use the BIOS setup to disable the IO APIC. If you do not have an option to do this, you will likely have to disable ACPI instead. There are bugs in the Pro-150 chipset for which we have not yet found a workaround.

2.2.1.3. FreeBSD/powerpc Apple® Macintosh®

All New World Apple® Macintosh® systems with built-in USB are supported. SMP is supported on machines with multiple CPUs.

A 32-bit kernel can only use the first 2 GB of RAM. FireWire® is not supported on the Blue & White PowerMac G3.

2.2.1.4. FreeBSD/sparc64

Systems supported by FreeBSD/sparc64 are listed at the FreeBSD/sparc64 Project.

A dedicated disk is required for FreeBSD/sparc64. It is not possible to share a disk with another operating system at this time.

2.2.2. Supported Hardware

Hardware architectures and devices supported by a FreeBSD release are listed in the Hardware Notes file. Usually named HARDWARE.TXT, the file is located in the root directory of the release media. Copies of the supported hardware list are also available on the Release Information page of the FreeBSD web site.

2.3. Pre-Installation Tasks

2.3.1. Back Up Your Data

Back up all important data on the target computer where FreeBSD will be installed. Test the backups before continuing. The FreeBSD installer will ask before making changes to the disk, but once the process has started it cannot be undone.

2.3.2. Decide Where to Install FreeBSD

If FreeBSD will be the only operating system installed, and will be allowed to use the entire hard disk, the rest of this section can be skipped. But if FreeBSD will share the disk with other operating systems, an understanding of disk layout is useful during the installation.

2.3.2.1. Disk Layouts for FreeBSD/i386 and FreeBSD/amd64

Hard disks can be divided into multiple sections. These sections are called partitions.

There are two ways of dividing a disk into partitions. A traditional Master Boot Record (MBR) holds a partition table defining up to four primary partitions. (For historical reasons, FreeBSD calls primary partitions slices.) A limit of only four partitions is restrictive for large disks, so one of these primary partitions can be made into an extended partition. Multiple logical partitions may then be created inside the extended partition. This may sound a little unwieldy, and it is.

The GUID Partition Table (GPT) is a newer and simpler method of partitioning a disk. GPT is far more versatile than the traditional MBR partition table. Common GPT implementations allow up to 128 partitions per disk, eliminating the need for inconvenient workarounds like logical partitions.

Warning:

Some older operating systems like Windows® XP are not compatible with the GPT partition scheme. If FreeBSD will be sharing a disk with such an operating system, MBR partitioning is required.

FreeBSD's standard boot loader requires either a primary or GPT partition. (See Chapter 13, The FreeBSD Booting Process for more information about the FreeBSD booting process.) If all of the primary or GPT partitions are already in use, one must be freed for FreeBSD.

A minimal installation of FreeBSD takes as little as 1 GB of disk space. However, that is a very minimal install, leaving almost no free space. A more realistic minimum is 3 GB without a graphical environment, and 5 GB or more if a graphical user interface will be used. Third-party application software requires more space.

A variety of free and commercial partition resizing tools are available. GParted Live is a free Live CD which includes the GParted partition editor. GParted is also included with many other Linux Live CD distributions.

Warning:

Disk partition applications can destroy data. Make a full backup and verify its integrity before modifying disk partitions.

Resizing Microsoft® Vista partitions can be difficult. A Vista installation CDROM can be useful when attempting such an operation.

Example 2.1. Using an Existing Partition

A Windows® computer has a single 40 GB disk that has been split into two 20 GB partitions. Windows® calls them C: and D:. The C: partition contains 10 GB of data, and the D: partition contains 5 GB of data.

Moving the data from D: to C: frees up the second partition to be used for FreeBSD.


Example 2.2. Shrinking an Existing Partition

A Windows® computer has a single 40 GB disk and one large partition using the whole disk. Windows® shows this 40 GB partition as a single C:. 15 GB of space is being used. The goal is to end up with Windows® in a 20 GB partition, and have another 20 GB partition for FreeBSD.

There are two ways to do this:

  1. Back up your Windows® data. Then reinstall Windows®, creating a 20 GB partition during the install.

  2. Use a partition resizing tool like GParted to shrink the Windows® partition and create a new partition in the freed space for FreeBSD.


Disk partitions containing different operating systems make it possible to run any one of those operating systems at a time. An alternative method that allows running multiple operating systems at the same time is covered in Chapter 22, Virtualization.

2.3.3. Collect Network Information

Some FreeBSD installation methods need a network connection to download files. To connect to an Ethernet network (or cable or DSL modem with an Ethernet interface), the installer will request some information about the network.

DHCP is commonly used to provide automatic network configuration. If DHCP is not available, this network information must be obtained from the local network administrator or service provider:

Network Information
  1. IP address

  2. Subnet mask

  3. Default router IP address

  4. Domain name of the local network

  5. DNS server IP address(es)

2.3.4. Check for FreeBSD Errata

Although the FreeBSD Project strives to ensure that each release of FreeBSD is as stable as possible, bugs occasionally creep into the process. On very rare occasions those bugs affect the installation process. As these problems are discovered and fixed, they are noted in the FreeBSD Errata on the FreeBSD web site. Check the errata before installing to make sure that there are no problems that might affect the installation.

Information and errata for all the releases can be found on the release information section of the FreeBSD web site.

2.3.5. Prepare the Installation Media

A FreeBSD installation is started by booting the computer with a FreeBSD installation CD, DVD, or USB memory stick. The installer is not a program that can be run from within another operating system.

In addition to the standard installation media which contains copies of all the FreeBSD installation files, there is a bootonly variant. Bootonly install media does not have copies of the installation files, but downloads them from the network during an install. The bootonly install CD is consequently much smaller, and reduces bandwidth usage during the install by only downloading required files.

Copies of FreeBSD installation media are available at the FreeBSD web site.

Tip:

If you already have a copy of FreeBSD on CDROM, DVD, or USB memory stick, this section can be skipped.

FreeBSD CD and DVD images are bootable ISO files. Only one CD or DVD is needed for an install. Burn the ISO image to a bootable CD or DVD using the CD recording applications available with your current operating system.

To create a bootable memory stick, follow these steps:

  1. Acquire the Memory Stick Image

    Memory stick images for FreeBSD 9.0-RELEASE and later can be downloaded from the ISO-IMAGES/ directory at ftp://ftp.FreeBSD.org/pub/FreeBSD/releases/arch/arch/ISO-IMAGES/version/FreeBSD-version-RELEASE-arch-memstick.img. Replace arch and version with the architecture and the version number which you want to install, respectively. For example, the memory stick images for FreeBSD/i386 9.0-RELEASE are available from ftp://ftp.FreeBSD.org/pub/FreeBSD/releases/i386/i386/ISO-IMAGES/9.0/FreeBSD-9.0-RELEASE-i386-memstick.img.

    Tip:

    A different directory path is used for FreeBSD 8.X and earlier versions. Details of download and installation of FreeBSD 8.X and earlier is covered in Chapter 3, Installing FreeBSD 8.X.

    The memory stick image has a .img extension. The ISO-IMAGES/ directory contains a number of different images, and the one needed depends on the version of FreeBSD being installed, and in some cases, the target hardware.

    Important:

    Before proceeding, back up the data on the USB stick, as this procedure will erase it.

  2. Write the Image File to the Memory Stick

    Procedure 2.1. Using FreeBSD to Write the Image

    Warning:

    The example below shows /dev/da0 as the target device where the image will be written. Be very careful that the correct device is used as the output target, or you may destroy existing data.

    • Writing the Image with dd(1)

      The .img file is not a regular file. It is an image of the complete contents of the memory stick. It cannot simply be copied like a regular file, but must be written directly to the target device with dd(1):

      # dd if=FreeBSD-9.0-RELEASE-i386-memstick.img of=/dev/da0 bs=64k
    Procedure 2.2. Using Windows® to Write the Image

    Warning:

    Be sure to give the correct drive letter as the output target, or you may overwrite and destroy existing data.

    1. Obtaining Image Writer for Windows®

      Image Writer for Windows® is a free application that can correctly write an image file to a memory stick. Download it from https://launchpad.net/win32-image-writer/ and extract it into a folder.

    2. Writing the Image with Image Writer

      Double-click the Win32DiskImager icon to start the program. Verify that the drive letter shown under Device is the drive with the memory stick. Click the folder icon and select the image to be written to the memory stick. Click [ Save ] to accept the image file name. Verify that everything is correct, and that no folders on the memory stick are open in other windows. When everything is ready, click [ Write ] to write the image file to the memory stick.

Note:

Installation from floppy disks is no longer supported.

You are now ready to start installing FreeBSD.

2.4. Starting the Installation

Important:

By default, the installation will not make any changes to your disk(s) until you see the following message:

Your changes will now be written to disk.  If you
have chosen to overwrite existing data, it will
be PERMANENTLY ERASED. Are you sure you want to
commit your changes?

The install can be exited at any time prior to this warning without changing the contents of the hard drive. If you are concerned that you have configured something incorrectly you can just turn the computer off before this point, and no damage will be done.

2.4.1. Booting

2.4.1.1. Booting on i386™ and amd64

  1. If you prepared a bootable USB stick, as described in Section 2.3.5, “Prepare the Installation Media”, then plug in your USB stick before turning on the computer.

    If you are booting from CDROM, then you will need to turn on the computer, and insert the CDROM at the first opportunity.

  2. Configure your machine to boot from either the CDROM or from USB, depending on the media being used for the installation. BIOS configurations allow the selection of a specific boot device. Most systems also provide for selecting a boot device during startup, typically by pressing F10, F11, F12, or Escape.

  3. If your computer starts up as normal and loads your existing operating system, then either:

    1. The disks were not inserted early enough in the boot process. Leave them in, and try restarting your computer.

    2. The BIOS changes earlier did not work correctly. You should redo that step until you get the right option.

    3. Your particular BIOS does not support booting from the desired media. The Plop Boot Manager can be used to boot older computers from CD or USB media.

  4. FreeBSD will start to boot. If you are booting from CDROM you will see a display similar to this (version information omitted):

    Booting from CD-ROM... 645MB medium detected CD Loader 1.2 Building the boot loader arguments Looking up /BOOT/LOADER... Found Relocating the loader and the BTX Starting the BTX loader BTX loader 1.00 BTX version is 1.02 Consoles: internal video/keyboard BIOS CD is cd0 BIOS drive C: is disk0 BIOS drive D: is disk1 BIOS 636kB/261056kB available memory FreeBSD/i386 bootstrap loader, Revision 1.1 Loading /boot/defaults/loader.conf /boot/kernel/kernel text=0x64daa0 data=0xa4e80+0xa9e40 syms=[0x4+0x6cac0+0x4+0x88e9d] \
  5. The FreeBSD boot loader is displayed:

    Figure 2.1. FreeBSD Boot Loader Menu
    FreeBSD Boot Loader Menu

    Either wait ten seconds, or press Enter.

2.4.1.2. Booting for Macintosh® PowerPC®

On most machines, holding C on the keyboard during boot will boot from the CD. Otherwise, hold Command+Option+O+F, or Windows+Alt+O+F on non-Apple® keyboards. At the 0 > prompt, enter

boot cd:,\ppc\loader cd:0

For Xserves without keyboards, see Apple®'s support web site about booting into Open Firmware.

2.4.1.3. Booting for SPARC64®

Most SPARC64® systems are set up to boot automatically from disk. To install FreeBSD, you need to boot over the network or from a CDROM, which requires you to break into the PROM (OpenFirmware).

To do this, reboot the system, and wait until the boot message appears. It depends on the model, but should look about like:

Sun Blade 100 (UltraSPARC-IIe), Keyboard Present Copyright 1998-2001 Sun Microsystems, Inc. All rights reserved. OpenBoot 4.2, 128 MB memory installed, Serial #51090132. Ethernet address 0:3:ba:b:92:d4, Host ID: 830b92d4.

If your system proceeds to boot from disk at this point, you need to press L1+A or Stop+A on the keyboard, or send a BREAK over the serial console (using for example ~# in tip(1) or cu(1)) to get to the PROM prompt. It looks like this:

ok 1 ok {0} 2

1

This is the prompt used on systems with just one CPU.

2

This is the prompt used on SMP systems, the digit indicates the number of the active CPU.

At this point, place the CDROM into your drive, and from the PROM prompt, type boot cdrom.

2.4.2. Reviewing the Device Probe Results

The last few hundred lines that have been displayed on screen are stored and can be reviewed.

To review the buffer, press Scroll Lock. This turns on scrolling in the display. You can then use the arrow keys, or PageUp and PageDown to view the results. Press Scroll Lock again to stop scrolling.

Do this now, to review the text that scrolled off the screen when the kernel was carrying out the device probes. You will see text similar to Figure 2.2, “Typical Device Probe Results”, although the precise text will differ depending on the devices that you have in your computer.

Figure 2.2. Typical Device Probe Results
Copyright (c) 1992-2011 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD is a registered trademark of The FreeBSD Foundation. FreeBSD 9.0-RELEASE #0 r225473M: Sun Sep 11 16:07:30 BST 2011 root@psi:/usr/obj/usr/src/sys/GENERIC amd64 CPU: Intel(R) Core(TM)2 Duo CPU T9400 @ 2.53GHz (2527.05-MHz K8-class CPU) Origin = "GenuineIntel" Id = 0x10676 Family = 6 Model = 17 Stepping = 6 Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE> Features2=0x8e3fd<SSE3,DTES64,MON,DS_CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1> AMD Features=0x20100800<SYSCALL,NX,LM> AMD Features2=0x1<LAHF> TSC: P-state invariant, performance statistics real memory = 3221225472 (3072 MB) avail memory = 2926649344 (2791 MB) Event timer "LAPIC" quality 400 ACPI APIC Table: <TOSHIB A0064 > FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs FreeBSD/SMP: 1 package(s) x 2 core(s) cpu0 (BSP): APIC ID: 0 cpu1 (AP): APIC ID: 1 ioapic0: Changing APIC ID to 1 ioapic0 <Version 2.0> irqs 0-23 on motherboard kbd1 at kbdmux0 acpi0: <TOSHIB A0064> on motherboard acpi0: Power Button (fixed) acpi0: reservation of 0, a0000 (3) failed acpi0: reservation of 100000, b6690000 (3) failed Timecounter "ACPI-safe" frequency 3579545 Hz quality 850 acpi_timer0: <24-bit timer at 3.579545MHz> port 0xd808-0xd80b on acpi0 cpu0: <ACPI CPU> on acpi0 ACPI Warning: Incorrect checksum in table [ASF!] - 0xFE, should be 0x9A (20110527/tbutils-282) cpu1: <ACPI CPU> on acpi0 pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0 pci0: <ACPI PCI bus> on pcib0 vgapci0: <VGA-compatible display> port 0xcff8-0xcfff mem 0xff400000-0xff7fffff,0xe0000000-0xefffffff irq 16 at device 2.0 on pci0 agp0: <Intel GM45 SVGA controller> on vgapci0 agp0: aperture size is 256M, detected 131068k stolen memory vgapci1: <VGA-compatible display> mem 0xffc00000-0xffcfffff at device 2.1 on pci0 pci0: <simple comms> at device 3.0 (no driver attached) em0: <Intel(R) PRO/1000 Network Connection 7.2.3> port 0xcf80-0xcf9f mem 0xff9c0000-0xff9dffff,0xff9fe000-0xff9fefff irq 20 at device 25.0 on pci0 em0: Using an MSI interrupt em0: Ethernet address: 00:1c:7e:6a:ca:b0 uhci0: <Intel 82801I (ICH9) USB controller> port 0xcf60-0xcf7f irq 16 at device 26.0 on pci0 usbus0: <Intel 82801I (ICH9) USB controller> on uhci0 uhci1: <Intel 82801I (ICH9) USB controller> port 0xcf40-0xcf5f irq 21 at device 26.1 on pci0 usbus1: <Intel 82801I (ICH9) USB controller> on uhci1 uhci2: <Intel 82801I (ICH9) USB controller> port 0xcf20-0xcf3f irq 19 at device 26.2 on pci0 usbus2: <Intel 82801I (ICH9) USB controller> on uhci2 ehci0: <Intel 82801I (ICH9) USB 2.0 controller> mem 0xff9ff800-0xff9ffbff irq 19 at device 26.7 on pci0 usbus3: EHCI version 1.0 usbus3: <Intel 82801I (ICH9) USB 2.0 controller> on ehci0 hdac0: <Intel 82801I High Definition Audio Controller> mem 0xff9f8000-0xff9fbfff irq 22 at device 27.0 on pci0 pcib1: <ACPI PCI-PCI bridge> irq 17 at device 28.0 on pci0 pci1: <ACPI PCI bus> on pcib1 iwn0: <Intel(R) WiFi Link 5100> mem 0xff8fe000-0xff8fffff irq 16 at device 0.0 on pci1 pcib2: <ACPI PCI-PCI bridge> irq 16 at device 28.1 on pci0 pci2: <ACPI PCI bus> on pcib2 pcib3: <ACPI PCI-PCI bridge> irq 18 at device 28.2 on pci0 pci4: <ACPI PCI bus> on pcib3 pcib4: <ACPI PCI-PCI bridge> at device 30.0 on pci0 pci5: <ACPI PCI bus> on pcib4 cbb0: <RF5C476 PCI-CardBus Bridge> at device 11.0 on pci5 cardbus0: <CardBus bus> on cbb0 pccard0: <16-bit PCCard bus> on cbb0 isab0: <PCI-ISA bridge> at device 31.0 on pci0 isa0: <ISA bus> on isab0 ahci0: <Intel ICH9M AHCI SATA controller> port 0x8f58-0x8f5f,0x8f54-0x8f57,0x8f48-0x8f4f,0x8f44-0x8f47,0x8f20-0x8f3f mem 0xff9fd800-0xff9fdfff irq 19 at device 31.2 on pci0 ahci0: AHCI v1.20 with 4 3Gbps ports, Port Multiplier not supported ahcich0: <AHCI channel> at channel 0 on ahci0 ahcich1: <AHCI channel> at channel 1 on ahci0 ahcich2: <AHCI channel> at channel 4 on ahci0 acpi_lid0: <Control Method Lid Switch> on acpi0 battery0: <ACPI Control Method Battery> on acpi0 acpi_button0: <Power Button> on acpi0 acpi_acad0: <AC Adapter> on acpi0 acpi_toshiba0: <Toshiba HCI Extras> on acpi0 acpi_tz0: <Thermal Zone> on acpi0 attimer0: <AT timer> port 0x40-0x43 irq 0 on acpi0 Timecounter "i8254" frequency 1193182 Hz quality 0 Event timer "i8254" frequency 1193182 Hz quality 100 atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0 atkbd0: <AT Keyboard> irq 1 on atkbdc0 kbd0 at atkbd0 atkbd0: [GIANT-LOCKED] psm0: <PS/2 Mouse> irq 12 on atkbdc0 psm0: [GIANT-LOCKED] psm0: model GlidePoint, device ID 0 atrtc0: <AT realtime clock> port 0x70-0x71 irq 8 on acpi0 Event timer "RTC" frequency 32768 Hz quality 0 hpet0: <High Precision Event Timer> iomem 0xfed00000-0xfed003ff on acpi0 Timecounter "HPET" frequency 14318180 Hz quality 950 Event timer "HPET" frequency 14318180 Hz quality 450 Event timer "HPET1" frequency 14318180 Hz quality 440 Event timer "HPET2" frequency 14318180 Hz quality 440 Event timer "HPET3" frequency 14318180 Hz quality 440 uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0 sc0: <System console> at flags 0x100 on isa0 sc0: VGA <16 virtual consoles, flags=0x300> vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0 ppc0: cannot reserve I/O port range est0: <Enhanced SpeedStep Frequency Control> on cpu0 p4tcc0: <CPU Frequency Thermal Control> on cpu0 est1: <Enhanced SpeedStep Frequency Control> on cpu1 p4tcc1: <CPU Frequency Thermal Control> on cpu1 Timecounters tick every 1.000 msec hdac0: HDA Codec #0: Realtek ALC268 hdac0: HDA Codec #1: Lucent/Agere Systems (Unknown) pcm0: <HDA Realtek ALC268 PCM #0 Analog> at cad 0 nid 1 on hdac0 pcm1: <HDA Realtek ALC268 PCM #1 Analog> at cad 0 nid 1 on hdac0 usbus0: 12Mbps Full Speed USB v1.0 usbus1: 12Mbps Full Speed USB v1.0 usbus2: 12Mbps Full Speed USB v1.0 usbus3: 480Mbps High Speed USB v2.0 ugen0.1: <Intel> at usbus0 uhub0: <Intel UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus0 ugen1.1: <Intel> at usbus1 uhub1: <Intel UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus1 ugen2.1: <Intel> at usbus2 uhub2: <Intel UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus2 ugen3.1: <Intel> at usbus3 uhub3: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus3 uhub0: 2 ports with 2 removable, self powered uhub1: 2 ports with 2 removable, self powered uhub2: 2 ports with 2 removable, self powered uhub3: 6 ports with 6 removable, self powered ugen2.2: <vendor 0x0b97> at usbus2 uhub8: <vendor 0x0b97 product 0x7761, class 9/0, rev 1.10/1.10, addr 2> on usbus2 ugen1.2: <Microsoft> at usbus1 ada0 at ahcich0 bus 0 scbus1 target 0 lun 0 ada0: <Hitachi HTS543225L9SA00 FBEOC43C> ATA-8 SATA 1.x device ada0: 150.000MB/s transfers (SATA 1.x, UDMA6, PIO 8192bytes) ada0: Command Queueing enabled ada0: 238475MB (488397168 512 byte sectors: 16H 63S/T 16383C) ada0: Previously was known as ad4 ums0: <Microsoft Microsoft 3-Button Mouse with IntelliEyeTM, class 0/0, rev 1.10/3.00, addr 2> on usbus1 SMP: AP CPU #1 Launched! cd0 at ahcich1 bus 0 scbus2 target 0 lun 0 cd0: <TEAC DV-W28S-RT 7.0C> Removable CD-ROM SCSI-0 device cd0: 150.000MB/s transfers (SATA 1.x, ums0: 3 buttons and [XYZ] coordinates ID=0 UDMA2, ATAPI 12bytes, PIO 8192bytes) cd0: cd present [1 x 2048 byte records] ugen0.2: <Microsoft> at usbus0 ukbd0: <Microsoft Natural Ergonomic Keyboard 4000, class 0/0, rev 2.00/1.73, addr 2> on usbus0 kbd2 at ukbd0 uhid0: <Microsoft Natural Ergonomic Keyboard 4000, class 0/0, rev 2.00/1.73, addr 2> on usbus0 Trying to mount root from cd9660:/dev/iso9660/FREEBSD_INSTALL [ro]...

Check the probe results carefully to make sure that FreeBSD found all the devices you expected. If a device was not found, then it will not be listed. Kernel modules allows you to add in support for devices which are not in the GENERIC kernel.

After the procedure of device probing, you will see Figure 2.3, “Selecting Installation Media Mode”. The install media can be used in three ways: to install FreeBSD, as a live CD, or to simply access a FreeBSD shell. Use the arrow keys to choose an option, and Enter to select.

Figure 2.3. Selecting Installation Media Mode
Selecting Installation Media Mode

Selecting [ Install ] here will enter the installer.

2.5. Introducing bsdinstall

bsdinstall is a text-based FreeBSD installer program written by Nathan Whitehorn and introduced in 2011 for FreeBSD 9.0.

Note:

Kris Moore 's pc-sysinstall is included with PC-BSD, and can also be used to install FreeBSD. Although sometimes confused with bsdinstall, the two are not related.

The bsdinstall menu system is controlled by the arrow keys, Enter, Tab, Space, and other keys.

2.5.1. Selecting the Keymap Menu

Depending on the system console being used, bsdinstall may initially prompt to select a non-default keyboard layout.

Figure 2.4. Keymap Selection
Keymap Selection

If [ YES ] is selected, the following keyboard selection screen will be displayed. Otherwise, this selection menu will not be displayed, and a default keyboard mapping will be used.

Figure 2.5. Selecting Keyboard Menu
Selecting Keyboard Menu

Select the keymap that most closely represents the mapping of the keyboard attached to the system, using the up/down arrow keys and pressing Enter.

Note:

Pressing Esc will use the default keymap. United States of America ISO-8859-1 is also a safe option if the choice of keymap is not clear.

2.5.2. Setting the Hostname

Next, bsdinstall will prompt for the hostname to be given to the newly installed system.

Figure 2.6. Setting the Hostname
Setting the Hostname

The entered hostname should be a fully-qualified hostname, such as machine3.example.com

2.5.3. Selecting Components to Install

Next, bsdinstall will prompt to select optional components to install.

Figure 2.7. Selecting Components to Install
Selecting Components to Install

Deciding which components to install will depend largely on the intended use of the system and the amount of disk space available. The FreeBSD Kernel and userland (collectively the base system) are always installed.

Depending on the type of installation, some of these components may not appear.

Optional Components
  • doc - Additional documentation, mostly of historical interest. Documentation provided by the FreeBSD Documentation Project may be installed later.

  • games - Several traditional BSD games, including fortune, rot13, and others.

  • lib32 - Compatibility libraries for running 32-bit applications on a 64-bit version of FreeBSD.

  • ports - The FreeBSD Ports Collection.

    The ports collection is an easy and convenient way to install software. The Ports Collection does not contain the source code necessary to compile the software. Instead, it is a collection of files which automates the downloading, compiling and installation of third-party software packages. Chapter 5, Installing Applications: Packages and Ports discusses how to use the ports collection.

    Warning:

    The installation program does not check to see if you have adequate space. Select this option only if you have adequate hard disk space. As of FreeBSD 9.0, the FreeBSD Ports Collection takes up about 500 MB of disk space. You can safely assume a larger value for more recent versions of FreeBSD.

  • src - System source code.

    FreeBSD comes with full source code for both the kernel and the userland. Although not required for the majority of applications, it may be required to build certain software supplied as source (for example, device drivers or kernel modules), or for developing FreeBSD itself.

    The full source tree requires 1 GB of disk space, and recompiling the entire FreeBSD system requires an additional 5 GB of space.

2.6. Installing from the Network

The bootonly installation media does not hold copies of the installation files. When a bootonly installation method is used, the files must be retrieved over a network connection as they are needed.

Figure 2.8. Installing from the Network
Installing from the Network

After the network connection has been configured as shown in Section 2.9.2, “Configuring Network Interfaces”, a mirror site is selected. Mirror sites cache copies of the FreeBSD files. Choose a mirror site located in the same region of the world as the computer on which FreeBSD is being installed. Files can be retrieved more quickly when the mirror is close to the target computer, and installation time will be reduced.

Figure 2.9. Choosing a Mirror
Choosing a Mirror

Installation will continue as if the installation files were located on local media.

2.7. Allocating Disk Space

There are three ways to allocate disk space for FreeBSD. Guided partitioning automatically sets up disk partitions, while Manual partitioning allows advanced users to create customized partitions. Finally, there's the option of starting a shell where command-line programs like gpart(8), fdisk(8), and bsdlabel(8) can be used directly.

Figure 2.10. Selecting Guided or Manual Partitioning
Selecting Guided or Manual Partitioning

2.7.1. Guided Partitioning

If multiple disks are connected, choose the one where FreeBSD is to be installed.

Figure 2.11. Selecting from Multiple Disks
Selecting from Multiple Disks

The entire disk can be allocated to FreeBSD, or just a portion of it. If [ Entire Disk ] is chosen, a general partition layout filling the whole disk is created. Selecting [ Partition ] creates a partition layout in unused space on the disk.

Figure 2.12. Selecting Entire Disk or Partition
Selecting Entire Disk or Partition

After the partition layout has been created, review it carefully for accuracy. If a mistake has been made, selecting [ Revert ] will reset the partitions as they were previously, or [ Auto ] will recreate the automatic FreeBSD partitions. Partitions can be manually created, modified, or deleted. When the partitioning is correct, select [ Finish ] to continue with the installation.

Figure 2.13. Review Created Partitions
Review Created Partitions

2.7.2. Manual Partitioning

Manual partitioning goes straight to the partition editor.

Figure 2.14. Manually Create Partitions
Manually Create Partitions

Highlighting a drive (ada0 in this example) and selecting [ Create ] displays a menu for choosing the type of partitioning scheme.

Figure 2.15. Manually Create Partitions
Manually Create Partitions

GPT partitioning is usually the most appropriate choice for PC-compatible computers. Older PC operating systems that are not compatible with GPT may require MBR partitioning instead. The other partitioning schemes are generally used for uncommon or older computer systems.

Table 2.1. Partitioning Schemes
AbbreviationDescription
APMApple Partition Map, used by PowerPC® Macintosh®.
BSDBSD Labels without an MBR, sometimes called "dangerously dedicated mode". See bsdlabel(8).
GPTGUID Partition Table.
MBRMaster Boot Record.
PC98MBR variant, used by NEC PC-98 computers.
VTOC8Volume Table Of Contents, used by Sun SPARC64 and UltraSPARC computers.

After the partitioning scheme has been selected and created, selecting [ Create ] again will create new partitions.

Figure 2.16. Manually Create Partitions
Manually Create Partitions

A standard FreeBSD GPT installation uses at least three partitions:

Standard FreeBSD GPT Partitions
  • freebsd-boot - FreeBSD boot code.

  • freebsd-ufs - A FreeBSD UFS filesystem.

  • freebsd-swap - FreeBSD swap space.

Another partition type worth noting is freebsd-zfs, used for partitions that will contain a FreeBSD ZFS filesystem. See Section 21.2, “The Z File System (ZFS)”. gpart(8) shows more of the available GPT partition types.

Multiple filesystem partitions can be used, and some people may prefer a traditional layout with separate partitions for the /, /var, /tmp, and /usr filesystems. See Example 2.3, “Creating Traditional Split Filesystem Partitions” for an example.

Size may be entered with common abbreviations: K for kilobytes, M for megabytes, or G for gigabytes.

Tip:

Proper sector alignment provides the best performance, and making partition sizes even multiples of 4K bytes helps to ensure alignment on drives with either 512-byte or 4K-byte sectors. Generally, using partition sizes that are even multiples of 1M or 1G is the easiest way to make sure every partition starts at an even multiple of 4K. One exception: at present, the freebsd-boot partition should be no larger than 512K due to boot code limitations.

A mountpoint is needed if this partition will contain a filesystem. If only a single UFS partition will be created, the mountpoint should be /.

A label is also requested. A label is a name by which this partition will be known. Drive names or numbers can change if the drive is connected to a different controller or port, but the partition label does not change. Referring to labels instead of drive names and partition numbers in files like /etc/fstab makes the system more tolerant of changing hardware. GPT labels appear in /dev/gpt/ when a disk is attached. Other partitioning schemes have different label capabilities, and their labels appear in different directories in /dev/.

Tip:

Use a unique label on every filesystem to avoid conflicts from identical labels. A few letters from the computer's name, use, or location can be added to the label. "labroot" or "rootfs-lab" for the UFS root partition on the lab's computer, for example.

Example 2.3. Creating Traditional Split Filesystem Partitions

For a traditional partition layout where the /, /var, /tmp, and /usr directories are separate filesystems on their own partitions, create a GPT partitioning scheme, then create the partitions as shown. Partition sizes shown are typical for a 20G target disk. If more space is available on the target disk, larger swap or /var partitions may be useful. Labels shown here are prefixed with ex for "example", but readers should use other unique label values as described above.

By default, FreeBSD's gptboot expects the first UFS partition found to be the / partition.

Partition TypeSizeMountpointLabel
freebsd-boot512K  
freebsd-ufs2G/exrootfs
freebsd-swap4G exswap
freebsd-ufs2G/varexvarfs
freebsd-ufs1G/tmpextmpfs
freebsd-ufsaccept the default (remainder of the disk)/usrexusrfs

After the custom partitions have been created, select [ Finish ] to continue with the installation.

2.8. Committing to the Installation

This is the last chance for aborting the installation to prevent changes to the hard drive.

Figure 2.17. Final Confirmation
Final Confirmation

Select [ Commit ] and press Enter to proceed. If changes need to be made, select [ Back ] to return to the partition editor. [ Revert & Exit ] will exit the installer without making any changes to the hard drive.

Installation time will vary depending on the distributions chosen, installation media, and speed of the computer. There will be a series of messages displayed indicating progress.

Firstly, the installer will write the partitions to the disk, and perform a newfs to initialise the partitions.

If doing a network install, bsdinstall will then proceed to download the required distribution files.

Figure 2.18. Fetching Distribution Files
Fetching Distribution Files

Next, the integrity of the distribution files is verified, to ensure they have not been corrupted during download or misread from the installation media.

Figure 2.19. Verifying Distribution Files
Verifying Distribution Files

Finally, the verified distribution files are extracted to the disk.

Figure 2.20. Extracting Distribution Files
Extracting Distribution Files

Once all requested distribution files have been extracted, bsdinstall will then drop straight into the post-installation configuration tasks (see Section 2.9, “Post-Installation”).

2.9. Post-Installation

Configuration of various options follows a successful installation of FreeBSD. An option can be configured by re-entering the configuration options from the final menu before booting into the newly installed FreeBSD system.

2.9.1. Setting the root Password

The root password must be set. Note that while entering the password, the characters being typed are not displayed on the screen. After the password has been entered, it must be entered again. This helps prevent typing errors.

Figure 2.21. Setting the root Password
Setting the root Password

After the password has been successfully entered, the installation will continue.

2.9.2. Configuring Network Interfaces

Note:

Network configuration will be skipped if it has already been done as part of a bootonly installation.

A list of all the network interfaces found on the computer is shown next. Select one to be configured.

Figure 2.22. Choose a Network Interface
Choose a Network Interface

2.9.2.1. Configuring a Wireless Network Interface

If a wireless network interface is chosen, wireless identification and security parameters must be entered to allow it to connect to the network.

Wireless networks are identified by a Service Set Identifier, or SSID. The SSID is a short, unique name given to each network.

Most wireless networks encrypt transmitted data to protect information from unauthorized viewing. WPA2 encryption is strongly recommended. Older encryption types, like WEP, offer very little security.

The first step in connecting to a wireless network is to scan for wireless access points.

Figure 2.23. Scanning for Wireless Access Points
Scanning for Wireless Access Points

SSIDs found during the scan are listed, followed by a description of the encryption types available for that network. If the desired SSID does not appear in the list, select [ Rescan ] to scan again. If the desired network still does not appear, check for problems with antenna connections or try moving the computer closer to the access point. Rescan after each change is made.

Figure 2.24. Choosing a Wireless Network
Choosing a Wireless Network

The encryption information for connecting to the selected wireless network is entered after selecting the network. With WPA2, only a password (also known as the Pre-Shared Key, or PSK) is needed. Characters typed into the input box are shown as asterisks for security.

Figure 2.25. WPA2 Setup
WPA2 Setup

Network configuration continues after selection of the wireless network and entry of the connection information.

2.9.2.2. Configuring IPv4 Networking

Choose whether IPv4 networking is to be used. This is the most common type of network connection.

Figure 2.26. Choose IPv4 Networking
Choose IPv4 Networking

There are two methods of IPv4 configuration. DHCP will automatically configure the network interface correctly, and is the preferred method. Static configuration requires manual entry of network information.

Note:

Do not enter random network information, as it will not work. Obtain the information shown in Section 2.3.3, “Collect Network Information” from the network administrator or service provider.

2.9.2.2.1. IPv4 DHCP Network Configuration

If a DHCP server is available, select [ Yes ] to automatically configure the network interface.

Figure 2.27. Choose IPv4 DHCP Configuration
Choose IPv4 DHCP Configuration

2.9.2.2.2. IPv4 Static Network Configuration

Static configuration of the network interface requires entry of some IPv4 information.

Figure 2.28. IPv4 Static Configuration
IPv4 Static Configuration

  • IP Address - The manually-assigned IPv4 address to be assigned to this computer. This address must be unique and not already in use by another piece of equipment on the local network.

  • Subnet Mask - The subnet mask used for the local network. Typically, this is 255.255.255.0.

  • Default Router - The IP address of the default router on this network. Usually this is the address of the router or other network equipment that connects the local network to the Internet. Also known as the default gateway.

2.9.2.3. Configuring IPv6 Networking

IPv6 is a newer method of network configuration. If IPv6 is available and desired, choose [ Yes ] to select it.

Figure 2.29. Choose IPv6 Networking
Choose IPv6 Networking

IPv6 also has two methods of configuration. SLAAC , or StateLess Address AutoConfiguration, will automatically configure the network interface correctly. Static configuration requires manual entry of network information.

2.9.2.3.1. IPv6 Stateless Address Autoconfiguration

SLAAC allows an IPv6 network component to request autoconfiguration information from a local router. See RFC4862 for more information.

Figure 2.30. Choose IPv6 SLAAC Configuration
Choose IPv6 SLAAC Configuration

2.9.2.3.2. IPv6 Static Network Configuration

Static configuration of the network interface requires entry of the IPv6 configuration information.

Figure 2.31. IPv6 Static Configuration
IPv6 Static Configuration

  • IPv6 Address - The manually-assigned IP address to be assigned to this computer. This address must be unique and not already in use by another piece of equipment on the local network.

  • Default Router - The IPv6 address of the default router on this network. Usually this is the address of the router or other network equipment that connects the local network to the Internet. Also known as the default gateway.

2.9.2.4. Configuring DNS

The Domain Name System (or DNS) Resolver converts hostnames to and from network addresses. If DHCP or SLAAC was used to autoconfigure the network interface, the Resolver Configuration values may already be present. Otherwise, enter the local network's domain name in the Search field. DNS #1 and DNS #2 are the IP addresses for the local DNS servers. At least one DNS server is required.

Figure 2.32. DNS Configuration
DNS Configuration

2.9.3. Setting the Time Zone

Setting the time zone for your machine will allow it to automatically correct for any regional time changes and perform other time zone related functions properly.

The example shown is for a machine located in the Eastern time zone of the United States. Your selections will vary according to your geographical location.

Figure 2.33. Select Local or UTC Clock
Select Local or UTC Clock

Select [ Yes ] or [ No ] according to how the machine's clock is configured and press Enter. If you do not know whether the system uses UTC or local time, select [ No ] to choose the more commonly-used local time.

Figure 2.34. Select a Region
Select a Region

The appropriate region is selected using the arrow keys and then pressing Enter.

Figure 2.35. Select a Country
Select a Country

Select the appropriate country using the arrow keys and press Enter.

Figure 2.36. Select a Time Zone
Select a Time Zone

The appropriate time zone is selected using the arrow keys and pressing Enter.

Figure 2.37. Confirm Time Zone
Confirm Time Zone

Confirm the abbreviation for the time zone is correct. If it looks okay, press Enter to continue with the post-installation configuration.

2.9.4. Selecting Services to Enable

Additional system services which will be started at boot can be enabled. All of these services are optional.

Figure 2.38. Selecting Additional Services to Enable
Selecting Additional Services to Enable

Additional Services
  • sshd - Secure Shell (SSH) daemon for secure remote access.

  • moused - Provides mouse usage within the system console.

  • ntpd - Network Time Protocol (NTP) daemon for automatic clock synchronization.

  • powerd - System power control utility for power control and energy saving.

2.9.5. Enabling Crash Dumps

bsdinstall will prompt if crash dumps should be enabled on the target system. Enabling crash dumps can be very useful in debugging issues with the system, so users are encouraged to enable crash dumps whenever possible. Select [ Yes ] to enable crash dumps, or [ No ] to proceed without crash dumps enabled.

Figure 2.39. Enabling Crash Dumps
Enabling Crash Dumps

2.9.6. Add Users

Adding at least one user during the installation allows the system to be used without being logged in as root. When logged in as root, there are essentially no limits or protection on what can be done. Logging in as a normal user is safer and more secure.

Select [ Yes ] to add new users.

Figure 2.40. Add User Accounts
Add User Accounts

Enter the information for the user to be added.

Figure 2.41. Enter User Information
Enter User Information

User Information
  • Username - The name the user will enter to log in. Typically the first letter of their first name combined with their last name.

  • Full name - The user's full name.

  • Uid - User ID. Typically, this is left blank so the system will assign a value.

  • Login group - The user's group. Typically left blank to accept the default.

  • Invite user into other groups? - Additional groups to which the user will be added as a member.

  • Login class - Typically left blank for the default.

  • Shell - The interactive shell for this user. In the example, csh(1) has been chosen.

  • Home directory - The user's home directory. The default is usually correct.

  • Home directory permissions - Permissions on the user's home directory. The default is usually correct.

  • Use password-based authentication? - Typically "yes".

  • Use an empty password? - Typically "no".

  • Use a random password? - Typically "no".

  • Enter password - The actual password for this user. Characters typed will not show on the screen.

  • Enter password again - The password must be typed again for verification.

  • Lock out the account after creation? - Typically "no".

After entering everything, a summary is shown, and the system asks if it is correct. If a mistake was made during entry, enter no and try again. If everything is correct, enter yes to create the new user.

Figure 2.42. Exit User and Group Management
Exit User and Group Management

If there are more users to add, answer the "Add another user?" question with yes. Enter no to finish adding users and continue the installation.

For more information on adding users and user management, see Chapter 14, Users and Basic Account Management.

2.9.7. Final Configuration

After everything has been installed and configured, a final chance is provided to modify settings.

Figure 2.43. Final Configuration
Final Configuration

Use this menu to make any changes or do any additional configuration before completing the installation.

Final Configuration Options

After any final configuration is complete, select Exit to leave the installation.

Figure 2.44. Manual Configuration
Manual Configuration

bsdinstall will prompt if there are any additional configuration that needs to be done before rebooting into the new system. Select [ Yes ] to exit to a shell within the new system, or [ No ] to proceed to the last step of the installation.

Figure 2.45. Complete the Installation
Complete the Installation

If further configuration or special setup is needed, selecting [ Live CD ] will boot the install media into Live CD mode.

When the installation is complete, select [ Reboot ] to reboot the computer and start the new FreeBSD system. Do not forget to remove the FreeBSD install CD, DVD, or USB memory stick, or the computer may boot from it again.

2.9.8. FreeBSD Booting and Shutdown

2.9.8.1. FreeBSD/i386 Booting

As FreeBSD boots, many informational messages are displayed. Most will scroll off the screen; this is normal. After the system finishes booting, a login prompt is displayed. Messages that scrolled off the screen can be reviewed by pressing Scroll-Lock to turn on the scroll-back buffer. The PgUp, PgDn, and arrow keys can be used to scroll back through the messages. Pressing Scroll-Lock again unlocks the display and returns to the normal screen.

At the login: prompt, enter the username added during the installation, asample in the example. Avoid logging in as root except when necessary.

The scroll-back buffer examined above is limited in size, so not all of the messages may have been visible. After logging in, most of them can be seen from the command line by typing dmesg | less at the prompt. Press q to return to the command line after viewing.

Typical boot messages (version information omitted):

Copyright (c) 1992-2011 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD is a registered trademark of The FreeBSD Foundation. root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64 CPU: Intel(R) Core(TM)2 Duo CPU E8400 @ 3.00GHz (3007.77-MHz K8-class CPU) Origin = "GenuineIntel" Id = 0x10676 Family = 6 Model = 17 Stepping = 6 Features=0x783fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE,SSE2> Features2=0x209<SSE3,MON,SSSE3> AMD Features=0x20100800<SYSCALL,NX,LM> AMD Features2=0x1<LAHF> real memory = 536805376 (511 MB) avail memory = 491819008 (469 MB) Event timer "LAPIC" quality 400 ACPI APIC Table: <VBOX VBOXAPIC> ioapic0: Changing APIC ID to 1 ioapic0 <Version 1.1> irqs 0-23 on motherboard kbd1 at kbdmux0 acpi0: <VBOX VBOXXSDT> on motherboard acpi0: Power Button (fixed) acpi0: Sleep Button (fixed) Timecounter "ACPI-fast" frequency 3579545 Hz quality 900 acpi_timer0: <32-bit timer at 3.579545MHz> port 0x4008-0x400b on acpi0 cpu0: <ACPI CPU> on acpi0 pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0 pci0: <ACPI PCI bus> on pcib0 isab0: <PCI-ISA bridge> at device 1.0 on pci0 isa0: <ISA bus> on isab0 atapci0: <Intel PIIX4 UDMA33 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0xd000-0xd00f at device 1.1 on pci0 ata0: <ATA channel 0> on atapci0 ata1: <ATA channel 1> on atapci0 vgapci0: <VGA-compatible display> mem 0xe0000000-0xe0ffffff irq 18 at device 2.0 on pci0 em0: <Intel(R) PRO/1000 Legacy Network Connection 1.0.3> port 0xd010-0xd017 mem 0xf0000000-0xf001ffff irq 19 at device 3.0 on pci0 em0: Ethernet address: 08:00:27:9f:e0:92 pci0: <base peripheral> at device 4.0 (no driver attached) pcm0: <Intel ICH (82801AA)> port 0xd100-0xd1ff,0xd200-0xd23f irq 21 at device 5.0 on pci0 pcm0: <SigmaTel STAC9700/83/84 AC97 Codec> ohci0: <OHCI (generic) USB controller> mem 0xf0804000-0xf0804fff irq 22 at device 6.0 on pci0 usbus0: <OHCI (generic) USB controller> on ohci0 pci0: <bridge> at device 7.0 (no driver attached) acpi_acad0: <AC Adapter> on acpi0 atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0 atkbd0: <AT Keyboard> irq 1 on atkbdc0 kbd0 at atkbd0 atkbd0: [GIANT-LOCKED] psm0: <PS/2 Mouse> irq 12 on atkbdc0 psm0: [GIANT-LOCKED] psm0: model IntelliMouse Explorer, device ID 4 attimer0: <AT timer> port 0x40-0x43,0x50-0x53 on acpi0 Timecounter "i8254" frequency 1193182 Hz quality 0 Event timer "i8254" frequency 1193182 Hz quality 100 sc0: <System console> at flags 0x100 on isa0 sc0: VGA <16 virtual consoles, flags=0x300> vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0 atrtc0: <AT realtime clock> at port 0x70 irq 8 on isa0 Event timer "RTC" frequency 32768 Hz quality 0 ppc0: cannot reserve I/O port range Timecounters tick every 10.000 msec pcm0: measured ac97 link rate at 485193 Hz em0: link state changed to UP usbus0: 12Mbps Full Speed USB v1.0 ugen0.1: <Apple> at usbus0 uhub0: <Apple OHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus0 cd0 at ata1 bus 0 scbus1 target 0 lun 0 cd0: <VBOX CD-ROM 1.0> Removable CD-ROM SCSI-0 device cd0: 33.300MB/s transfers (UDMA2, ATAPI 12bytes, PIO 65534bytes) cd0: Attempt to query device size failed: NOT READY, Medium not present ada0 at ata0 bus 0 scbus0 target 0 lun 0 ada0: <VBOX HARDDISK 1.0> ATA-6 device ada0: 33.300MB/s transfers (UDMA2, PIO 65536bytes) ada0: 12546MB (25694208 512 byte sectors: 16H 63S/T 16383C) ada0: Previously was known as ad0 Timecounter "TSC" frequency 3007772192 Hz quality 800 Root mount waiting for: usbus0 uhub0: 8 ports with 8 removable, self powered Trying to mount root from ufs:/dev/ada0p2 [rw]... Setting hostuuid: 1848d7bf-e6a4-4ed4-b782-bd3f1685d551. Setting hostid: 0xa03479b2. Entropy harvesting: interrupts ethernet point_to_point kickstart. Starting file system checks: /dev/ada0p2: FILE SYSTEM CLEAN; SKIPPING CHECKS /dev/ada0p2: clean, 2620402 free (714 frags, 327461 blocks, 0.0% fragmentation) Mounting local file systems:. vboxguest0 port 0xd020-0xd03f mem 0xf0400000-0xf07fffff,0xf0800000-0xf0803fff irq 20 at device 4.0 on pci0 vboxguest: loaded successfully Setting hostname: machine3.example.com. Starting Network: lo0 em0. lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384 options=3<RXCSUM,TXCSUM> inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3 inet 127.0.0.1 netmask 0xff000000 nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL> em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM> ether 08:00:27:9f:e0:92 nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL> media: Ethernet autoselect (1000baseT <full-duplex>) status: active Starting devd. Starting Network: usbus0. DHCPREQUEST on em0 to 255.255.255.255 port 67 DHCPACK from 10.0.2.2 bound to 192.168.1.142 -- renewal in 43200 seconds. add net ::ffff:0.0.0.0: gateway ::1 add net ::0.0.0.0: gateway ::1 add net fe80::: gateway ::1 add net ff02::: gateway ::1 ELF ldconfig path: /lib /usr/lib /usr/lib/compat /usr/local/lib 32-bit compatibility ldconfig path: /usr/lib32 Creating and/or trimming log files. Starting syslogd. No core dumps found. Clearing /tmp (X related). Updating motd:. Configuring syscons: blanktime. Generating public/private rsa1 key pair. Your identification has been saved in /etc/ssh/ssh_host_key. Your public key has been saved in /etc/ssh/ssh_host_key.pub. The key fingerprint is: 10:a0:f5:af:93:ae:a3:1a:b2:bb:3c:35:d9:5a:b3:f3 root@machine3.example.com The key's randomart image is: +--[RSA1 1024]----+ | o.. | | o . . | | . o | | o | | o S | | + + o | |o . + * | |o+ ..+ . | |==o..o+E | +-----------------+ Generating public/private dsa key pair. Your identification has been saved in /etc/ssh/ssh_host_dsa_key. Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub. The key fingerprint is: 7e:1c:ce:dc:8a:3a:18:13:5b:34:b5:cf:d9:d1:47:b2 root@machine3.example.com The key's randomart image is: +--[ DSA 1024]----+ | .. . .| | o . . + | | . .. . E .| | . . o o . . | | + S = . | | + . = o | | + . * . | | . . o . | | .o. . | +-----------------+ Starting sshd. Starting cron. Starting background file system checks in 60 seconds. Thu Oct 6 19:15:31 MDT 2011 FreeBSD/amd64 (machine3.example.com) (ttyv0) login:

Generating the RSA and DSA keys may take some time on slower machines. This happens only on the initial boot-up of a new installation, and only if sshd is set to start automatically. Subsequent boots will be faster.

FreeBSD does not install graphical environments by default, but many are available. See Chapter 6, The X Window System for more information.

2.9.9. FreeBSD Shutdown

Proper shutdown of a FreeBSD computer helps protect data and even hardware from damage. Do not just turn off the power. If the user is a member of the wheel group, become the superuser by typing su at the command line and entering the root password. Otherwise, log in as root and use shutdown -p now. The system will close down cleanly and turn itself off.

The Ctrl+Alt+Del key combination can be used to reboot the system, but is not recommended during normal operation.

2.10. Troubleshooting

The following section covers basic installation troubleshooting, such as common problems people have reported.

2.10.1. What to Do If Something Goes Wrong

Due to various limitations of the PC architecture, it is impossible for probing to be 100% reliable, however, there are a few things you can do if it fails.

Check the Hardware Notes document for your version of FreeBSD to make sure your hardware is supported.

If your hardware is supported and you still experience lock-ups or other problems, you will need to build a custom kernel. This will allow you to add in support for devices which are not present in the GENERIC kernel. The kernel on the boot disks 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 edit the kernel configuration and recompile to tell FreeBSD where to find things.

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.

Note:

Some installation problems can be avoided or alleviated by updating the firmware on various hardware components, most notably the motherboard. Motherboard firmware is usually referred to as the BIOS. Most motherboard and computer manufacturers have a website for upgrades and upgrade information.

Manufacturers generally advise against upgrading the motherboard BIOS unless there is a good reason for doing so, like a critical update. The upgrade process can go wrong, leaving the BIOS incomplete and the computer inoperative.

2.10.2. Troubleshooting Questions and Answers

2.10.2.1. My system hangs while probing hardware during boot, or it behaves strangely during install.

2.10.2.1.

My system hangs while probing hardware during boot, or it behaves strangely during install.

FreeBSD makes extensive use of the system ACPI service on the i386, amd64, and ia64 platforms to aid in system configuration if it is detected during boot. Unfortunately, some bugs still exist in both the ACPI driver and within system motherboards and BIOS firmware. ACPI can be disabled by setting the hint.acpi.0.disabled hint in the third stage boot loader:

set hint.acpi.0.disabled="1"

This is reset each time the system is booted, so it is necessary to add hint.acpi.0.disabled="1" to the file /boot/loader.conf. More information about the boot loader can be found in Section 13.1, “Synopsis”.

2.11. Using the Live CD

A live CD of FreeBSD is available on the same CD as the main installation program. This is useful for those who are still wondering whether FreeBSD is the right operating system for them and want to test some of the features before installing.

Note:

The following points should be noted while using the live CD:

  • To gain access to the system, authentication is required. The username is root, and the password is blank.

  • As the system runs directly from the CD, performance will be significantly slower than that of a system installed on a hard disk.

  • The live CD provides a command prompt and not a graphical interface.

Chapter 3. Installing FreeBSD 8.X

Restructured, reorganized, and parts rewritten by Jim Mock.
The sysinstall walkthrough, screenshots, and general copy by Randy Pratt.

3.1. Synopsis

FreeBSD provides a text-based, easy to use installation program. FreeBSD 9.0-RELEASE and later use the installation program known as bsdinstall(8) while FreeBSD 8.X uses sysinstall(8). This chapter describes how to use sysinstall(8). The use of bsdinstall(8) is covered in Chapter 2, Installing FreeBSD 9.X and Later.

After reading this chapter, you will know:

  • How to create the FreeBSD installation media.

  • How FreeBSD refers to and subdivides hard disks.

  • How to start sysinstall(8).

  • The questions sysinstall(8) asks, what they mean, and how to answer them.

Before reading this chapter, you should:

  • Read the supported hardware list that shipped with the version of FreeBSD to install, and verify that the system's hardware is supported.

Note:

In general, these installation instructions are written for the i386™ and FreeBSD/amd64 architectures. Where applicable, instructions specific to other platforms will be listed. There may be minor differences between the installer and what is shown here. This chapter should be used as a general guide rather than a literal installation manual.

3.2. Hardware Requirements

3.2.1. Minimal Configuration

The minimal configuration to install FreeBSD varies with the FreeBSD version and the hardware architecture.

A summary of this information is given in the following sections. Depending on the method chosen to install FreeBSD, a floppy drive, CDROM drive, or network adapter may be needed. Instructions on how to prepare the installation media can be found in Section 3.3.7, “Prepare the Boot Media”.

3.2.1.1. FreeBSD/i386 and FreeBSD/pc98

Both FreeBSD/i386 and FreeBSD/pc98 require a 486 or better processor, at least 24 MB of RAM, and at least 150 MB of free hard drive space for the most minimal installation.

Note:

In the case of older hardware, installing more RAM and more hard drive space is often more important than a faster processor.

3.2.1.2. FreeBSD/amd64

There are two classes of processors capable of running FreeBSD/amd64. The first are AMD64 processors, including the AMD Athlon™64, AMD Athlon™64-FX, and AMD Opteron™ or better processors.

The second class of processors includes those using the Intel® EM64T architecture. Examples of these processors include the Intel® Core™ 2 Duo, Quad, Extreme processor families, and the Intel® Xeon™ 3000, 5000, and 7000 sequences of processors.

If the machine is based on an nVidia nForce3 Pro-150, the BIOS setup must be used to disable the IO APIC. If this option does not exist, disable ACPI instead as there are bugs in the Pro-150 chipset.

3.2.1.3. FreeBSD/sparc64

To install FreeBSD/sparc64, use a supported platform (see Section 3.2.2, “Supported Hardware”).

A dedicated disk is needed for FreeBSD/sparc64 as it is not possible to share a disk with another operating system at this time.

3.2.2. Supported Hardware

A list of supported hardware is provided with each FreeBSD release in the FreeBSD Hardware Notes. This document can usually be found in a file named HARDWARE.TXT, in the top-level directory of a CDROM or FTP distribution, or in sysinstall(8)'s documentation menu. It lists, for a given architecture, which hardware devices are known to be supported by each release of FreeBSD. Copies of the supported hardware list for various releases and architectures can also be found on the Release Information page of the FreeBSD website.

3.3. Pre-installation Tasks

3.3.1. Inventory the Computer

Before installing FreeBSD it is recommended to inventory the components in the computer. The FreeBSD installation routines will show components such as hard disks, network cards, and CDROM drives with their model number and manufacturer. FreeBSD will also attempt to determine the correct configuration for these devices, including information about IRQ and I/O port usage. Due to the vagaries of computer hardware, this process is not always completely successful, and FreeBSD may need some manual configuration.

If another operating system is already installed, use the facilities provided by that operating systems to view the hardware configuration. If the settings of an expansion card are not obvious, check if they are printed on the card itself. Popular IRQ numbers are 3, 5, and 7, and I/O port addresses are normally written as hexadecimal numbers, such as 0x330.

It is recommended to print or write down this information before installing FreeBSD. It may help to use a table, as seen in this example:

Table 3.1. Sample Device Inventory
Device NameIRQI/O port(s)Notes
First hard diskN/AN/A40 GB, made by Seagate, first IDE master
CDROMN/AN/AFirst IDE slave
Second hard diskN/AN/A20 GB, made by IBM, second IDE master
First IDE controller140x1f0 
Network cardN/AN/AIntel® 10/100
ModemN/AN/A3Com® 56K faxmodem, on COM1
   

Once the inventory of the components in the computer is complete, check if it matches the hardware requirements of the FreeBSD release to install.

3.3.2. Make a Backup

If the computer contains valuable data, ensure it is backed up, and that the backup has been tested before installing FreeBSD. The FreeBSD installer will prompt before writing any data to disk, but once that process has started, it cannot be undone.

3.3.3. Decide Where to Install FreeBSD

If FreeBSD is to be installed on the entire hard disk, skip this section.

However, if FreeBSD will co-exist with other operating systems, a rough understanding of how data is laid out on the disk is useful.

3.3.3.1. Disk Layouts for FreeBSD/i386

A PC disk can be divided into discrete chunks known as partitions. Since FreeBSD also has partitions, naming can quickly become confusing. Therefore, these disk chunks are referred to as slices in FreeBSD. For example, the FreeBSD version of fdisk(8) refers to slices instead of partitions. By design, the PC only supports four partitions per disk. These partitions are called primary partitions. To work around this limitation and allow more than four partitions, a new partition type was created, the extended partition. A disk may contain only one extended partition. Special partitions, called logical partitions, can be created inside this extended partition.

Each partition has a partition ID, which is a number used to identify the type of data on the partition. FreeBSD partitions have the partition ID of 165.

In general, each operating system will identify partitions in a particular way. For example, Windows®, assigns each primary and logical partition a drive letter, starting with C:.

FreeBSD must be installed into a primary partition. If there are multiple disks, a FreeBSD partition can be created on all, or some, of them. When FreeBSD is installed, at least one partition must be available. This might be a blank partition or it might be an existing partition whose data can be overwritten.

If all the partitions on all the disks are in use, free one of them for FreeBSD using the tools provided by an existing operating system, such as Windows® fdisk.

If there is a spare partition, use that. If it is too small, shrink one or more existing partitions to create more available space.

A minimal installation of FreeBSD takes as little as 100 MB of disk space. However, that is a very minimal install, leaving almost no space for files. A more realistic minimum is 250 MB without a graphical environment, and 350 MB or more for a graphical user interface. If other third-party software will be installed, even more space is needed.

You can use a tool such as GParted to resize your partitions and make space for FreeBSD. GParted is known to work on NTFS and is available on a number of Live CD Linux distributions, such as SystemRescueCD.

Warning:

Incorrect use of a shrinking tool can delete the data on the disk. Always have a recent, working backup before using this type of tool.

Example 3.1. Using an Existing Partition Unchanged

Consider a computer with a single 4 GB disk that already has a version of Windows® installed, where the disk has been split into two drive letters, C: and D:, each of which is 2 GB in size. There is 1 GB of data on C:, and 0.5 GB of data on D:.

This disk has two partitions, one per drive letter. Copy all existing data from D: to C:, which will free up the second partition, ready for FreeBSD.


Example 3.2. Shrinking an Existing Partition

Consider a computer with a single 4 GB disk that already has a version of Windows® installed. When Windows® was installed, it created one large partition, a C: drive that is 4 GB in size. Currently, 1.5 GB of space is used, and FreeBSD should have 2 GB of space.

In order to install FreeBSD, either:

  1. Backup the Windows® data and then reinstall Windows®, asking for a 2 GB partition at install time.

  2. Use one of the tools described above to shrink your Windows® partition.


3.3.4. Collect the Network Configuration Details

Before installing from an FTP site or an NFS server, make note of the network configuration. The installer will prompt for this information so that it can connect to the network to complete the installation.

3.3.4.1. Connecting to an Ethernet Network or Cable/DSL Modem

If using an Ethernet network or an Internet connection using an Ethernet adapter via cable or DSL, the following information is needed:

  1. IP address

  2. IP address of the default gateway

  3. Hostname

  4. DNS server IP addresses

  5. Subnet Mask

If this information is unknown, ask the system administrator or service provider. Make note if this information is assigned automatically using DHCP.

3.3.4.2. Connecting Using a Modem

If using a dialup modem, FreeBSD can still be installed over the Internet, it will just take a very long time.

You will need to know:

  1. The phone number to dial the Internet Service Provider (ISP)

  2. The COM: port the modem is connected to

  3. The username and password for the ISP account

3.3.5. Check for FreeBSD Errata

Although the FreeBSD Project strives to ensure that each release of FreeBSD is as stable as possible, bugs do occasionally creep into the process. On rare occasions those bugs affect the installation process. As these problems are discovered and fixed, they are noted in the FreeBSD Errata, which is found on the FreeBSD website. Check the errata before installing to make sure that there are no late-breaking problems to be aware of.

Information about all releases, including the errata for each release, can be found on the release information section of the FreeBSD website.

3.3.6. Obtain the FreeBSD Installation Files

The FreeBSD installer can install FreeBSD from files located in any of the following places:

Local Media
  • A CDROM or DVD

  • A USB Memory Stick

  • A MS-DOS® partition on the same computer

  • Floppy disks (FreeBSD/pc98 only)

Network
  • An FTP site through a firewall or using an HTTP proxy

  • An NFS server

  • A dedicated parallel or serial connection

If installing from a purchased FreeBSD CD/DVD, skip ahead to Section 3.3.7, “Prepare the Boot Media”.

To obtain the FreeBSD installation files, skip ahead to Section 3.13, “Preparing Custom Installation Media” which explains how to prepare the installation media. After reading that section, come back here and read on to Section 3.3.7, “Prepare the Boot Media”.

3.3.7. Prepare the Boot Media

The FreeBSD installation process is started by booting the computer into the FreeBSD installer. It is not a program that can be run within another operating system. The computer normally boots using the operating system installed on the hard disk, but it can also be configured to boot from a CDROM or from a USB disk.

Tip:

If installing from a CD/DVD to a computer whose BIOS supports booting from the CD/DVD, skip this section. The FreeBSD CD/DVD images are bootable and can be used to install FreeBSD without any other special preparation.

To create a bootable memory stick, follow these steps:

  1. Acquire the Memory Stick Image

    Memory stick images for FreeBSD 8.X can be downloaded from the ISO-IMAGES/ directory at ftp://ftp.FreeBSD.org/pub/FreeBSD/releases/arch/ISO-IMAGES/version/FreeBSD-version-RELEASE-arch-memstick.img. Replace arch and version with the architecture and the version number to install. For example, the memory stick images for FreeBSD/i386 8.4-RELEASE are available from ftp://ftp.FreeBSD.org/pub/FreeBSD/releases/i386/ISO-IMAGES/8.4/FreeBSD-8.4-RELEASE-i386-memstick.img.

    Tip:

    A different directory path is used for FreeBSD 9.0-RELEASE and later versions. How to download and install FreeBSD 9.X is covered in Chapter 2, Installing FreeBSD 9.X and Later.

    The memory stick image has a .img extension. The ISO-IMAGES/ directory contains a number of different images and the one to use depends on the version of FreeBSD and the type of media supported by the hardware being installed to.

    Important:

    Before proceeding, back up the data on the USB stick, as this procedure will erase it.

  2. Write the Image File to the Memory Stick

    Procedure 3.1. Using FreeBSD to Write the Image

    Warning:

    The example below lists /dev/da0 as the target device where the image will be written. Be very careful that you have the correct device as the output target, or you may destroy your existing data.

    • Writing the Image with dd(1)

      The .img file is not a regular file that can just be copied to the memory stick. It is an image of the complete contents of the disk. This means that dd(1) must be used to write the image directly to the disk:

      # dd if=FreeBSD-8.4-RELEASE-i386-memstick.img of=/dev/da0 bs=64k

      If an Operation not permitted error is displayed, make certain that the target device is not in use, mounted, or being automounted by another program. Then try again.

    Procedure 3.2. Using Windows® to Write the Image

    Warning:

    Make sure to use the correct drive letter as the output target, as this command will overwrite and destroy any existing data on the specified device.

    1. Obtaining Image Writer for Windows

      Image Writer for Windows is a free application that can correctly write an image file to a memory stick. Download it from https://launchpad.net/win32-image-writer/ and extract it into a folder.

    2. Writing the Image with Image Writer

      Double-click the Win32DiskImager icon to start the program. Verify that the drive letter shown under Device is the drive with the memory stick. Click the folder icon and select the image to be written to the memory stick. Click Save to accept the image file name. Verify that everything is correct, and that no folders on the memory stick are open in other windows. Finally, click Write to write the image file to the drive.

To create the boot floppy images for a FreeBSD/pc98 installation, follow these steps:

  1. Acquire the Boot Floppy Images

    The FreeBSD/pc98 boot disks can be downloaded from the floppies directory, ftp://ftp.FreeBSD.org/pub/FreeBSD/releases/pc98/version-RELEASE/floppies/. Replace version with the version number to install.

    The floppy images have a .flp extension. floppies/ contains a number of different images. Download boot.flp as well as the number of files associated with the type of installation, such as kern.small* or kern*.

    Important:

    The FTP program must use binary mode to download these disk images. Some web browsers use text or ASCII mode, which will be apparent if the disks are not bootable.

  2. Prepare the Floppy Disks

    Prepare one floppy disk per downloaded image file. It is imperative that these disks are free from defects. The easiest way to test this is to reformat the disks. Do not trust pre-formatted floppies. The format utility in Windows® will not tell about the presence of bad blocks, it simply marks them as bad and ignores them. It is advised to use brand new floppies.

    Important:

    If the installer crashes, freezes, or otherwise misbehaves, one of the first things to suspect is the floppies. Write the floppy image files to new disks and try again.

  3. Write the Image Files to the Floppy Disks

    The .flp files are not regular files that can be copied to the disk. They are images of the complete contents of the disk. Specific tools must be used to write the images directly to the disk.

    FreeBSD provides a tool called rawrite for creating the floppies on a computer running Windows®. This tool can be downloaded from ftp://ftp.FreeBSD.org/pub/FreeBSD/releases/pc98/ version-RELEASE/tools/ on the FreeBSD FTP site. Download this tool, insert a floppy, then specify the filename to write to the floppy drive:

    C:\> rawrite boot.flp A:

    Repeat this command for each .flp file, replacing the floppy disk each time, being sure to label the disks with the name of the file. Adjust the command line as necessary, depending on where the .flp files are located.

    When writing the floppies on a UNIX®-like system, such as another FreeBSD system, use dd(1) to write the image files directly to disk. On FreeBSD, run:

    # dd if=boot.flp of=/dev/fd0

    On FreeBSD, /dev/fd0 refers to the first floppy disk. Other UNIX® variants might have different names for the floppy disk device, so check the documentation for the system as necessary.

You are now ready to start installing FreeBSD.

3.4. Starting the Installation

Important:

By default, the installer will not make any changes to the disk(s) until after the following message:

Last Chance: Are you SURE you want continue the installation?

If you're running this on a disk with data you wish to save then WE
STRONGLY ENCOURAGE YOU TO MAKE PROPER BACKUPS before proceeding!

We can take no responsibility for lost disk contents!

The install can be exited at any time prior to this final warning without changing the contents of the hard drive. If there is a concern that something is configured incorrectly, turn the computer off before this point, and no damage will be done.

3.4.1. Booting

3.4.1.1. Booting for the i386

  1. Turn on the computer. As it starts it should display an option to enter the system set up menu, or BIOS, commonly reached by keys like F2, F10, Del, or Alt+S. Use whichever keystroke is indicated on screen. In some cases the computer may display a graphic while it starts. Typically, pressing Esc will dismiss the graphic and display the boot messages.

  2. Find the setting that controls which devices the system boots from. This is usually labeled as the Boot Order and commonly shown as a list of devices, such as Floppy, CDROM, First Hard Disk, and so on.

    If booting from the CD/DVD, make sure that the CDROM drive is selected. If booting from a USB disk, make sure that it is selected instead. When in doubt, consult the manual that came with the computer or its motherboard.

    Make the change, then save and exit. The computer should now restart.

  3. If using a prepared a bootable USB stick, as described in Section 3.3.7, “Prepare the Boot Media”, plug in the USB stick before turning on the computer.

    If booting from CD/DVD, turn on the computer, and insert the CD/DVD at the first opportunity.

    Note:

    For FreeBSD/pc98, installation boot floppies are available and can be prepared as described in Section 3.3.7, “Prepare the Boot Media”. The first floppy disc will contain boot.flp. Put this floppy in the floppy drive to boot into the installer.

    If the computer starts up as normal and loads the existing operating system, then either:

    1. The disks were not inserted early enough in the boot process. Leave them in, and try restarting the computer.

    2. The BIOS changes did not work correctly. Redo that step until the right option is selected.

    3. That particular BIOS does not support booting from the desired media.

  4. FreeBSD will start to boot. If booting from CD/DVD, messages will be displayed, similar to these:

    Booting from CD-Rom... 645MB medium detected CD Loader 1.2 Building the boot loader arguments Looking up /BOOT/LOADER... Found Relocating the loader and the BTX Starting the BTX loader BTX loader 1.00 BTX version is 1.02 Consoles: internal video/keyboard BIOS CD is cd0 BIOS drive C: is disk0 BIOS drive D: is disk1 BIOS 636kB/261056kB available memory FreeBSD/i386 bootstrap loader, Revision 1.1 Loading /boot/defaults/loader.conf /boot/kernel/kernel text=0x64daa0 data=0xa4e80+0xa9e40 syms=[0x4+0x6cac0+0x4+0x88e9d] \

    If booting from floppy disc, a display similar to this will be shown:

    Booting from Floppy... Uncompressing ... done BTX loader 1.00 BTX version is 1.01 Console: internal video/keyboard BIOS drive A: is disk0 BIOS drive C: is disk1 BIOS 639kB/261120kB available memory FreeBSD/i386 bootstrap loader, Revision 1.1 Loading /boot/defaults/loader.conf /kernel text=0x277391 data=0x3268c+0x332a8 | Insert disk labelled "Kernel floppy 1" and press any key...

    Remove the boot.flp floppy, insert the next floppy, and press Enter. When prompted, insert the other disks as required.

  5. The boot process will then display the FreeBSD boot loader menu:

    Figure 3.1. FreeBSD Boot Loader Menu
    FreeBSD Boot Loader Menu

    Either wait ten seconds, or press Enter.

3.4.1.2. Booting for SPARC64®

Most SPARC64® systems are set to boot automatically from disk. To install FreeBSD, boot over the network or from a CD/DVD and wait until the boot message appears. The message depends on the model, but should look similar to:

Sun Blade 100 (UltraSPARC-IIe), Keyboard Present Copyright 1998-2001 Sun Microsystems, Inc. All rights reserved. OpenBoot 4.2, 128 MB memory installed, Serial #51090132. Ethernet address 0:3:ba:b:92:d4, Host ID: 830b92d4.

If the system proceeds to boot from disk, press L1+A or Stop+A on the keyboard, or send a BREAK over the serial console using ~# in tip(1) or cu(1) to get to the PROM prompt. It looks like this:

ok 1 ok {0} 2

1

This is the prompt used on systems with just one CPU.

2

This is the prompt used on SMP systems and the digit indicates the number of the active CPU.

At this point, place the CD/DVD into the drive and from the PROM prompt, type boot cdrom.

3.4.2. Reviewing the Device Probe Results

The last few hundred lines that have been displayed on screen are stored and can be reviewed.

To review this buffer, press Scroll Lock to turn on scrolling in the display. Use the arrow keys or PageUp and PageDown to view the results. Press Scroll Lock again to stop scrolling.

Do this now, to review the text that scrolled off the screen when the kernel was carrying out the device probes. Text similar to Figure 3.2, “Typical Device Probe Results” will be displayed, although it will differ depending on the devices in the computer.

Figure 3.2. Typical Device Probe Results
avail memory = 253050880 (247120K bytes) Preloaded elf kernel "kernel" at 0xc0817000. Preloaded mfs_root "/mfsroot" at 0xc0817084. md0: Preloaded image </mfsroot> 4423680 bytes at 0xc03ddcd4 md1: Malloc disk Using $PIR table, 4 entries at 0xc00fde60 npx0: <math processor> on motherboard npx0: INT 16 interface pcib0: <Host to PCI bridge> on motherboard pci0: <PCI bus> on pcib0 pcib1:<VIA 82C598MVP (Apollo MVP3) PCI-PCI (AGP) bridge> at device 1.0 on pci0 pci1: <PCI bus> on pcib1 pci1: <Matrox MGA G200 AGP graphics accelerator> at 0.0 irq 11 isab0: <VIA 82C586 PCI-ISA bridge> at device 7.0 on pci0 isa0: <iSA bus> on isab0 atapci0: <VIA 82C586 ATA33 controller> port 0xe000-0xe00f at device 7.1 on pci0 ata0: at 0x1f0 irq 14 on atapci0 ata1: at 0x170 irq 15 on atapci0 uhci0 <VIA 83C572 USB controller> port 0xe400-0xe41f irq 10 at device 7.2 on pci 0 usb0: <VIA 83572 USB controller> on uhci0 usb0: USB revision 1.0 uhub0: VIA UHCI root hub, class 9/0, rev 1.00/1.00, addr1 uhub0: 2 ports with 2 removable, self powered pci0: <unknown card> (vendor=0x1106, dev=0x3040) at 7.3 dc0: <ADMtek AN985 10/100BaseTX> port 0xe800-0xe8ff mem 0xdb000000-0xeb0003ff ir q 11 at device 8.0 on pci0 dc0: Ethernet address: 00:04:5a:74:6b:b5 miibus0: <MII bus> on dc0 ukphy0: <Generic IEEE 802.3u media interface> on miibus0 ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto ed0: <NE2000 PCI Ethernet (RealTek 8029)> port 0xec00-0xec1f irq 9 at device 10. 0 on pci0 ed0 address 52:54:05:de:73:1b, type NE2000 (16 bit) isa0: too many dependant configs (8) isa0: unexpected small tag 14 orm0: <Option ROM> at iomem 0xc0000-0xc7fff on isa0 fdc0: <NEC 72065B or clone> at port 0x3f0-0x3f5,0x3f7 irq 6 drq2 on isa0 fdc0: FIFO enabled, 8 bytes threshold fd0: <1440-KB 3.5” drive> on fdc0 drive 0 atkbdc0: <Keyboard controller (i8042)> at port 0x60,0x64 on isa0 atkbd0: <AT Keyboard> flags 0x1 irq1 on atkbdc0 kbd0 at atkbd0 psm0: <PS/2 Mouse> irq 12 on atkbdc0 psm0: model Generic PS/@ mouse, device ID 0 vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0 sc0: <System console> at flags 0x100 on isa0 sc0: VGA <16 virtual consoles, flags=0x300> sio0 at port 0x3f8-0x3ff irq 4 flags 0x10 on isa0 sio0: type 16550A sio1 at port 0x2f8-0x2ff irq 3 on isa0 sio1: type 16550A ppc0: <Parallel port> at port 0x378-0x37f irq 7 on isa0 pppc0: SMC-like chipset (ECP/EPP/PS2/NIBBLE) in COMPATIBLE mode ppc0: FIFO with 16/16/15 bytes threshold plip0: <PLIP network interface> on ppbus0 ad0: 8063MB <IBM-DHEA-38451> [16383/16/63] at ata0-master UDMA33 acd0: CD-RW <LITE-ON LTR-1210B> at ata1-slave PIO4 Mounting root from ufs:/dev/md0c /stand/sysinstall running as init on vty0

Check the probe results carefully to make sure that FreeBSD found all the devices. If a device was not found, it will not be listed. A custom kernel can be used to add in support for devices which are not in the GENERIC kernel.

After the device probe, the menu shown in Figure 3.3, “Selecting Country Menu” will be displayed. Use the arrow key to choose a country, region, or group. Then press Enter to set the country.

Figure 3.3. Selecting Country Menu
Selecting Country Menu

If United States is selected as the country, the standard American keyboard map will be used. If a different country is chosen, the following menu will be displayed. Use the arrow keys to choose the correct keyboard map and press Enter.

Figure 3.4. Selecting Keyboard Menu
Selecting Keyboard Menu

After the country selection, the sysinstall(8) main menu will display.

3.5. Introducing sysinstall(8)

The FreeBSD 8.X installer, sysinstall(8), is console based and is divided into a number of menus and screens that can be used to configure and control the installation process.

This menu system is controlled by the arrow keys, Enter, Tab, Space, and other keys. To view a detailed description of these keys and what they do, ensure that the Usage entry is highlighted and that the [Select] button is selected, as shown in Figure 3.5, “Selecting Usage from Sysinstall Main Menu”, then press Enter.

The instructions for using the menu system will be displayed. After reviewing them, press Enter to return to the Main Menu.

Figure 3.5. Selecting Usage from Sysinstall Main Menu
Selecting Usage from Sysinstall Main Menu

3.5.1. Selecting the Documentation Menu

From the Main Menu, select Doc with the arrow keys and press Enter.

Figure 3.6. Selecting Documentation Menu
Selecting Documentation Menu

This will display the Documentation Menu.

Figure 3.7. Sysinstall Documentation Menu
Sysinstall Documentation Menu

It is important to read the documents provided. To view a document, select it with the arrow keys and press Enter. When finished reading a document, press Enter to return to the Documentation Menu.

To return to the Main Installation Menu, select Exit with the arrow keys and press Enter.

3.5.2. Selecting the Keymap Menu

To change the keyboard mapping, use the arrow keys to select Keymap from the menu and press Enter. This is only required when using a non-standard or non-US keyboard.

Figure 3.8. Sysinstall Main Menu
Sysinstall Main Menu

A different keyboard mapping may be chosen by selecting the menu item using the up and down arrow keys and pressing Space. Pressing Space again will unselect the item. When finished, choose the [ OK ] using the arrow keys and press Enter.

Only a partial list is shown in this screen representation. Selecting [ Cancel ] by pressing Tab will use the default keymap and return to the Main Install Menu.

Figure 3.9. Sysinstall Keymap Menu
Sysinstall Keymap Menu

3.5.3. Installation Options Screen

Select Options and press Enter.

Figure 3.10. Sysinstall Main Menu
Sysinstall Main Menu

Figure 3.11. Sysinstall Options
Sysinstall Options

The default values are usually fine for most users and do not need to be changed. The release name will vary according to the version being installed.

The description of the selected item will appear at the bottom of the screen highlighted in blue. Notice that one of the options is Use Defaults to reset all values to startup defaults.

Press F1 to read the help screen about the various options.

Press Q to return to the Main Install menu.

3.5.4. Begin a Standard Installation

The Standard installation is the option recommended for those new to UNIX® or FreeBSD. Use the arrow keys to select Standard and then press Enter to start the installation.

Figure 3.12. Begin Standard Installation
Begin Standard Installation

3.6. Allocating Disk Space

The first task is to allocate disk space for FreeBSD, and label that space so that sysinstall(8) can prepare it. In order to do this you need to know how FreeBSD expects to find information on the disk.

3.6.1. BIOS Drive Numbering

Before installing and configuring FreeBSD it is important to be aware how FreeBSD deals with BIOS drive mappings.

In a PC running a BIOS-dependent operating system such as Microsoft® Windows®, the BIOS is able to abstract the normal disk drive order and the operating system goes along with the change. This allows the user to boot from a disk drive other than the "primary master". This is especially convenient for users buy an identical second hard drive, and perform routine copies of the first drive to the second drive. If the first drive fails, is attacked by a virus, or is scribbled upon by an operating system defect, they can easily recover by instructing the BIOS to logically swap the drives. It is like switching the cables on the drives, without having to open the case.

Systems with SCSI controllers often include BIOS extensions which allow the SCSI drives to be re-ordered in a similar fashion for up to seven drives.

A user who is accustomed to taking advantage of these features may become surprised when the results with FreeBSD are not as expected. FreeBSD does not use the BIOS, and does not know the logical BIOS drive mapping. This can lead to perplexing situations, especially when drives are physically identical in geometry and have been made as data clones of one another.

When using FreeBSD, always restore the BIOS to natural drive numbering before installing FreeBSD, and then leave it that way. If drives need to be switched around, take the time to open the case and move the jumpers and cables.

3.6.2. Creating Slices Using FDisk

After choosing to begin a standard installation in sysinstall(8), this message will appear:

Message In the next menu, you will need to set up a DOS-style ("fdisk") partitioning scheme for your hard disk. If you simply wish to devote all disk space to FreeBSD (overwriting anything else that might be on the disk(s) selected) then use the (A)ll command to select the default partitioning scheme followed by a (Q)uit. If you wish to allocate only free space to FreeBSD, move to a partition marked "unused" and use the (C)reate command. [ OK ] [ Press enter or space ]

Press Enter and a list of all the hard drives that the kernel found when it carried out the device probes will be displayed. Figure 3.13, “Select Drive for FDisk” shows an example from a system with two IDE disks called ad0 and ad2.

Figure 3.13. Select Drive for FDisk
Select Drive for FDisk

Note that ad1 is not listed here.

Consider two IDE hard disks where one is the master on the first IDE controller and one is the master on the second IDE controller. If FreeBSD numbered these as ad0 and ad1, everything would work.

But if a third disk is later added as the slave device on the first IDE controller, it would now be ad1, and the previous ad1 would become ad2. Because device names are used to find filesystems, some filesystems may no longer appear correctly, requiring a change to the FreeBSD configuration.

To work around this, the kernel can be configured to name IDE disks based on where they are and not the order in which they were found. With this scheme, the master disk on the second IDE controller will always be ad2, even if there are no ad0 or ad1 devices.

This configuration is the default for the FreeBSD kernel, which is why the display in this example shows ad0 and ad2. The machine on which this screenshot was taken had IDE disks on both master channels of the IDE controllers and no disks on the slave channels.

Select the disk on which to install FreeBSD, and then press [ OK ]. FDisk will start, with a display similar to that shown in Figure 3.14, “Typical Default FDisk Partitions”.

The FDisk display is broken into three sections.

The first section, covering the first two lines of the display, shows details about the currently selected disk, including its FreeBSD name, the disk geometry, and the total size of the disk.

The second section shows the slices that are currently on the disk, where they start and end, how large they are, the name FreeBSD gives them, and their description and sub-type. This example shows two small unused slices which are artifacts of disk layout schemes on the PC. It also shows one large FAT slice, which appears as C: in Windows®, and an extended slice, which may contain other drive letters in Windows®.

The third section shows the commands that are available in FDisk.

Figure 3.14. Typical Default FDisk Partitions
Typical Default FDisk Partitions

This step varies, depending on how the disk is to be sliced.

To install FreeBSD to the entire disk, which will delete all the other data on this disk, press A, which corresponds to the Use Entire Disk option. The existing slices will be removed and replaced with a small area flagged as unused and one large slice for FreeBSD. Then, select the newly created FreeBSD slice using the arrow keys and press S to mark the slice as being bootable. The screen will then look similar to Figure 3.15, “Fdisk Partition Using Entire Disk”. Note the A in the Flags column, which indicates that this slice is active, and will be booted from.

If an existing slice needs to be deleted to make space for FreeBSD, select the slice using the arrow keys and press D. Then, press C to be prompted for the size of the slice to create. Enter the appropriate value and press Enter. The default value in this box represents the largest possible slice to make, which could be the largest contiguous block of unallocated space or the size of the entire hard disk.

If you have already made space for FreeBSD then you can press C to create a new slice. Again, you will be prompted for the size of slice you would like to create.

Figure 3.15. Fdisk Partition Using Entire Disk
Fdisk Partition Using Entire Disk

When finished, press Q. Any changes will be saved in sysinstall(8), but will not yet be written to disk.

3.6.3. Install a Boot Manager

The next menu provides the option to install a boot manager. In general, install the FreeBSD boot manager if:

  • There is more than one drive and FreeBSD will be installed onto a drive other than the first one.

  • FreeBSD will be installed alongside another operating system on the same disk, and you want to choose whether to start FreeBSD or the other operating system when the computer starts.

If FreeBSD is going to be the only operating system on this machine, installed on the first hard disk, then the Standard boot manager will suffice. Choose None if using a third-party boot manager capable of booting FreeBSD.

Make a selection and press Enter.

Figure 3.16. Sysinstall Boot Manager Menu
Sysinstall Boot Manager Menu

The help screen, reached by pressing F1, discusses the problems that can be encountered when trying to share the hard disk between operating systems.

3.6.4. Creating Slices on Another Drive

If there is more than one drive, it will return to the Select Drives screen after the boot manager selection. To install FreeBSD on to more than one disk, select another disk and repeat the slice process using FDisk.

Important:

If installing FreeBSD on a drive other than the first drive, the FreeBSD boot manager needs to be installed on both drives.

Figure 3.17. Exit Select Drive
Exit Select Drive

Use Tab to toggle between the last drive selected, [ OK ], and [ Cancel ].

Press Tab once to toggle to [ OK ], then press Enter to continue with the installation.

3.6.5. Creating Partitions Using Disklabel

Next, create some partitions inside each slice. Remember that each partition is lettered, from a through to h, and that partitions b, c, and d have conventional meanings that should be adhered to.

Certain applications can benefit from particular partition schemes, especially when laying out partitions across more than one disk. However, for a first FreeBSD installation, do not give too much thought to how to partition the disk. It is more important to install FreeBSD and start learning how to use it. You can always re-install FreeBSD to change the partition scheme after becoming more familiar with the operating system.

The following scheme features four partitions: one for swap space and three for filesystems.

Table 3.2. Partition Layout for First Disk
PartitionFilesystemSizeDescription
a/1 GBThis is the root filesystem. Every other filesystem will be mounted somewhere under this one. 1 GB is a reasonable size for this filesystem as user files should not be stored here and a regular FreeBSD install will put about 128 MB of data here.
bN/A2-3 x RAM

The system's swap space is kept on the b partition. Choosing the right amount of swap space can be a bit of an art. A good rule of thumb is that swap space should be two or three times as much as the available physical memory (RAM). There should be at least 64 MB of swap, so if there is less than 32 MB of RAM in the computer, set the swap amount to 64 MB. If there is more than one disk, swap space can be put on each disk. FreeBSD will then use each disk for swap, which effectively speeds up the act of swapping. In this case, calculate the total amount of swap needed and divide this by the number of disks to give the amount of swap to put on each disk.

e/var512 MB to 4096 MB/var contains files that are constantly varying, such as log files and other administrative files. Many of these files are read from or written to extensively during FreeBSD's day-to-day running. Putting these files on another filesystem allows FreeBSD to optimize the access of these files without affecting other files in other directories that do not have the same access pattern.
f/usrRest of disk (at least 8 GB)All other files will typically be stored in /usr and its subdirectories.

Warning:

The values above are given as example and should be used by experienced users only. Users are encouraged to use the automatic partition layout called Auto Defaults by the FreeBSD partition editor.

If installing FreeBSD on to more than one disk, create partitions in the other configured slices. The easiest way to do this is to create two partitions on each disk, one for the swap space, and one for a filesystem.

Table 3.3. Partition Layout for Subsequent Disks
PartitionFilesystemSizeDescription
bN/ASee descriptionSwap space can be split across each disk. Even though the a partition is free, convention dictates that swap space stays on the b partition.
e/disknRest of diskThe rest of the disk is taken up with one big partition. This could easily be put on the a partition, instead of the e partition. However, convention says that the a partition on a slice is reserved for the filesystem that will be the root (/) filesystem. Following this convention is not necessary, but sysinstall(8) uses it, so following it makes the installation slightly cleaner. This filesystem can be mounted anywhere; this example mounts it as /diskn, where n is a number that changes for each disk.

Having chosen the partition layout, create it using sysinstall(8).

Message Now, you need to create BSD partitions inside of the fdisk partition(s) just created. If you have a reasonable amount of disk space (1GB or more) and don't have any special requirements, simply use the (A)uto command to allocate space automatically. If you have more specific needs or just don't care for the layout chosen by (A)uto, press F1 for more information on manual layout. [ OK ] [ Press enter or space ]

Press Enter to start the FreeBSD partition editor, called Disklabel.

Figure 3.18, “Sysinstall Disklabel Editor” shows the display when Disklabel starts. The display is divided into three sections.

The first few lines show the name of the disk being worked on and the slice that contains the partitions to create. At this point, Disklabel calls this the Partition name rather than slice name. This display also shows the amount of free space within the slice; that is, space that was set aside in the slice, but that has not yet been assigned to a partition.

The middle of the display shows the partitions that have been created, the name of the filesystem that each partition contains, their size, and some options pertaining to the creation of the filesystem.

The bottom third of the screen shows the keystrokes that are valid in Disklabel.

Figure 3.18. Sysinstall Disklabel Editor
Sysinstall Disklabel Editor

Disklabel can automatically create partitions and assign them default sizes. The default sizes are calculated with the help of an internal partition sizing algorithm based on the disk size. Press A to see a display similar to that shown in Figure 3.19, “Sysinstall Disklabel Editor with Auto Defaults”. Depending on the size of the disk, the defaults may or may not be appropriate.

Note:

The default partitioning assigns /tmp its own partition instead of being part of the / partition. This helps avoid filling the / partition with temporary files.

Figure 3.19. Sysinstall Disklabel Editor with Auto Defaults
Sysinstall Disklabel Editor with Auto Defaults

To replace the default partitions, use the arrow keys to select the first partition and press D to delete it. Repeat this to delete all the suggested partitions.

To create the first partition, a, mounted as /, make sure the proper disk slice at the top of the screen is selected and press C. A dialog box will appear, prompting for the size of the new partition, as shown in Figure 3.20, “Free Space for Root Partition”. The size can be entered as the number of disk blocks to use or as a number followed by either M for megabytes, G for gigabytes, or C for cylinders.

Figure 3.20. Free Space for Root Partition
Free Space for Root Partition

The default size shown will create a partition that takes up the rest of the slice. If using the partition sizes described in the earlier example, delete the existing figure using Backspace, and then type in 512M, as shown in Figure 3.21, “Edit Root Partition Size”. Then press [ OK ].

Figure 3.21. Edit Root Partition Size
Edit Root Partition Size

After choosing the partition's size, the installer will ask whether this partition will contain a filesystem or swap space. The dialog box is shown in Figure 3.22, “Choose the Root Partition Type”. This first partition will contain a filesystem, so check that FS is selected and press Enter.

Figure 3.22. Choose the Root Partition Type
Choose the Root Partition Type

Finally, tell Disklabel where the filesystem will be mounted. The dialog box is shown in Figure 3.23, “Choose the Root Mount Point”. Type /, and then press Enter.

Figure 3.23. Choose the Root Mount Point
Choose the Root Mount Point

The display will then update to show the newly created partition. Repeat this procedure for the other partitions. When creating the swap partition, it will not prompt for the filesystem mount point. When creating the final partition, /usr, leave the suggested size as is to use the rest of the slice.

The final FreeBSD DiskLabel Editor screen will appear similar to Figure 3.24, “Sysinstall Disklabel Editor”, although the values chosen may be different. Press Q to finish.

Figure 3.24. Sysinstall Disklabel Editor
Sysinstall Disklabel Editor

3.7. Choosing What to Install

3.7.1. Select the Distribution Set

Deciding which distribution set to install will depend largely on the intended use of the system and the amount of disk space available. The predefined options range from installing the smallest possible configuration to everything. Those who are new to UNIX® or FreeBSD should select one of these canned options. Customizing a distribution set is typically for the more experienced user.

Press F1 for more information on the distribution set options and what they contain. When finished reviewing the help, press Enter to return to the Select Distributions Menu.

If a graphical user interface is desired, the configuration of Xorg and selection of a default desktop must be done after the installation of FreeBSD. More information regarding the installation and configuration of a Xorg can be found in Chapter 6, The X Window System.

If compiling a custom kernel is anticipated, select an option which includes the source code. For more information on why a custom kernel should be built or how to build a custom kernel, see Chapter 9, Configuring the FreeBSD Kernel.

The most versatile system is one that includes everything. If there is adequate disk space, select All, as shown in Figure 3.25, “Choose Distributions”, by using the arrow keys and pressing Enter. If there is a concern about disk space, consider using an option that is more suitable for the situation. Do not fret over the perfect choice, as other distributions can be added after installation.

Figure 3.25. Choose Distributions
Choose Distributions

3.7.2. Installing the Ports Collection

After selecting the desired distribution, an opportunity to install the FreeBSD Ports Collection is presented. The Ports Collection is an easy and convenient way to install software as it provides a collection of files that automate the downloading, compiling, and installation of third-party software packages. Chapter 5, Installing Applications: Packages and Ports discusses how to use the Ports Collection.

The installation program does not check to see if you have adequate space. Select this option only if you have adequate hard disk space. As of FreeBSD 9.1, the FreeBSD Ports Collection takes up about 500 MB of disk space. You can safely assume a larger value for more recent versions of FreeBSD.

User Confirmation Requested Would you like to install the FreeBSD ports collection? This will give you ready access to over 24,000 ported software packages, at a cost of around 500 MB of disk space when "clean" and possibly much more than that if a lot of the distribution tarballs are loaded (unless you have the extra CDs from a FreeBSD CD/DVD distribution available and can mount it on /cdrom, in which case this is far less of a problem). The Ports Collection is a very valuable resource and well worth having on your /usr partition, so it is advisable to say Yes to this option. For more information on the Ports Collection & the latest ports, visit: http://www.FreeBSD.org/ports [ Yes ] No

Select [ Yes ] with the arrow keys to install the Ports Collection or [ No ] to skip this option. Press Enter to continue. The Choose Distributions menu will redisplay.

Figure 3.26. Confirm Distributions
Confirm Distributions

Once satisfied with the options, select Exit with the arrow keys, ensure that [ OK ] is highlighted, and press Enter to continue.

3.8. Choosing the Installation Media

If installing from a CD/DVD, use the arrow keys to highlight Install from a FreeBSD CD/DVD. Ensure that [ OK ] is highlighted, then press Enter to proceed with the installation.

For other methods of installation, select the appropriate option and follow the instructions.

Press F1 to display the Online Help for installation media. Press Enter to return to the media selection menu.

Figure 3.27. Choose Installation Media
Choose Installation Media

FTP Installation Modes:

There are three FTP installation modes to choose from: active FTP, passive FTP, or via a HTTP proxy.

FTP Active: Install from an FTP server

This option makes 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 the connection hangs with passive mode (the default), try using active mode.

FTP Passive: Install from an FTP server through a firewall

This option instructs sysinstall(8) to use passive mode for all FTP operations. This allows the user to pass through firewalls that do not allow incoming connections on random TCP ports.

FTP via a HTTP proxy: Install from an FTP server through a http proxy

This option instructs sysinstall(8) to use the HTTP protocol to connect to a proxy for all FTP operations. The proxy will translate the requests and send them to the FTP server. This allows the user to pass through firewalls that do not allow FTP, but offer a HTTP proxy. In this case, specify the proxy in addition to the FTP server.

For a proxy FTP server, give the name of the server as part of the username, after an @ sign. The proxy server then fakes the real server. For example, to install from ftp.FreeBSD.org, using the proxy FTP server foo.example.com, listening on port 1234, go to the options menu, set the FTP username to ftp@ftp.FreeBSD.org and the password to an email address. As the installation media, specify FTP (or passive FTP, if the proxy supports it), and the URL ftp://foo.example.com:1234/pub/FreeBSD.

Since /pub/FreeBSD from ftp.FreeBSD.org is proxied under foo.example.com, the proxy will fetch the files from ftp.FreeBSD.org as the installer requests them.

3.9. Committing to the Installation

The installation can now proceed if desired. This is also the last chance for aborting the installation to prevent changes to the hard drive.

User Confirmation Requested Last Chance! Are you SURE you want to continue the installation? If you're running this on a disk with data you wish to save then WE STRONGLY ENCOURAGE YOU TO MAKE PROPER BACKUPS before proceeding! We can take no responsibility for lost disk contents! [ Yes ] No

Select [ Yes ] and press Enter to proceed.

The installation time will vary according to the distribution chosen, installation media, and the speed of the computer. There will be a series of messages displayed, indicating the status.

The installation is complete when the following message is displayed:

Message Congratulations! You now have FreeBSD installed on your system. We will now move on to the final configuration questions. For any option you do not wish to configure, simply select No. If you wish to re-enter this utility after the system is up, you may do so by typing: /usr/sbin/sysinstall. [ OK ] [ Press enter or space ]

Press Enter to proceed with post-installation configurations.

Selecting [ No ] and pressing Enter will abort the installation so no changes will be made to the system. The following message will appear:

Message Installation complete with some errors. You may wish to scroll through the debugging messages on VTY1 with the scroll-lock feature. You can also choose "No" at the next prompt and go back into the installation menus to retry whichever operations have failed. [ OK ]

This message is generated because nothing was installed. Pressing Enter will return to the Main Installation Menu to exit the installation.

3.10. Post-installation

Configuration of various options can be performed after a successful installation. An option can be configured by re-entering the configuration menus before booting the new FreeBSD system or after boot using sysinstall(8) and then selecting the Configure menu.

3.10.1. Network Device Configuration

If PPP was previously configured for an FTP install, this screen will not display and can be configured after boot as described above.

For detailed information on Local Area Networks and configuring FreeBSD as a gateway/router refer to the Advanced Networking chapter.

User Confirmation Requested Would you like to configure any Ethernet or PPP network devices? [ Yes ] No

To configure a network device, select [ Yes ] and press Enter. Otherwise, select [ No ] to continue.

Figure 3.28. Selecting an Ethernet Device
Selecting an Ethernet Device

Select the interface to be configured with the arrow keys and press Enter.

User Confirmation Requested Do you want to try IPv6 configuration of the interface? Yes [ No ]

In this private local area network, the current Internet type protocol (IPv4) was sufficient and [ No ] was selected with the arrow keys and Enter pressed.

If connected to an existing IPv6 network with an RA server, choose [ Yes ] and press Enter. It will take several seconds to scan for RA servers.

User Confirmation Requested Do you want to try DHCP configuration of the interface? Yes [ No ]

If Dynamic Host Configuration Protocol DHCP) is not required, select [ No ] with the arrow keys and press Enter.

Selecting [ Yes ] will execute dhclient(8) and, if successful, will fill in the network configuration information automatically. Refer to Section 29.6, “Automatic Network Configuration (DHCP)” for more information.

The following Network Configuration screen shows the configuration of the Ethernet device for a system that will act as the gateway for a Local Area Network.

Figure 3.29. Set Network Configuration for ed0
Set Network Configuration for ed0

Use Tab to select the information fields and fill in appropriate information:

Host

The fully-qualified hostname, such as k6-2.example.com in this case.

Domain

The name of the domain that the machine is in, such as example.com for this case.

IPv4 Gateway

IP address of host forwarding packets to non-local destinations. This must be filled in if the machine is a node on the network. Leave this field blank if the machine is the gateway to the Internet for the network. The IPv4 Gateway is also known as the default gateway or default route.

Name server

IP address of the local DNS server. There is no local DNS server on this private local area network so the IP address of the provider's DNS server (208.163.10.2) was used.

IPv4 address

The IP address to be used for this interface was 192.168.0.1

Netmask

The address block being used for this local area network is 192.168.0.0 - 192.168.0.255 with a netmask of 255.255.255.0.

Extra options to ifconfig(8)

Any additional interface-specific options to ifconfig(8). There were none in this case.

Use Tab to select [ OK ] when finished and press Enter.

User Confirmation Requested Would you like to bring the ed0 interface up right now? [ Yes ] No

Choosing [ Yes ] and pressing Enter will bring the machine up on the network so it is ready for use. However, this does not accomplish much during installation, since the machine still needs to be rebooted.

3.10.2. Configure Gateway

User Confirmation Requested Do you want this machine to function as a network gateway? [ Yes ] No

If the machine will be acting as the gateway for a local area network and forwarding packets between other machines, select [ Yes ] and press Enter. If the machine is a node on a network, select [ No ] and press Enter to continue.

3.10.3. Configure Internet Services

User Confirmation Requested Do you want to configure inetd and the network services that it provides? Yes [ No ]

If [ No ] is selected, various services will not be enabled. These services can be enabled after installation by editing /etc/inetd.conf with a text editor. See Section 29.2.1, “Overview” for more information.

Otherwise, select [ Yes ] to configure these services during install. An additional confirmation will display:

User Confirmation Requested The Internet Super Server (inetd) allows a number of simple Internet services to be enabled, including finger, ftp and telnetd. Enabling these services may increase risk of security problems by increasing the exposure of your system. With this in mind, do you wish to enable inetd? [ Yes ] No

Select [ Yes ] to continue.

User Confirmation Requested inetd(8) relies on its configuration file, /etc/inetd.conf, to determine which of its Internet services will be available. The default FreeBSD inetd.conf(5) leaves all services disabled by default, so they must be specifically enabled in the configuration file before they will function, even once inetd(8) is enabled. Note that services for IPv6 must be separately enabled from IPv4 services. Select [Yes] now to invoke an editor on /etc/inetd.conf, or [No] to use the current settings. [ Yes ] No

Selecting [ Yes ] allows services to be enabled by deleting the # at the beginning of the lines representing those services.

Figure 3.30. Editing inetd.conf
Editing inetd.conf

Once the edits are complete, press Esc to display a menu which will exit the editor and save the changes.

3.10.4. Enabling SSH Login

User Confirmation Requested Would you like to enable SSH login? Yes [ No ]

Selecting [ Yes ] will enable sshd(8), the daemon for OpenSSH. This allows secure remote access to the machine. For more information about OpenSSH, see Section 15.10, “OpenSSH”.

3.10.5. Anonymous FTP

User Confirmation Requested Do you want to have anonymous FTP access to this machine? Yes [ No ]

3.10.5.1. Deny Anonymous FTP

Selecting the default [ No ] and pressing Enter will still allow users who have accounts with passwords to use FTP to access the machine.

3.10.5.2. Allow Anonymous FTP

Anyone can access the machine if anonymous FTP connections are allowed. The security implications should be considered before enabling this option. For more information about security, see Chapter 15, Security.

To allow anonymous FTP, use the arrow keys to select [ Yes ] and press Enter. An additional confirmation will display:

User Confirmation Requested Anonymous FTP permits un-authenticated users to connect to the system FTP server, if FTP service is enabled. Anonymous users are restricted to a specific subset of the file system, and the default configuration provides a drop-box incoming directory to which uploads are permitted. You must separately enable both inetd(8), and enable ftpd(8) in inetd.conf(5) for FTP services to be available. If you did not do so earlier, you will have the opportunity to enable inetd(8) again later. If you want the server to be read-only you should leave the upload directory option empty and add the -r command-line option to ftpd(8) in inetd.conf(5) Do you wish to continue configuring anonymous FTP? [ Yes ] No

This message indicates that the FTP service will also have to be enabled in /etc/inetd.conf to allow anonymous FTP connections. Select [ Yes ] and press Enter to continue. The following screen will display:

Figure 3.31. Default Anonymous FTP Configuration
Default Anonymous FTP Configuration

Use Tab to select the information fields and fill in appropriate information:

UID

The user ID to assign to the anonymous FTP user. All files uploaded will be owned by this ID.

Group

Which group to place the anonymous FTP user into.

Comment

String describing this user in /etc/passwd.

FTP Root Directory

Where files available for anonymous FTP will be kept.

Upload Subdirectory

Where files uploaded by anonymous FTP users will go.

The FTP root directory will be put in /var by default. If there is not enough room there for the anticipated FTP needs, use /usr instead by setting the FTP root directory to /usr/ftp.

Once satisfied with the values, press Enter to continue.

User Confirmation Requested Create a welcome message file for anonymous FTP users? [ Yes ] No

If [ Yes ] is selected, press Enter and the cu(1) editor will automatically start.

Figure 3.32. Edit the FTP Welcome Message
Edit the FTP Welcome Message

Use the instructions to change the message. Note the file name location at the bottom of the editor screen.

Press Esc and a pop-up menu will default to a) leave editor. Press Enter to exit and continue. Press Enter again to save any changes.

3.10.6. Configure the Network File System

The Network File System (NFS) allows sharing of files across a network. A machine can be configured as a server, a client, or both. Refer to Section 29.3, “Network File System (NFS)” for more information.

3.10.6.1. NFS Server

User Confirmation Requested Do you want to configure this machine as an NFS server? Yes [ No ]

If there is no need for a NFS server, select [ No ] and press Enter.

If [ Yes ] is chosen, a message will pop-up indicating that /etc/exports must be created.

Message Operating as an NFS server means that you must first configure an /etc/exports file to indicate which hosts are allowed certain kinds of access to your local filesystems. Press [Enter] now to invoke an editor on /etc/exports [ OK ]

Press Enter to continue. A text editor will start, allowing /etc/exports to be edited.

Figure 3.33. Editing exports
Editing exports

Use the instructions to add the exported filesystems. Note the file name location at the bottom of the editor screen.

Press Esc and a pop-up menu will default to a) leave editor. Press Enter to exit and continue.

3.10.6.2. NFS Client

The NFS client allows the machine to access NFS servers.

User Confirmation Requested Do you want to configure this machine as an NFS client? Yes [ No ]

With the arrow keys, select [ Yes ] or [ No ] as appropriate and press Enter.

3.10.7. System Console Settings

There are several options available to customize the system console.

User Confirmation Requested Would you like to customize your system console settings? [ Yes ] No

To view and configure the options, select [ Yes ] and press Enter.

Figure 3.34. System Console Configuration Options
System Console Configuration Options

A commonly used option is the screen saver. Use the arrow keys to select Saver and then press Enter.

Figure 3.35. Screen Saver Options
Screen Saver Options

Select the desired screen saver using the arrow keys and then press Enter. The System Console Configuration menu will redisplay.

The default time interval is 300 seconds. To change the time interval, select Saver again. At the Screen Saver Options menu, select Timeout using the arrow keys and press Enter. A pop-up menu will appear:

Figure 3.36. Screen Saver Timeout
Screen Saver Timeout

The value can be changed, then select [ OK ] and press Enter to return to the System Console Configuration menu.

Figure 3.37. System Console Configuration Exit
System Console Configuration Exit

Select Exit and press Enter to continue with the post-installation configuration.

3.10.8. Setting the Time Zone

Setting the time zone allows the system to automatically correct for any regional time changes and perform other time zone related functions properly.

The example shown is for a machine located in the Eastern time zone of the United States. The selections will vary according to the geographic location.

User Confirmation Requested Would you like to set this machine's time zone now? [ Yes ] No

Select [ Yes ] and press Enter to set the time zone.

User Confirmation Requested Is this machine's CMOS clock set to UTC? If it is set to local time or you don't know, please choose NO here! Yes [ No ]

Select [ Yes ] or [ No ] according to how the machine's clock is configured, then press Enter.

Figure 3.38. Select the Region
Select the Region

The appropriate region is selected using the arrow keys and then pressing Enter.

Figure 3.39. Select the Country
Select the Country

Select the appropriate country using the arrow keys and press Enter.

Figure 3.40. Select the Time Zone
Select the Time Zone

The appropriate time zone is selected using the arrow keys and pressing Enter.

Confirmation Does the abbreviation 'EDT' look reasonable? [ Yes ] No

Confirm that the abbreviation for the time zone is correct. If it looks okay, press Enter to continue with the post-installation configuration.

3.10.9. Mouse Settings

This option allows cut and paste in the console and user programs using a 3-button mouse. If using a 2-button mouse, refer to moused(8) for details on emulating the 3-button style. This example depicts a non-USB mouse configuration:

User Confirmation Requested Does this system have a PS/2, serial, or bus mouse? [ Yes ] No

Select [ Yes ] for a PS/2, serial, or bus mouse, or [ No ] for a USB mouse, then press Enter.

Figure 3.41. Select Mouse Protocol Type
Select Mouse Protocol Type

Use the arrow keys to select Type and press Enter.

Figure 3.42. Set Mouse Protocol
Set Mouse Protocol

The mouse used in this example is a PS/2 type, so the default Auto is appropriate. To change the mouse protocol, use the arrow keys to select another option. Ensure that [ OK ] is highlighted and press Enter to exit this menu.

Figure 3.43. Configure Mouse Port
Configure Mouse Port

Use the arrow keys to select Port and press Enter.

Figure 3.44. Setting the Mouse Port
Setting the Mouse Port

This system had a PS/2 mouse, so the default PS/2 is appropriate. To change the port, use the arrow keys and then press Enter.

Figure 3.45. Enable the Mouse Daemon
Enable the Mouse Daemon

Last, use the arrow keys to select Enable, and press Enter to enable and test the mouse daemon.

Figure 3.46. Test the Mouse Daemon
Test the Mouse Daemon

Move the mouse around the screen to verify that the cursor responds properly. If it does, select [ Yes ] and press Enter. If not, the mouse has not been configured correctly. Select [ No ] and try using different configuration options.

Select Exit with the arrow keys and press Enter to continue with the post-installation configuration.

3.10.10. Install Packages

Packages are pre-compiled binaries and are a convenient way to install software.

Installation of one package is shown for purposes of illustration. Additional packages can also be added at this time if desired. After installation, sysinstall(8) can be used to add additional packages.

User Confirmation Requested The FreeBSD package collection is a collection of hundreds of ready-to-run applications, from text editors to games to WEB servers and more. Would you like to browse the collection now? [ Yes ] No

Select [ Yes ] and press Enter to be presented with the Package Selection screens:

Figure 3.47. Select Package Category
Select Package Category

Only packages on the current installation media are available for installation at any given time.

All packages available will be displayed if All is selected. Otherwise, select a particular category. Highlight the selection with the arrow keys and press Enter.

A menu will display showing all the packages available for the selection made:

Figure 3.48. Select Packages
Select Packages

The bash shell is shown as selected. Select as many packages as desired by highlighting the package and pressing Space. A short description of each package will appear in the lower left corner of the screen.

Press Tab to toggle between the last selected package, [ OK ], and [ Cancel ].

Once finished marking the packages for installation, press Tab once to toggle to [ OK ] and press Enter to return to the Package Selection menu.

The left and right arrow keys will also toggle between [ OK ] and [ Cancel ]. This method can also be used to select [ OK ] and press Enter to return to the Package Selection menu.

Figure 3.49. Install Packages
Install Packages

Use the Tab and arrow keys to select [ Install ] and press Enter to see the installation confirmation message:

Figure 3.50. Confirm Package Installation
Confirm Package Installation

Select [ OK ] and press Enter to start the package installation. Installation messages will appear until all of the installations have completed. Make note if there are any error messages.

The final configuration continues after packages are installed. If no packages are selected, select Install to return to the final configuration.

3.10.11. Add Users/Groups

Add at least one user during the installation so that the system can be used without logging in as root. The root partition is generally small and running applications as root can quickly fill it. A bigger danger is noted below:

User Confirmation Requested Would you like to add any initial user accounts to the system? Adding at least one account for yourself at this stage is suggested since working as the "root" user is dangerous (it is easy to do things which adversely affect the entire system). [ Yes ] No

Select [ Yes ] and press Enter to continue with adding a user.

Figure 3.51. Select User
Select User

Select User with the arrow keys and press Enter.

Figure 3.52. Add User Information
Add User Information

The following descriptions will appear in the lower part of the screen as the items are selected with Tab to assist with entering the required information:

Login ID

The login name of the new user (mandatory).

UID

The numerical ID for this user (leave blank for automatic choice).

Group

The login group name for this user (leave blank for automatic choice).

Password

The password for this user (enter this field with care!).

Full name

The user's full name (comment).

Member groups

The groups this user belongs to.

Home directory

The user's home directory (leave blank for default).

Login shell

The user's login shell (leave blank for default of /bin/sh).

In this example, the login shell was changed from /bin/sh to /usr/local/bin/bash to use the bash shell that was previously installed as a package. Do not use a shell that does not exist or the user will not be able to login. The most common shell used in FreeBSD is the C shell, /bin/tcsh.

The user was also added to the wheel group to be able to become a superuser with root privileges.

Once satisfied, press [ OK ] and the User and Group Management menu will redisplay:

Figure 3.53. Exit User and Group Management
Exit User and Group Management

Groups can also be added at this time. Otherwise, this menu may be accessed using sysinstall(8) at a later time.

When finished adding users, select Exit with the arrow keys and press Enter to continue the installation.

3.10.12. Set the root Password

Message Now you must set the system manager's password. This is the password you'll use to log in as "root". [ OK ] [ Press enter or space ]

Press Enter to set the root password.

The password will need to be typed in twice correctly. Do not forget this password. Notice that the typed password is not echoed, nor are asterisks displayed.

New password: Retype new password :

The installation will continue after the password is successfully entered.

3.10.13. Exiting Install

A message will ask if configuration is complete:

User Confirmation Requested Visit the general configuration menu for a chance to set any last options? Yes [ No ]

Select [ No ] with the arrow keys and press Enter to return to the Main Installation Menu.

Figure 3.54. Exit Install
Exit Install

Select [X Exit Install] with the arrow keys and press Enter. The installer will prompt to confirm exiting the installation:

User Confirmation Requested Are you sure you wish to exit? The system will reboot. [ Yes ] No

Select [ Yes ]. If booting from the CDROM drive, the following message will remind you to remove the disk:

Message Be sure to remove the media from the drive. [ OK ] [ Press enter or space ]

The CDROM drive is locked until the machine starts to reboot, then the disk can quickly be removed from the drive. Press [ OK ] to reboot.

The system will reboot so watch for any error messages that may appear, see Section 3.10.15, “FreeBSD Bootup” for more details.

3.10.14. Configure Additional Network Services

Contributed by Tom Rhodes.

Configuring network services can be a daunting task for users that lack previous knowledge in this area. Since networking and the Internet are critical to all modern operating systems, it is useful to have some understanding of FreeBSD's extensive networking capabilities.

Network services are programs that accept input from anywhere on the network. Since there have been cases where bugs in network services have been exploited by attackers, it is important to only enable needed network services. If in doubt, do not enable a network service until it is needed. Services can be enabled with sysinstall(8) or by editing /etc/rc.conf.

Selecting the Networking option will display a menu similar to the one below:

Figure 3.55. Network Configuration Upper-level
Network Configuration Upper-level

The first option, Interfaces, is covered in Section 3.10.1, “Network Device Configuration”.

Selecting the AMD option adds support for amd(8). This is usually used in conjunction with NFS for automatically mounting remote filesystems.

Next is the AMD Flags option. When selected, a menu will pop up where specific AMD flags can be entered. The menu already contains a set of default options:

-a /.amd_mnt -l syslog /host /etc/amd.map /net /etc/amd.map

-a sets the default mount location which is specified here as /.amd_mnt. -l specifies the default log; however, when syslogd(8) is used, all log activity will be sent to the system log daemon. /host is used to mount an exported file system from a remote host, while /net is used to mount an exported filesystem from an IP address. The default options for AMD exports are defined in /etc/amd.map.

The Anon FTP option permits anonymous FTP connections. Select this option to make this machine an anonymous FTP server. Be aware of the security risks involved with this option. Another menu will be displayed to explain the security risks and configuration in depth.

The Gateway menu will configure the machine to be a gateway. This menu can also be used to unset the Gateway option if it was accidentally selected during installation.

The Inetd option can be used to configure or completely disable inetd(8).

The Mail option is used to configure the system's default Mail Transfer Agent (MTA). Selecting this option will bring up the following menu:

Figure 3.56. Select a Default MTA
Select a Default MTA

This menu offers a choice as to which MTA to install and set as the default. An MTA is a mail server which delivers email to users on the system or the Internet.

Select Sendmail to install Sendmail as the default MTA. Select Sendmail local to set Sendmail as the default MTA, but disable its ability to receive incoming email from the Internet. The other options, Postfix and Exim, provide alternatives to Sendmail.

The next menu after the MTA menu is NFS client. This menu is used to configure the system to communicate with a NFS server which in turn is used to make filesystems available to other machines on the network over the NFS protocol. See Section 29.3, “Network File System (NFS)” for more information about client and server configuration.

Below that option is the NFS server option, for setting the system up as an NFS server. This adds the required information to start up the Remote Procedure Call RPC services. RPC is used to coordinate connections between hosts and programs.

Next in line is the Ntpdate option, which deals with time synchronization. When selected, a menu like the one below shows up:

Figure 3.57. Ntpdate Configuration
Ntpdate Configuration

From this menu, select the server which is geographically closest. This will make the time synchronization more accurate as a farther server may have more connection latency.

The next option is the PCNFSD selection. This option will install the net/pcnfsd package from the Ports Collection. This is a useful utility which provides NFS authentication services for systems which are unable to provide their own, such as Microsoft's MS-DOS® operating system.

Now, scroll down a bit to see the other options:

Figure 3.58. Network Configuration Lower-level
Network Configuration Lower-level

RPC. communication between NFS servers and clients is managed by rpcbind(8) which is required for NFS servers to operate correctly. Status monitoring is provided by rpc.statd(8) and the reported status is usually held in /var/db/statd.status. The next option is for rpc.lockd(8) which provides file locking services. This is usually used with rpc.statd(8) to monitor which hosts are requesting locks and how frequently they request them. While these last two options are useful for debugging, they are not required for NFS servers and clients to operate correctly.

The next menu, Routed, configures the routing daemon. routed(8), manages network routing tables, discovers multicast routers, and supplies a copy of the routing tables to any physically connected host on the network upon request. This is mainly used for machines which act as a gateway for the local network. If selected, a menu will request the default location of the utility. To accept the default location, press Enter. Yet another menu will ask for the flags to pass to routed(8). The default of -q should appear on the screen.

The next menu, Rwhod, starts rwhod(8) during system initialization. This utility broadcasts system messages across the network periodically, or collects them when in consumer mode. More information can be found in ruptime(1) and rwho(1).

The next to last option in the list is for sshd(8), the secure shell server for OpenSSH. It is highly recommended over the standard telnetd(8) and ftpd(8) servers as it is used to create a secure, encrypted connection from one host to another.

The final option is TCP Extensions which are defined in RFC 1323 and RFC 1644. While on many hosts this can speed up connections, it can also cause some connections to be dropped. It is not recommended for servers, but may be beneficial for stand alone machines.

Once the network services are configured, scroll up to the very top item which is X Exit and continue on to the next configuration item or simply exit sysinstall(8) by selecting X Exit twice then [X Exit Install].

3.10.15. FreeBSD Bootup

3.10.15.1. FreeBSD/i386 Bootup

If everything went well, messages will scroll along the screen and a login prompt will appear. To view these messages, press Scroll-Lock then use PgUp and PgDn. Press Scroll-Lock again to return to the prompt.

All of the messages may not display due to buffer limitations, but they can be read after logging using dmesg(8).

Login using the username and password which were set during installation. Avoid logging in as root except when necessary.

Typical boot messages (version information omitted):

Copyright (c) 1992-2002 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. Timecounter "i8254" frequency 1193182 Hz CPU: AMD-K6(tm) 3D processor (300.68-MHz 586-class CPU) Origin = "AuthenticAMD" Id = 0x580 Stepping = 0 Features=0x8001bf<FPU,VME,DE,PSE,TSC,MSR,MCE,CX8,MMX> AMD Features=0x80000800<SYSCALL,3DNow!> real memory = 268435456 (262144K bytes) config> di sn0 config> di lnc0 config> di le0 config> di ie0 config> di fe0 config> di cs0 config> di bt0 config> di aic0 config> di aha0 config> di adv0 config> q avail memory = 256311296 (250304K bytes) Preloaded elf kernel "kernel" at 0xc0491000. Preloaded userconfig_script "/boot/kernel.conf" at 0xc049109c. md0: Malloc disk Using $PIR table, 4 entries at 0xc00fde60 npx0: <math processor> on motherboard npx0: INT 16 interface pcib0: <Host to PCI bridge> on motherboard pci0: <PCI bus> on pcib0 pcib1: <VIA 82C598MVP (Apollo MVP3) PCI-PCI (AGP) bridge> at device 1.0 on pci0 pci1: <PCI bus> on pcib1 pci1: <Matrox MGA G200 AGP graphics accelerator> at 0.0 irq 11 isab0: <VIA 82C586 PCI-ISA bridge> at device 7.0 on pci0 isa0: <ISA bus> on isab0 atapci0: <VIA 82C586 ATA33 controller> port 0xe000-0xe00f at device 7.1 on pci0 ata0: at 0x1f0 irq 14 on atapci0 ata1: at 0x170 irq 15 on atapci0 uhci0: <VIA 83C572 USB controller> port 0xe400-0xe41f irq 10 at device 7.2 on pci0 usb0: <VIA 83C572 USB controller> on uhci0 usb0: USB revision 1.0 uhub0: VIA UHCI root hub, class 9/0, rev 1.00/1.00, addr 1 uhub0: 2 ports with 2 removable, self powered chip1: <VIA 82C586B ACPI interface> at device 7.3 on pci0 ed0: <NE2000 PCI Ethernet (RealTek 8029)> port 0xe800-0xe81f irq 9 at device 10.0 on pci0 ed0: address 52:54:05:de:73:1b, type NE2000 (16 bit) isa0: too many dependant configs (8) isa0: unexpected small tag 14 fdc0: <NEC 72065B or clone> at port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on isa0 fdc0: FIFO enabled, 8 bytes threshold fd0: <1440-KB 3.5" drive> on fdc0 drive 0 atkbdc0: <keyboard controller (i8042)> at port 0x60-0x64 on isa0 atkbd0: <AT Keyboard> flags 0x1 irq 1 on atkbdc0 kbd0 at atkbd0 psm0: <PS/2 Mouse> irq 12 on atkbdc0 psm0: model Generic PS/2 mouse, device ID 0 vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0 sc0: <System console> at flags 0x1 on isa0 sc0: VGA <16 virtual consoles, flags=0x300> sio0 at port 0x3f8-0x3ff irq 4 flags 0x10 on isa0 sio0: type 16550A sio1 at port 0x2f8-0x2ff irq 3 on isa0 sio1: type 16550A ppc0: <Parallel port> at port 0x378-0x37f irq 7 on isa0 ppc0: SMC-like chipset (ECP/EPP/PS2/NIBBLE) in COMPATIBLE mode ppc0: FIFO with 16/16/15 bytes threshold ppbus0: IEEE1284 device found /NIBBLE Probing for PnP devices on ppbus0: plip0: <PLIP network interface> on ppbus0 lpt0: <Printer> on ppbus0 lpt0: Interrupt-driven port ppi0: <Parallel I/O> on ppbus0 ad0: 8063MB <IBM-DHEA-38451> [16383/16/63] at ata0-master using UDMA33 ad2: 8063MB <IBM-DHEA-38451> [16383/16/63] at ata1-master using UDMA33 acd0: CDROM <DELTA OTC-H101/ST3 F/W by OIPD> at ata0-slave using PIO4 Mounting root from ufs:/dev/ad0s1a swapon: adding /dev/ad0s1b as swap device Automatic boot in progress... /dev/ad0s1a: FILESYSTEM CLEAN; SKIPPING CHECKS /dev/ad0s1a: clean, 48752 free (552 frags, 6025 blocks, 0.9% fragmentation) /dev/ad0s1f: FILESYSTEM CLEAN; SKIPPING CHECKS /dev/ad0s1f: clean, 128997 free (21 frags, 16122 blocks, 0.0% fragmentation) /dev/ad0s1g: FILESYSTEM CLEAN; SKIPPING CHECKS /dev/ad0s1g: clean, 3036299 free (43175 frags, 374073 blocks, 1.3% fragmentation) /dev/ad0s1e: filesystem CLEAN; SKIPPING CHECKS /dev/ad0s1e: clean, 128193 free (17 frags, 16022 blocks, 0.0% fragmentation) Doing initial network setup: hostname. ed0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255 inet6 fe80::5054::5ff::fede:731b%ed0 prefixlen 64 tentative scopeid 0x1 ether 52:54:05:de:73:1b lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x8 inet6 ::1 prefixlen 128 inet 127.0.0.1 netmask 0xff000000 Additional routing options: IP gateway=YES TCP keepalive=YES routing daemons:. additional daemons: syslogd. Doing additional network setup:. Starting final network daemons: creating ssh RSA host key Generating public/private rsa1 key pair. Your identification has been saved in /etc/ssh/ssh_host_key. Your public key has been saved in /etc/ssh/ssh_host_key.pub. The key fingerprint is: cd:76:89:16:69:0e:d0:6e:f8:66:d0:07:26:3c:7e:2d root@k6-2.example.com creating ssh DSA host key Generating public/private dsa key pair. Your identification has been saved in /etc/ssh/ssh_host_dsa_key. Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub. The key fingerprint is: f9:a1:a9:47:c4:ad:f9:8d:52:b8:b8:ff:8c:ad:2d:e6 root@k6-2.example.com. setting ELF ldconfig path: /usr/lib /usr/lib/compat /usr/X11R6/lib /usr/local/lib a.out ldconfig path: /usr/lib/aout /usr/lib/compat/aout /usr/X11R6/lib/aout starting standard daemons: inetd cron sshd usbd sendmail. Initial rc.i386 initialization:. rc.i386 configuring syscons: blank_time screensaver moused. Additional ABI support: linux. Local package initialization:. Additional TCP options:. FreeBSD/i386 (k6-2.example.com) (ttyv0) login: rpratt Password:

Generating the RSA and DSA keys may take some time on slower machines. This happens only on the initial boot-up of a new installation. Subsequent boots will be faster.

If Xorg has been configured and a default desktop chosen, it can be started by typing startx at the command line.

3.10.16. FreeBSD Shutdown

It is important to properly shutdown the operating system. Do not just turn off the power. First, become the superuser using su(1) and entering the root password. This will work only if the user is a member of wheel. Otherwise, login as root. To shutdown the system, type shutdown -h now.

The operating system has halted. Please press any key to reboot.

It is safe to turn off the power after the shutdown command has been issued and the message Please press any key to reboot appears. If any key is pressed instead of turning off the power switch, the system will reboot.

The Ctrl+Alt+Del key combination can also be used to reboot the system; however, this is not recommended.

3.11. Troubleshooting

This section covers basic installation troubleshooting of common problems. There are also a few questions and answers for people wishing to dual-boot FreeBSD with Windows®.

3.11.1. If Something Goes Wrong

Due to various limitations of the PC architecture, it is impossible for device probing to be 100% reliable. However, there are a few things to try if it fails.

Check the Hardware Notes document for the version of FreeBSD to make sure the hardware is supported.

If the hardware is supported but still experiences lock-ups or other problems, build a custom kernel to add in support for devices which are not present in the GENERIC kernel. The default kernel assumes that most hardware devices are in their factory default configuration in terms of IRQs, I/O addresses, and DMA channels. If the hardware has been reconfigured, create a custom kernel configuration file and recompile to tell FreeBSD where to find things.

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.

Note:

Some installation problems can be avoided or alleviated by updating the firmware on various hardware components, most notably the motherboard BIOS. Most motherboard and computer manufacturers have a website where upgrade information may be located.

Most manufacturers strongly advise against upgrading the motherboard BIOS unless there is a good reason for doing so, such as a critical update. The upgrade process can go wrong, causing permanent damage to the BIOS chip.

3.11.2. Using Windows® Filesystems

At this time, FreeBSD does not support file systems compressed with the Double Space™ application. Therefore the file system will need to be uncompressed before FreeBSD can access the data. This can be done by running the Compression Agent located in the Start> Programs > System Tools menu.

FreeBSD can support MS-DOS® file systems (sometimes called FAT file systems). The mount_msdosfs(8) command grafts such file systems onto the existing directory hierarchy, allowing the file system's contents to be accessed. The mount_msdosfs(8) program is not usually invoked directly; instead, it is called by the system through a line in /etc/fstab or by using mount(8) with the appropriate parameters.

A typical line in /etc/fstab is:

/dev/ad0sN /dos msdosfs rw 0 0

Note:

/dos must already exist for this to work. For details about the format of /etc/fstab, see fstab(5).

A typical call to mount(8) for a FAT filesystem looks like:

# mount -t msdosfs /dev/ad0s1 /mnt

In this example, the FAT filesystem is located on the first partition of the primary hard disk. The output from dmesg(8) and mount(8) should produce enough information to give an idea of the partition layout.

Note:

FreeBSD may number FAT partitions differently than other operating systems. In particular, extended partitions are usually given higher slice numbers than primary partitions. Use fdisk(8) to help determine which slices belong to FreeBSD and which belong to other operating systems.

NTFS partitions can also be mounted in a similar manner using mount_ntfs(8).

3.11.3. Troubleshooting Questions and Answers

3.11.3.1. My system hangs while probing hardware during boot or it behaves strangely during install.
3.11.3.2. When booting from the hard disk for the first time after installing FreeBSD, the kernel loads and probes hardware, but stops with messages like:
3.11.3.3. When booting from the hard disk for the first time after installing FreeBSD, the Boot Manager prompt just prints F? at the boot menu and the boot will not go any further.
3.11.3.4. The system finds the ed(4) network card but continuously displays device timeout errors.
3.11.3.5. When sysinstall(8) is used in an Xorg terminal, the yellow font is difficult to read against the light gray background. Is there a way to provide higher contrast for this application?

3.11.3.1.

My system hangs while probing hardware during boot or it behaves strangely during install.

FreeBSD makes extensive use of the system ACPI service on the i386, amd64, and ia64 platforms to aid in system configuration if it is detected during boot. Unfortunately, some bugs still exist in the ACPI driver and various system motherboards. The use of ACPI can be disabled by setting hint.acpi.0.disabled in the third stage boot loader:

set hint.acpi.0.disabled="1"

This is reset each time the system is booted, so it is necessary to add hint.acpi.0.disabled="1" to /boot/loader.conf to make this change permanent. More information about the boot loader can be found in Section 13.1, “Synopsis”.

3.11.3.2.

When booting from the hard disk for the first time after installing FreeBSD, the kernel loads and probes hardware, but stops with messages like:

changing root device to ad1s1a panic: cannot mount root

What is wrong?

This can occur when the boot disk is not the first disk in the system. The BIOS uses a different numbering scheme to FreeBSD, and working out which numbers correspond to which is difficult to get right.

If this occurs, tell FreeBSD where the root filesystem is by specifying the BIOS disk number, the disk type, and the FreeBSD disk number for that type.

Consider two IDE disks, each configured as the master on their respective IDE bus, where FreeBSD should be booted from the second disk. The BIOS sees these as disk 0 and disk 1, while FreeBSD sees them as ad0 and ad2.

If FreeBSD is on BIOS disk 1, of type ad and the FreeBSD disk number is 2, this is the correct value:

1:ad(2,a)kernel

Note that if there is a slave on the primary bus, the above is not necessary and is effectively wrong.

The second situation involves booting from a SCSI disk when there are one or more IDE disks in the system. In this case, the FreeBSD disk number is lower than the BIOS disk number. For two IDE disks and a SCSI disk, where the SCSI disk is BIOS disk 2, type da, and FreeBSD disk number 0, the correct value is:

2:da(0,a)kernel

This tells FreeBSD to boot from BIOS disk 2, which is the first SCSI disk in the system. If there is only IDE disk, use 1: instead.

Once the correct value to use is determined, put the command in /boot.config using a text editor. Unless instructed otherwise, FreeBSD will use the contents of this file as the default response to the boot: prompt.

3.11.3.3.

When booting from the hard disk for the first time after installing FreeBSD, the Boot Manager prompt just prints F? at the boot menu and the boot will not go any further.

The hard disk geometry was set incorrectly in the partition editor when FreeBSD was installed. Go back into the partition editor and specify the actual geometry of the hard disk. FreeBSD must be reinstalled again from the beginning with the correct geometry.

For a dedicated FreeBSD system that does not need future compatibility with another operating system, use the entire disk by selecting A in the installer's partition editor.

3.11.3.4.

The system finds the ed(4) network card but continuously displays device timeout errors.

The card is probably on a different IRQ from what is specified in /boot/device.hints. The ed(4) driver does not use software configuration by default, but it will if -1 is specified in the hints for the interface.

Either move the jumper on the card to the configuration setting or specify the IRQ as -1 by setting the hint hint.ed.0.irq="-1". This tells the kernel to use the software configuration.

Another possibility is that the card is at IRQ 9, which is shared by IRQ 2 and frequently a cause of problems, especially if a VGA card is using IRQ 2. Do not use IRQ 2 or 9 if at all possible.

3.11.3.5.

When sysinstall(8) is used in an Xorg terminal, the yellow font is difficult to read against the light gray background. Is there a way to provide higher contrast for this application?

If the default colors chosen by sysinstall(8) make text illegible while using x11/xterm or x11/rxvt, add the following to ~/.Xdefaults to get a darker background gray: XTerm*color7: #c0c0c0

3.12. Advanced Installation Guide

Contributed by Valentino Vaschetto.
Updated by Marc Fonvieille.

This section describes how to install FreeBSD in exceptional cases.

3.12.1. Installing FreeBSD on a System Without a Monitor or Keyboard

This type of installation is called a headless install because the machine to be installed does not have either an attached monitor or a VGA output. This type of installation is possible using a serial console, another machine which acts as the main display and keyboard. To do this, follow the steps to create an installation USB stick, explained in Section 3.3.7, “Prepare the Boot Media”, or download the correct installation ISO image as described in Section 3.13.1, “Creating an Installation ISO”.

To modify the installation media to boot into a serial console, follow these steps. If using a CD/DVD media, skip the first step):

  1. Enabling the Installation USB Stick to Boot into a Serial Console

    By default, booting into the USB stick boots into the installer. To instead boot into a serial console, mount the USB disk onto a FreeBSD system using mount(8):

    # mount /dev/da0a /mnt

    Note:

    Adapt the device node and the mount point to the situation.

    Once the USB stick is mounted, set it to boot into a serial console. Add this line to /boot/loader.conf on the USB stick:

    # echo 'console="comconsole"' >> /mnt/boot/loader.conf

    Now that the USB is stick configured correctly, unmount the disk using umount(8):

    # umount /mnt

    Now, unplug the USB stick and jump directly to the third step of this procedure.

  2. Enabling the Installation CD/DVD to Boot into a Serial Console

    By default, when booting into the installation CD/DVD, FreeBSD boots into its normal install mode. To instead boot into a serial console, extract, modify, and regenerate the ISO image before burning it to the CD/DVD media.

    From the FreeBSD system with the saved installation ISO image, use tar(1) to extract all the files:

    # mkdir /path/to/headless-iso # tar -C /path/to/headless-iso -pxvf FreeBSD-9.1-RELEASE-i386-disc1.iso

    Next, set the installation media to boot into a serial console. Add this line to the /boot/loader.conf of the extracted ISO image:

    # echo 'console="comconsole"' >> /path/to/headless-iso/boot/loader.conf

    Then, create a new ISO image from the modified tree. This example uses mkisofs(8) from the sysutils/cdrtools package or port:

    # mkisofs -v -b boot/cdboot -no-emul-boot -r -J -V "Headless_install" \ -o Headless-FreeBSD-8.4-RELEASE-i386-disc1.iso/path/to/headless-iso

    Now that the ISO image is configured correctly, burn it to a CD/DVD media using a burning application.

  3. Connecting the Null-modem Cable

    Connect a null-modem cable to the serial ports of the two machines. A normal serial cable will not work. A null-modem cable is required.

  4. Booting Up for the Install

    It is now time to go ahead and start the install. Plug in the USB stick or insert the CD/DVD media in the headless install machine and power it on.

  5. Connecting to the Headless Machine

    Next, connect to that machine with cu(1):

    # cu -l /dev/cuau0

The headless machine can now be controlled using cu(1). It will load the kernel and then dispaly a selection of which type of terminal to use. Select the FreeBSD color console and proceed with the installation.

3.13. Preparing Custom Installation Media

Some situations may require a customized FreeBSD installation media and/or source. This might be physical media or a source that sysinstall(8) can use to retrieve the installation files. Some example situations include:

  • A local network with many machines has a private FTP server hosting the FreeBSD installation files which the machines should use for installation.

  • FreeBSD does not recognize the CD/DVD drive but Windows® does. In this case, copy the FreeBSD installation files to a Windows® partition on the same computer, and then install FreeBSD using those files.

  • The computer to install does not have a CD/DVD drive or a network card, but can be connected using a null-printer cable to a computer that does.

  • A tape will be be used to install FreeBSD.

3.13.1. Creating an Installation ISO

As part of each release, the FreeBSD Project provides ISO images for each supported architecture. These images can be written (burned) to CD or DVD media using a burning application, and then used to install FreeBSD. If a CD/DVD writer is available, this is the easiest way to install FreeBSD.

  1. Download the Correct ISO Images

    The ISO images for each release can be downloaded from ftp://ftp.FreeBSD.org/pub/FreeBSD/ISO-IMAGES-arch/version or the closest mirror. or the closest mirror. Substitute arch and version as appropriate.

    An image directory normally contains the following images:

    Table 3.4. FreeBSD ISO Image Names and Meanings
    FilenameContents
    FreeBSD-version-RELEASE-arch-bootonly.isoThis CD image starts the installation process by booting from a CD-ROM drive but it does not contain the support for installing FreeBSD from the CD itself. Perform a network based install, such as from an FTP server, after booting from this CD.
    FreeBSD-version-RELEASE-arch-dvd1.iso.gzThis DVD image contains everything necessary to install the base FreeBSD operating system, a collection of pre-built packages, and the documentation. It also supports booting into a livefs based rescue mode.
    FreeBSD-version-RELEASE-arch-memstick.imgThis image can be written to an USB memory stick in order to install machines capable of booting from USB drives. It also supports booting into a livefs based rescue mode. The only included package is the documentation package.
    FreeBSD-version-RELEASE-arch-disc1.isoThis CD image contains the base FreeBSD operating system and the documentation package but no other packages.
    FreeBSD-version-RELEASE-arch-disc2.isoA CD image with as many third-party packages as would fit on the disc. This image is not available for FreeBSD 9.X.
    FreeBSD-version-RELEASE-arch-disc3.isoAnother CD image with as many third-party packages as would fit on the disc. This image is not available for FreeBSD 9.X.
    FreeBSD-version-RELEASE-arch-livefs.isoThis CD image contains support for booting into a livefs based rescue mode but does not support doing an install from the CD itself.

    When performing a CD installation, download either the bootonly ISO image or disc1. Do not download both, since disc1 contains everything that the bootonly ISO image contains.

    Use the bootonly ISO to perform a network install over the Internet. Additional software can be installed as needed using the Ports Collection as described in Chapter 5, Installing Applications: Packages and Ports.

    Use dvd1 to install FreeBSD and a selection of third-party packages from the disc.

  2. Burn the Media

    Next, write the downloaded image(s) to disc. If using another FreeBSD system, refer to Section 19.5.3, “burncd and Section 19.5.4, “cdrecord for instructions.

    If using another platform, use any burning utility that exists for that platform. The images are in the standard ISO format which most CD writing applications support.

Note:

To build a customized release of FreeBSD, refer to the Release Engineering Article.

3.13.2. Creating a Local FTP Site with a FreeBSD Disc

FreeBSD discs are laid out in the same way as the FTP site. This makes it easy to create a local FTP site that can be used by other machines on a network to install FreeBSD.

  1. On the FreeBSD computer that will host the FTP site, ensure that the CD/DVD is in the drive and mounted:

    # mount /cdrom
  2. Create an account for anonymous FTP. Use vipw(8) to insert this line:

    ftp:*:99:99::0:0:FTP:/cdrom:/nonexistent
  3. Ensure that the FTP service is enabled in /etc/inetd.conf.

Anyone with network connectivity to the machine can now chose a media type of FTP and type in ftp://your machine after picking Other in the FTP sites menu during the install.

Note:

If the boot media for the FTP clients is not precisely the same version as that provided by the local FTP site, sysinstall(8) will not complete the installation. To override this, go into the Options menu and change the distribution name to any.

Warning:

This approach is acceptable for a machine on the local network which is protected by a firewall. Offering anonymous FTP services to other machines over the Internet exposes the computer to increased security risks. It is strongly recommended to follow good security practices when providing services over the Internet.

3.13.3. Installing from an Windows® Partition

To prepare for an installation from a Windows® partition, copy the files from the distribution into a directory in the root directory of the partition, such as c:\freebsd. Since the directory structure must be reproduced, it is recommended to use robocopy when copying from a CD/DVD. For example, to prepare for a minimal installation of FreeBSD:

C:\> md c:\freebsd C:\> robocopy e:\bin c:\freebsd\bin\ /s C:\> robocopy e:\manpages c:\freebsd\manpages\ /s

This example assumes that C: has enough free space and E: is where the CD/DVD is mounted.

Alternatively, download the distribution from ftp.FreeBSD.org. Each distribution is in its own directory; for example, the base distribution can be found in the 8.4/base/ directory.

Copy the distributions to install from a Windows® partition to c:\freebsd. Both the base and kernel distributions are needed for the most minimal installation.

3.13.4. Before Installing over a Network

There are three types of network installations available: Ethernet, PPP, and PLIP.

For the fastest possible network installation, use an Ethernet adapter. FreeBSD supports most common Ethernet cards. A list of supported cards is provided in the Hardware Notes for each release of FreeBSD. If using a supported PCMCIA Ethernet card, be sure that it is plugged in before the system is powered on as FreeBSD does not support hot insertion of PCMCIA cards during installation.

Make note of the system's IP address, subnet mask, hostname, default gateway address, and DNS server addresses if these values are statically assigned. If installing by FTP through a HTTP proxy, make note of the proxy's address. If you do not know these values, ask the system administrator or ISP before trying this type of installation.

If using a dialup modem, have the service provider's PPP information handy as it is needed early in the installation process.

If PAP or CHAP are used to connect to the ISP without using a script, type dial at the FreeBSD ppp prompt. Otherwise, know how to dial the ISP using the AT commands specific to the modem, as the PPP dialer provides only a simple terminal emulator. Refer to Section 27.2, “Using User PPP” and ../../../../doc/en_US.ISO8859-1/books/faq/ppp.html for further information. Logging can be directed to the screen using set log local ....

If a hard-wired connection to another FreeBSD machine is available, the installation can occur over a null-modem parallel port cable. The data rate over the parallel port is higher than what is typically possible over a serial line.

3.13.4.1. Before Installing via NFS

To perform an NFS installation, copy the needed FreeBSD distribution files to an NFS server and then point the installer's NFS media selection to it.

If the server supports only a privileged port, set the option NFS Secure in the Options menu so that the installation can proceed.

If using a poor quality Ethernet card which suffers from slow transfer rates, toggle the NFS Slow flag to on.

In order for an NFS installation to work, the server must support subdir mounts. For example, if the FreeBSD 9.1 distribution lives on: ziggy:/usr/archive/stuff/FreeBSD, ziggy will have to allow the direct mounting of /usr/archive/stuff/FreeBSD, not just /usr or /usr/archive/stuff.

In FreeBSD, this is controlled by using -alldirs in /etc/exports. Other NFS servers may have different conventions. If the server is displaying permission denied messages, it is likely that this is not enabled properly.

Chapter 4. UNIX Basics

Rewritten by Chris Shumway.

4.1. Synopsis

This chapter covers the basic commands and functionality of the FreeBSD operating system. Much of this material is relevant for any UNIX®-like operating system. New FreeBSD users are encouraged to read through this chapter carefully.

After reading this chapter, you will know:

  • How to use the virtual consoles of FreeBSD.

  • How UNIX® file permissions and FreeBSD file flags work.

  • The default FreeBSD file system layout.

  • The FreeBSD disk organization.

  • How to mount and unmount file systems.

  • What processes, daemons, and signals are.

  • What a shell is, and how to change the default login environment.

  • How to use basic text editors.

  • What devices and device nodes are.

  • How to read manual pages for more information.

4.2. Virtual Consoles and Terminals

FreeBSD can be used in various ways. One of them is typing commands to a text terminal. A lot of the flexibility and power of a UNIX® operating system is readily available when using FreeBSD this way. This section describes what terminals and consoles are, and how to use them in FreeBSD.

4.2.1. The Console

Unless FreeBSD has been configured to automatically start a graphical environment during startup, the system will boot into a command line login prompt, as seen in this example:

FreeBSD/amd64 (pc3.example.org) (ttyv0) login:

The first line contains some information about the system. The amd64 indicates that the system in this example is running a 64-bit version of FreeBSD. The hostname is pc3.example.org, and ttyv0 indicates that this is the system console.

The second line is the login prompt. The next section describes how to log into FreeBSD at this prompt.

4.2.2. Logging into FreeBSD

FreeBSD is a multiuser, multiprocessing system. This is the formal description that is usually given to a system that can be used by many different people, who simultaneously run a lot of programs on a single machine.

Every multiuser system needs some way to distinguish one user from the rest. In FreeBSD (and all the UNIX®-like operating systems), this is accomplished by requiring that every user must log into the system before being able to run programs. Every user has a unique name (the username) and a personal, secret key (the password). FreeBSD will ask for these two before allowing a user to run any programs.

When a FreeBSD system boots, startup scripts are automatically executed in order to prepare the system and to start any services which have been configured to start at system boot. Once the system finishes running its startup scripts, it will present a login prompt:

login:

Type the username that was configured during system installation, as described in Section 2.9.6, “Add Users”, and press Enter. Then enter the password associated with the username and press Enter. The password is not echoed for security reasons.

Once the correct password is input, the message of the day (MOTD) will be displayed followed by a command prompt (a #, $, or % character). You are now logged into the FreeBSD console and ready to try the available commands.

4.2.3. Virtual Consoles

FreeBSD can be configured to provide many virtual consoles for inputting commands. Each virtual console has its own login prompt and output channel, and FreeBSD takes care of properly redirecting keyboard input and monitor output as switching occurs between virtual consoles.

Special key combinations have been reserved by FreeBSD for switching consoles.[1]. Use Alt+F1, Alt+F2, through Alt+F8 to switch to a different virtual console in FreeBSD.

When switching from one console to the next, FreeBSD takes care of saving and restoring the screen output. The result is an illusion of having multiple virtual screens and keyboards that can be used to type commands for FreeBSD to run. The programs that are launched in one virtual console do not stop running when that console is not visible because the user has switched to a different virtual console.

4.2.4. The /etc/ttys File

By default, FreeBSD is configured to start eight virtual consoles. The configuration can be customized to start more or fewer virtual consoles. To change the number of and the settings of the virtual consoles, edit /etc/ttys.

Each uncommented line in /etc/ttys (lines that do not start with a # character) contains settings for a single terminal or virtual console. The default version configures nine virtual consoles, and enables eight of them. They are the lines that start with ttyv:

# name getty type status comments # ttyv0 "/usr/libexec/getty Pc" cons25 on secure # Virtual terminals ttyv1 "/usr/libexec/getty Pc" cons25 on secure ttyv2 "/usr/libexec/getty Pc" cons25 on secure ttyv3 "/usr/libexec/getty Pc" cons25 on secure ttyv4 "/usr/libexec/getty Pc" cons25 on secure ttyv5 "/usr/libexec/getty Pc" cons25 on secure ttyv6 "/usr/libexec/getty Pc" cons25 on secure ttyv7 "/usr/libexec/getty Pc" cons25 on secure ttyv8 "/usr/X11R6/bin/xdm -nodaemon" xterm off secure

For a detailed description of every column in this file and the available options for the virtual consoles, refer to ttys(5).

4.2.5. Single User Mode Console

A detailed description of single user mode can be found in Section 13.6.2, “Single-User Mode”. There is only one console when FreeBSD is in single user mode as no other virtual consoles are available in this mode. The settings for single user mode are found in this section of /etc/ttys:

# name getty type status comments # # If console is marked "insecure", then init will ask for the root password # when going to single-user mode. console none unknown off secure

Note:

As the comments above the console line indicate, editing secure to insecure will prompt for the root password when booting into single user mode. The default setting enters single user mode without prompting for a password.

Be careful when changing this setting to insecure. If the root password is forgotten, booting into single user mode is still possible, but may be difficult for someone who is not comfortable with the FreeBSD booting process.

4.2.6. Changing Console Video Modes

The FreeBSD console default video mode may be adjusted to 1024x768, 1280x1024, or any other size supported by the graphics chip and monitor. To use a different video mode load the VESA module:

# kldload vesa

To determine which video modes are supported by the hardware, use vidcontrol(1). To get a list of supported video modes issue the following:

# vidcontrol -i mode

The output of this command lists the video modes that are supported by the hardware. To select a new video mode, specify the mode using vidcontrol(1) as the root user:

# vidcontrol MODE_279

If the new video mode is acceptable, it can be permanently set on boot by adding it to /etc/rc.conf:

allscreens_flags="MODE_279"

4.3. Permissions

FreeBSD, being a direct descendant of BSD UNIX®, is based on several key UNIX® concepts. The first and most pronounced is that FreeBSD is a multi-user operating system that can handle several users working simultaneously on completely unrelated tasks. The system is responsible for properly sharing and managing requests for hardware devices, peripherals, memory, and CPU time fairly to each user.

Much more information about user accounts is in the chapter about accounts. It is important to understand that each person (user) who uses the computer should be given their own username and password. The system keeps track of the people using the computer based on this username. Since it is often the case that several people are working on the same project UNIX® also provides groups. Several users can be placed in the same group.

Because the system is capable of supporting multiple users, everything the system manages has a set of permissions governing who can read, write, and execute the resource. These permissions are stored as three octets broken into three pieces, one for the owner of the file, one for the group that the file belongs to, and one for everyone else. This numerical representation works like this:

Note:

This section will discuss the traditional UNIX® permissions. For finer grained file system access control, see the File System Access Control Lists section.

ValuePermissionDirectory Listing
0No read, no write, no execute---
1No read, no write, execute--x
2No read, write, no execute-w-
3No read, write, execute-wx
4Read, no write, no executer--
5Read, no write, executer-x
6Read, write, no executerw-
7Read, write, executerwx

Use the -l argument to ls(1) to view a long directory listing that includes a column of information about a file's permissions for the owner, group, and everyone else. For example, a ls -l in an arbitrary directory may show:

% ls -l total 530 -rw-r--r-- 1 root wheel 512 Sep 5 12:31 myfile -rw-r--r-- 1 root wheel 512 Sep 5 12:31 otherfile -rw-r--r-- 1 root wheel 7680 Sep 5 12:31 email.txt

The first (leftmost) character in the first column indicates whether this file is a regular file, a directory, a special character device, a socket, or any other special pseudo-file device. In this example, the - indicates a regular file. The next three characters, rw- in this example, give the permissions for the owner of the file. The next three characters, r--, give the permissions for the group that the file belongs to. The final three characters, r--, give the permissions for the rest of the world. A dash means that the permission is turned off. In this example, the permissions are set so the owner can read and write to the file, the group can read the file, and the rest of the world can only read the file. According to the table above, the permissions for this file would be 644, where each digit represents the three parts of the file's permission.

How does the system control permissions on devices? FreeBSD treats most hardware devices as a file that programs can open, read, and write data to. These special device files are stored in /dev/.

Directories are also treated as files. They have read, write, and execute permissions. The executable bit for a directory has a slightly different meaning than that of files. When a directory is marked executable, it means it is possible to change into that directory using cd(1). This also means that it is possible to access the files within that directory, subject to the permissions on the files themselves.

In order to perform a directory listing, the read permission must be set on the directory. In order to delete a file that one knows the name of, it is necessary to have write and execute permissions to the directory containing the file.

There are more permission bits, but they are primarily used in special circumstances such as setuid binaries and sticky directories. For more information on file permissions and how to set them, refer to chmod(1).

4.3.1. Symbolic Permissions

Contributed by Tom Rhodes.

Symbolic permissions use characters instead of octal values to assign permissions to files or directories. Symbolic permissions use the syntax of (who) (action) (permissions), where the following values are available:

OptionLetterRepresents
(who)uUser
(who)gGroup owner
(who)oOther
(who)aAll (world)
(action)+Adding permissions
(action)-Removing permissions
(action)=Explicitly set permissions
(permissions)rRead
(permissions)wWrite
(permissions)xExecute
(permissions)tSticky bit
(permissions)sSet UID or GID

These values are used with chmod(1), but with letters instead of numbers. For example, the following command would block other users from accessing FILE:

% chmod go= FILE

A comma separated list can be provided when more than one set of changes to a file must be made. For example, the following command removes the group and world write permission on FILE, and adds the execute permissions for everyone:

% chmod go-w,a+x FILE

4.3.2. FreeBSD File Flags

Contributed by Tom Rhodes.

In addition to file permissions, FreeBSD supports the use of file flags. These flags add an additional level of security and control over files, but not directories. With file flags, even root can be prevented from removing or altering files.

File flags are modified using chflags(1). For example, to enable the system undeletable flag on the file file1, issue the following command:

# chflags sunlink file1

To disable the system undeletable flag, put a no in front of the sunlink:

# chflags nosunlink file1

To view the flags of a file, use -lo with ls(1):

# ls -lo file1
-rw-r--r-- 1 trhodes trhodes sunlnk 0 Mar 1 05:54 file1

Several file flags may only be added or removed by the root user. In other cases, the file owner may set its file flags. Refer to chflags(1) and chflags(2) for more information.

4.3.3. The setuid, setgid, and sticky Permissions

Contributed by Tom Rhodes.

Other than the permissions already discussed, there are three other specific settings that all administrators should know about. They are the setuid, setgid, and sticky permissions.

These settings are important for some UNIX® operations as they provide functionality not normally granted to normal users. To understand them, the difference between the real user ID and effective user ID must be noted.

The real user ID is the UID who owns or starts the process. The effective UID is the user ID the process runs as. As an example, passwd(1) runs with the real user ID when a user changes their password. However, in order to update the password database, the command runs as the effective ID of the root user. This allows users to change their passwords without seeing a Permission Denied error.

The setuid permission may be set by prefixing a permission set with the number four (4) as shown in the following example:

# chmod 4755 suidexample.sh

The permissions on suidexample.sh now look like the following:

-rwsr-xr-x 1 trhodes trhodes 63 Aug 29 06:36 suidexample.sh

Note that a s is now part of the permission set designated for the file owner, replacing the executable bit. This allows utilities which need elevated permissions, such as passwd(1).

Note:

The nosuid mount(8) option will cause such binaries to silently fail without alerting the user. That option is not completely reliable as a nosuid wrapper may be able to circumvent it.

To view this in real time, open two terminals. On one, type passwd as a normal user. While it waits for a new password, check the process table and look at the user information for passwd(1):

In terminal A:

Changing local password for trhodes Old Password:

In terminal B:

# ps aux | grep passwd
trhodes 5232 0.0 0.2 3420 1608 0 R+ 2:10AM 0:00.00 grep passwd root 5211 0.0 0.2 3620 1724 2 I+ 2:09AM 0:00.01 passwd

Although passwd(1) is run as a normal user, it is using the effective UID of root.

The setgid permission performs the same function as the setuid permission; except that it alters the group settings. When an application or utility executes with this setting, it will be granted the permissions based on the group that owns the file, not the user who started the process.

To set the setgid permission on a file, provide chmod(1) with a leading two (2):

# chmod 2755 sgidexample.sh

In the following listing, notice that the s is now in the field designated for the group permission settings:

-rwxr-sr-x 1 trhodes trhodes 44 Aug 31 01:49 sgidexample.sh

Note:

In these examples, even though the shell script in question is an executable file, it will not run with a different EUID or effective user ID. This is because shell scripts may not access the setuid(2) system calls.

The setuid and setgid permission bits may lower system security, by allowing for elevated permissions. The third special permission, the sticky bit, can strengthen the security of a system.

When the sticky bit is set on a directory, it allows file deletion only by the file owner. This is useful to prevent file deletion in public directories, such as /tmp, by users who do not own the file. To utilize this permission, prefix the permission set with a one (1):

# chmod 1777 /tmp

The sticky bit permission will display as a t at the very end of the permission set:

# ls -al / | grep tmp
drwxrwxrwt 10 root wheel 512 Aug 31 01:49 tmp

4.4. Directory Structure

The FreeBSD directory hierarchy is fundamental to obtaining an overall understanding of the system. The most important directory is root or, /. This directory is the first one mounted at boot time and it contains the base system necessary to prepare the operating system for multi-user operation. The root directory also contains mount points for other file systems that are mounted during the transition to multi-user operation.

A mount point is a directory where additional file systems can be grafted onto a parent file system (usually the root file system). This is further described in Section 4.5, “Disk Organization”. Standard mount points include /usr/, /var/, /tmp/, /mnt/, and /cdrom/. These directories are usually referenced to entries in /etc/fstab. This file is a table of various file systems and mount points and is read by the system. Most of the file systems in /etc/fstab are mounted automatically at boot time from the script rc(8) unless their entry includes noauto. Details can be found in Section 4.6.1, “The fstab File”.

A complete description of the file system hierarchy is available in hier(7). The following table provides a brief overview of the most common directories.

DirectoryDescription
/Root directory of the file system.
/bin/User utilities fundamental to both single-user and multi-user environments.
/boot/Programs and configuration files used during operating system bootstrap.
/boot/defaults/Default boot configuration files. Refer to loader.conf(5) for details.
/dev/Device nodes. Refer to intro(4) for details.
/etc/System configuration files and scripts.
/etc/defaults/Default system configuration files. Refer to rc(8) for details.
/etc/mail/Configuration files for mail transport agents such as sendmail(8).
/etc/namedb/named(8) configuration files.
/etc/periodic/Scripts that run daily, weekly, and monthly, via cron(8). Refer to periodic(8) for details.
/etc/ppp/ppp(8) configuration files.
/mnt/Empty directory commonly used by system administrators as a temporary mount point.
/proc/Process file system. Refer to procfs(5), mount_procfs(8) for details.
/rescue/Statically linked programs for emergency recovery as described in rescue(8).
/root/Home directory for the root account.
/sbin/System programs and administration utilities fundamental to both single-user and multi-user environments.
/tmp/Temporary files which are usually not preserved across a system reboot. A memory-based file system is often mounted at /tmp. This can be automated using the tmpmfs-related variables of rc.conf(5) or with an entry in /etc/fstab; refer to mdmfs(8) for details.
/usr/The majority of user utilities and applications.
/usr/bin/Common utilities, programming tools, and applications.
/usr/include/Standard C include files.
/usr/lib/Archive libraries.
/usr/libdata/Miscellaneous utility data files.
/usr/libexec/System daemons and system utilities executed by other programs.
/usr/local/Local executables and libraries. Also used as the default destination for the FreeBSD ports framework. Within /usr/local, the general layout sketched out by hier(7) for /usr should be used. Exceptions are the man directory, which is directly under /usr/local rather than under /usr/local/share, and the ports documentation is in share/doc/port.
/usr/obj/Architecture-specific target tree produced by building the /usr/src tree.
/usr/ports/The FreeBSD Ports Collection (optional).
/usr/sbin/System daemons and system utilities executed by users.
/usr/share/Architecture-independent files.
/usr/src/BSD and/or local source files.
/var/Multi-purpose log, temporary, transient, and spool files. A memory-based file system is sometimes mounted at /var. This can be automated using the varmfs-related variables in rc.conf(5) or with an entry in /etc/fstab; refer to mdmfs(8) for details.
/var/log/Miscellaneous system log files.
/var/mail/User mailbox files.
/var/spool/Miscellaneous printer and mail system spooling directories.
/var/tmp/Temporary files which are usually preserved across a system reboot, unless /var is a memory-based file system.
/var/yp/NIS maps.

4.5. Disk Organization

The smallest unit of organization that FreeBSD uses to find files is the filename. Filenames are case-sensitive, which means that readme.txt and README.TXT are two separate files. FreeBSD does not use the extension of a file to determine whether the file is a program, document, or some other form of data.

Files are stored in directories. A directory may contain no files, or it may contain many hundreds of files. A directory can also contain other directories, allowing a hierarchy of directories within one another in order to organize data.

Files and directories are referenced by giving the file or directory name, followed by a forward slash, /, followed by any other directory names that are necessary. For example, if the directory foo contains a directory bar which contains the file readme.txt, the full name, or path, to the file is foo/bar/readme.txt. Note that this is different from Windows® which uses \ to separate file and directory names. FreeBSD does not use drive letters, or other drive names in the path. For example, one would not type c:/foo/bar/readme.txt on FreeBSD.

Directories and files are stored in a file system. Each file system contains exactly one directory at the very top level, called the root directory for that file system. This root directory can contain other directories. One file system is designated the root file system or /. Every other file system is mounted under the root file system. No matter how many disks are on the FreeBSD system, every directory appears to be part of the same disk.

Consider three file systems, called A, B, and C. Each file system has one root directory, which contains two other directories, called A1, A2 (and likewise B1, B2 and C1, C2).

Call A the root file system. If ls(1) is used to view the contents of this directory, it will show two subdirectories, A1 and A2. The directory tree looks like this:

A file system must be mounted on to a directory in another file system. When mounting file system B on to the directory A1, the root directory of B replaces A1, and the directories in B appear accordingly:

Any files that are in the B1 or B2 directories can be reached with the path /A1/B1 or /A1/B2 as necessary. Any files that were in /A1 have been temporarily hidden. They will reappear if B is unmounted from A.

If B had been mounted on A2 then the diagram would look like this:

and the paths would be /A2/B1 and /A2/B2 respectively.

File systems can be mounted on top of one another. Continuing the last example, the C file system could be mounted on top of the B1 directory in the B file system, leading to this arrangement:

Or C could be mounted directly on to the A file system, under the A1 directory:

It is entirely possible to have one large root file system, and not need to create any others. There are some drawbacks to this approach, and one advantage.

Benefits of Multiple File Systems
  • Different file systems can have different mount options. For example, the root file system can be mounted read-only, making it impossible for users to inadvertently delete or edit a critical file. Separating user-writable file systems, such as /home, from other file systems allows them to be mounted nosuid. This option prevents the suid/guid bits on executables stored on the file system from taking effect, possibly improving security.

  • FreeBSD automatically optimizes the layout of files on a file system, depending on how the file system is being used. So a file system that contains many small files that are written frequently will have a different optimization to one that contains fewer, larger files. By having one big file system this optimization breaks down.

  • FreeBSD's file systems are robust if power is lost. However, a power loss at a critical point could still damage the structure of the file system. By splitting data over multiple file systems it is more likely that the system will still come up, making it easier to restore from backup as necessary.

Benefit of a Single File System
  • File systems are a fixed size. If you create a file system when you install FreeBSD and give it a specific size, you may later discover that you need to make the partition bigger. This is not easily accomplished without backing up, recreating the file system with the new size, and then restoring the backed up data.

    Important:

    FreeBSD features the growfs(8) command, which makes it possible to increase the size of file system on the fly, removing this limitation.

File systems are contained in partitions. This does not have the same meaning as the common usage of the term partition (for example, MS-DOS® partition), because of FreeBSD's UNIX® heritage. Each partition is identified by a letter from a through to h. Each partition can contain only one file system, which means that file systems are often described by either their typical mount point in the file system hierarchy, or the letter of the partition they are contained in.

FreeBSD also uses disk space for swap space to provide virtual memory. This allows your computer to behave as though it has much more memory than it actually does. When FreeBSD runs out of memory, it moves some of the data that is not currently being used to the swap space, and moves it back in (moving something else out) when it needs it.

Some partitions have certain conventions associated with them.

PartitionConvention
aNormally contains the root file system.
bNormally contains swap space.
cNormally the same size as the enclosing slice. This allows utilities that need to work on the entire slice, such as a bad block scanner, to work on the c partition. A file system would not normally be created on this partition.
dPartition d used to have a special meaning associated with it, although that is now gone and d may work as any normal partition.

Disks in FreeBSD are divided into slices, referred to in Windows® as partitions, which are numbered from 1 to 4. These are then divided into partitions, which contain file systems, and are labeled using letters.

Slice numbers follow the device name, prefixed with an s, starting at 1. So da0s1 is the first slice on the first SCSI drive. There can only be four physical slices on a disk, but there can be logical slices inside physical slices of the appropriate type. These extended slices are numbered starting at 5, so ad0s5 is the first extended slice on the first IDE disk. These devices are used by file systems that expect to occupy a slice.

Slices, dangerously dedicated physical drives, and other drives contain partitions, which are represented as letters from a to h. This letter is appended to the device name, so da0a is the a partition on the first da drive, which is dangerously dedicated. ad1s3e is the fifth partition in the third slice of the second IDE disk drive.

Finally, each disk on the system is identified. A disk name starts with a code that indicates the type of disk, and then a number, indicating which disk it is. Unlike slices, disk numbering starts at 0. Common codes are listed in Table 4.1, “Disk Device Codes”.

When referring to a partition, include the disk name, s, the slice number, and then the partition letter. Examples are shown in Example 4.1, “Sample Disk, Slice, and Partition Names”.

Example 4.2, “Conceptual Model of a Disk” shows a conceptual model of a disk layout.

When installing FreeBSD, configure the disk slices, create partitions within the slice to be used for FreeBSD, create a file system or swap space in each partition, and decide where each file system will be mounted.

Table 4.1. Disk Device Codes
CodeMeaning
adATAPI (IDE) disk
daSCSI direct access disk
acdATAPI (IDE) CDROM
cdSCSI CDROM
fdFloppy disk

Example 4.1. Sample Disk, Slice, and Partition Names
NameMeaning
ad0s1aThe first partition (a) on the first slice (s1) on the first IDE disk (ad0).
da1s2eThe fifth partition (e) on the second slice (s2) on the second SCSI disk (da1).

Example 4.2. Conceptual Model of a Disk

This diagram shows FreeBSD's view of the first IDE disk attached to the system. Assume that the disk is 4 GB in size, and contains two 2 GB slices (MS-DOS® partitions). The first slice contains a MS-DOS® disk, C:, and the second slice contains a FreeBSD installation. This example FreeBSD installation has three data partitions, and a swap partition.

The three partitions will each hold a file system. Partition a will be used for the root file system, e for the /var/ directory hierarchy, and f for the /usr/ directory hierarchy.


4.6. Mounting and Unmounting File Systems

The file system is best visualized as a tree, rooted, as it were, at /. /dev, /usr, and the other directories in the root directory are branches, which may have their own branches, such as /usr/local, and so on.

There are various reasons to house some of these directories on separate file systems. /var contains the directories log/, spool/, and various types of temporary files, and as such, may get filled up. Filling up the root file system is not a good idea, so splitting /var from / is often favorable.

Another common reason to contain certain directory trees on other file systems is if they are to be housed on separate physical disks, or are separate virtual disks, such as Network File System mounts, described in Section 29.3, “Network File System (NFS)”, or CDROM drives.

4.6.1. The fstab File

During the boot process (Chapter 13, The FreeBSD Booting Process), file systems listed in /etc/fstab are automatically mounted except for the entries containing noauto. This file contains entries in the following format:

device /mount-point fstype options dumpfreq passno
device

An existing device name as explained in Section 19.2, “Device Names”.

mount-point

An existing directory on which to mount the file system.

fstype

The file system type to pass to mount(8). The default FreeBSD file system is ufs.

options

Either rw for read-write file systems, or ro for read-only file systems, followed by any other options that may be needed. A common option is noauto for file systems not normally mounted during the boot sequence. Other options are listed in mount(8).

dumpfreq

Used by dump(8) to determine which file systems require dumping. If the field is missing, a value of zero is assumed.

passno

Determines the order in which file systems should be checked. File systems that should be skipped should have their passno set to zero. The root file system needs to be checked before everything else and should have its passno set to one. The other file systems should be set to values greater than one. If more than one file system has the same passno, fsck(8) will attempt to check file systems in parallel if possible.

Refer to fstab(5) for more information on the format of /etc/fstab and its options.

4.6.2. Using mount(8)

File systems are mounted using mount(8). The most basic syntax is as follows:

# mount device mountpoint

This command provides many options which are described in mount(8), The most commonly used options include:

Mount Options
-a

Mount all the file systems listed in /etc/fstab, except those marked as noauto, excluded by the -t flag, or those that are already mounted.

-d

Do everything except for the actual mount system call. This option is useful in conjunction with the -v flag to determine what mount(8) is actually trying to do.

-f

Force the mount of an unclean file system (dangerous), or the revocation of write access when downgrading a file system's mount status from read-write to read-only.

-r

Mount the file system read-only. This is identical to using -o ro.

-t fstype

Mount the specified file system type or mount only file systems of the given type, if -a is included. ufs is the default file system type.

-u

Update mount options on the file system.

-v

Be verbose.

-w

Mount the file system read-write.

The following options can be passed to -o as a comma-separated list:

nosuid

Do not interpret setuid or setgid flags on the file system. This is also a useful security option.

4.6.3. Using umount(8)

To unmount a file system use umount(8). This command takes one parameter which can be a mountpoint, device name, -a or -A.

All forms take -f to force unmounting, and -v for verbosity. Be warned that -f is not generally a good idea as it might crash the computer or damage data on the file system.

To unmount all mounted file systems, or just the file system types listed after -t, use -a or -A. Note that -A does not attempt to unmount the root file system.

4.7. Processes

FreeBSD is a multi-tasking operating system. Each program running at any one time is called a process. Every running command starts at least one new process and there are a number of system processes that are run by FreeBSD.

Each process is uniquely identified by a number called a process ID (PID). Similar to files, each process has one owner and group, and the owner and group permissions are used to determine which files and devices the process can open. Most processes also have a parent process that started them. For example, the shell is a process, and any command started in the shell is a process which has the shell as its parent process. The exception is a special process called init(8) which is always the first process to start at boot time and which always has a PID of 1.

To see the processes on the system, use ps(1) and top(1). To display a static list of the currently running processes, their PIDs, how much memory they are using, and the command they were started with, use ps(1). To display all the running processes and update the display every few seconds in order to interactively see what the computer is doing, use top(1).

By default, ps(1) only shows the commands that are running and owned by the user. For example:

% ps PID TT STAT TIME COMMAND 298 p0 Ss 0:01.10 tcsh 7078 p0 S 2:40.88 xemacs mdoc.xsl (xemacs-21.1.14) 37393 p0 I 0:03.11 xemacs freebsd.dsl (xemacs-21.1.14) 72210 p0 R+ 0:00.00 ps 390 p1 Is 0:01.14 tcsh 7059 p2 Is+ 1:36.18 /usr/local/bin/mutt -y 6688 p3 IWs 0:00.00 tcsh 10735 p4 IWs 0:00.00 tcsh 20256 p5 IWs 0:00.00 tcsh 262 v0 IWs 0:00.00 -tcsh (tcsh) 270 v0 IW+ 0:00.00 /bin/sh /usr/X11R6/bin/startx -- -bpp 16 280 v0 IW+ 0:00.00 xinit /home/nik/.xinitrc -- -bpp 16 284 v0 IW 0:00.00 /bin/sh /home/nik/.xinitrc 285 v0 S 0:38.45 /usr/X11R6/bin/sawfish

The output from ps(1) is organized into a number of columns. The PID column displays the process ID. PIDs are assigned starting at 1, go up to 99999, then wrap around back to the beginning. However, a PID is not reassigned if it is already in use. The TT column shows the tty the program is running on and STAT shows the program's state. TIME is the amount of time the program has been running on the CPU. This is usually not the elapsed time since the program was started, as most programs spend a lot of time waiting for things to happen before they need to spend time on the CPU. Finally, COMMAND is the command that was used to start the program.

ps(1) supports a number of different options to change the information that is displayed. One of the most useful sets is auxww. a displays information about all the running processes of all users. u displays the username of the process' owner, as well as memory usage. x displays information about daemon processes, and ww causes ps(1) to display the full command line for each process, rather than truncating it once it gets too long to fit on the screen.

The output from top(1) is similar. A sample session looks like this:

% top last pid: 72257; load averages: 0.13, 0.09, 0.03 up 0+13:38:33 22:39:10 47 processes: 1 running, 46 sleeping CPU states: 12.6% user, 0.0% nice, 7.8% system, 0.0% interrupt, 79.7% idle Mem: 36M Active, 5256K Inact, 13M Wired, 6312K Cache, 15M Buf, 408K Free Swap: 256M Total, 38M Used, 217M Free, 15% Inuse PID USERNAME PRI NICE SIZE RES STATE TIME WCPU CPU COMMAND 72257 nik 28 0 1960K 1044K RUN 0:00 14.86% 1.42% top 7078 nik 2 0 15280K 10960K select 2:54 0.88% 0.88% xemacs-21.1.14 281 nik 2 0 18636K 7112K select 5:36 0.73% 0.73% XF86_SVGA 296 nik 2 0 3240K 1644K select 0:12 0.05% 0.05% xterm 175 root 2 0 924K 252K select 1:41 0.00% 0.00% syslogd 7059 nik 2 0 7260K 4644K poll 1:38 0.00% 0.00% mutt ...

The output is split into two sections. The header (the first five lines) shows the PID of the last process to run, the system load averages (which are a measure of how busy the system is), the system uptime (time since the last reboot) and the current time. The other figures in the header relate to how many processes are running (47 in this case), how much memory and swap space has been used, and how much time the system is spending in different CPU states.

Below the header is a series of columns containing similar information to the output from ps(1), such as the PID, username, amount of CPU time, and the command that started the process. By default, top(1) also displays the amount of memory space taken by the process. This is split into two columns: one for total size and one for resident size. Total size is how much memory the application has needed and the resident size is how much it is actually using at the moment. In this example, mutt has required almost 8 MB of RAM, but is currently only using 5 MB.

top(1) automatically updates the display every two seconds. A different interval can be specified with -s.

4.8. Daemons, Signals, and Killing Processes

When using an editor, it is easy to control the editor and load files because the editor provides facilities to do so, and because the editor is attached to a terminal. Some programs are not designed to be run with continuous user input and disconnect from the terminal at the first opportunity. For example, a web server responds to web requests, rather than user input. Mail servers are another example of this type of application.

These programs are known as daemons. The term daemon comes from Greek mythology and represents an entity that is neither good or evil, and which invisibly performs useful tasks. This is why the BSD mascot is the cheerful-looking daemon with sneakers and a pitchfork.

There is a convention to name programs that normally run as daemons with a trailing d. BIND is the Berkeley Internet Name Domain, but the actual program that executes is named(8). The Apache web server program is httpd and the line printer spooling daemon is lpd(8). This is only a naming convention. For example, the main mail daemon for the Sendmail application is sendmail(8), and not maild.

One way to communicate with a daemon, or any running process, is to send a signal using kill(1). There are a number of different signals; some have a specific meaning while others are described in the application's documentation. A user can only send a signal to a process they own and sending a signal to someone else's process will result in a permission denied error. The exception is the root user, who can send signals to anyone's processes.

FreeBSD can also send a signal to a process. If an application is badly written and tries to access memory that it is not supposed to, FreeBSD will send the process the Segmentation Violation signal (SIGSEGV). If an application has used the alarm(3) system call to be alerted after a period of time has elapsed, it will be sent the Alarm signal (SIGALRM).

Two signals can be used to stop a process: SIGTERM and SIGKILL. SIGTERM is the polite way to kill a process as the process can read the signal, close any log files it may have open, and attempt to finish what it is doing before shutting down. In some cases, a process may ignore SIGTERM if it is in the middle of some task that can not be interrupted.

SIGKILL can not be ignored by a process. This is the I do not care what you are doing, stop right now signal. Sending a SIGKILL to a process will usually stop that process there and then.[2].

Other commonly used signals are SIGHUP, SIGUSR1, and SIGUSR2. These are general purpose signals and different applications will respond differently.

For example, after changing a web server's configuration file, the web server needs to be told to re-read its configuration. Restarting httpd would result in a brief outage period on the web server. Instead, send the daemon the SIGHUP signal. Be aware that different daemons will have different behavior, so refer to the documentation for the daemon to determine if SIGHUP will achieve the desired results.

Procedure 4.1. Sending a Signal to a Process

This example shows how to send a signal to inetd(8). The inetd(8) configuration file is /etc/inetd.conf, and inetd(8) will re-read this configuration file when it is sent a SIGHUP.

  1. Find the PID of the process to send the signal to using pgrep(1). In this example, the PID for inetd(8) is 198:

    % pgrep -l inetd 198 inetd -wW
  2. Use kill(1) to send the signal. Because inetd(8) is owned by root, use su(1) to become root first.

    % su Password: # /bin/kill -s HUP 198

    Like most UNIX® commands, kill(1) will not print any output if it is successful. If a signal is sent to a process not owned by that user, the message kill: PID: Operation not permitted will be displayed. Mistyping the PID will either send the signal to the wrong process, which could have negative results, or will send the signal to a PID that is not currently in use, resulting in the error kill: PID: No such process.

    Why Use /bin/kill?:

    Many shells provide kill as a built in command, meaning that the shell will send the signal directly, rather than running /bin/kill. Be aware that different shells have a different syntax for specifying the name of the signal to send. Rather than try to learn all of them, it can be simpler to use /bin/kill ... directly.

When sending other signals, substitute TERM or KILL in the command line as necessary.

Important:

Killing a random process on the system can be a bad idea. In particular, init(8), PID 1, is special. Running /bin/kill -s KILL 1 is a quick, and unrecommended, way to shutdown the system. Always double check the arguments to kill(1) before pressing Return.

4.9. Shells

FreeBSD provides a command line interface called a shell. A shell receives commands from the input channel and executes them. Many shells provide built in functions to help with everyday tasks such as file management, file globbing, command line editing, command macros, and environment variables. FreeBSD comes with several shells, including the Bourne shell (sh(1)) and the extended C shell (tcsh(1)). Other shells are available from the FreeBSD Ports Collection, such as zsh and bash.

The shell that is used is really a matter of taste. A C programmer might feel more comfortable with a C-like shell such as tcsh(1). A Linux® user might prefer bash. Each shell has unique properties that may or may not work with a user's preferred working environment, which is why there is a choice of which shell to use.

One common shell feature is filename completion. After a user types the first few letters of a command or filename and presses Tab, the shell will automatically complete the rest of the command or filename. Consider two files called foobar and foo.bar. To delete foo.bar, type rm fo[Tab].[Tab].

The shell should print out rm foo[BEEP].bar.

The [BEEP] is the console bell, which the shell used to indicate it was unable to complete the filename because there is more than one match. Both foobar and foo.bar start with fo. By typing ., then pressing Tab again, the shell would be able to fill in the rest of the filename.

Another feature of the shell is the use of environment variables. Environment variables are a variable/key pair stored in the shell's environment. This environment can be read by any program invoked by the shell, and thus contains a lot of program configuration. Here is a list of common environment variables and their meanings:

VariableDescription
USERCurrent logged in user's name.
PATHColon-separated list of directories to search for binaries.
DISPLAYNetwork name of the Xorg display to connect to, if available.
SHELLThe current shell.
TERMThe name of the user's type of terminal. Used to determine the capabilities of the terminal.
TERMCAPDatabase entry of the terminal escape codes to perform various terminal functions.
OSTYPEType of operating system.
MACHTYPEThe system's CPU architecture.
EDITORThe user's preferred text editor.
PAGERThe user's preferred text pager.
MANPATHColon-separated list of directories to search for manual pages.

How to set an environment variable differs between shells. In tcsh(1) and csh(1), use setenv to set environment variables. In sh(1) and bash, use export to set the current environment variables. This example sets the default EDITOR to /usr/local/bin/emacs for the tcsh(1) shell:

% setenv EDITOR /usr/local/bin/emacs

The equivalent command for bash would be:

% export EDITOR="/usr/local/bin/emacs"

To expand an environment variable in order to see its current setting, type a $ character in front of its name on the command line. For example, echo $TERM displays the current $TERM setting.

Shells treat special characters, known as meta-characters, as special representations of data. The most common meta-character is *, which represents any number of characters in a filename. Meta-characters can be used to perform filename globbing. For example, echo * is equivalent to ls(1) because the shell takes all the files that match * and echo(1) lists them on the command line.

To prevent the shell from interpreting a special character, escape it from the shell by starting it with a backslash (\). For example, echo $TERM prints the terminal setting whereas echo \$TERM literally prints the string $TERM.

4.9.1. Changing Your Shell

The easiest way to permanently change the default shell is to use chsh. Running this command will open the editor that is configured in the EDITOR environment variable, which by default is set to vi(1). Change the Shell: line to the full path of the new shell.

Alternately, use chsh -s which will set the specified shell without opening an editor. For example, to change the shell to bash:

% chsh -s /usr/local/bin/bash

Note:

The new shell must be present in /etc/shells. If the shell was installed from the FreeBSD Ports Collection as described in Chapter 5, Installing Applications: Packages and Ports, it should be automatically added to this file. If it is missing, add it using this command, replacing the path with the path of the shell:

# echo /usr/local/bin/bash >> /etc/shells

Then rerun chsh(1).

4.10. Text Editors

Most FreeBSD configuration is done by editing text files. Because of this, it is a good idea to become familiar with a text editor. FreeBSD comes with a few as part of the base system, and many more are available in the Ports Collection.

A simple editor to learn is ee(1), which stands for easy editor. To start this editor, type ee filename where filename is the name of the file to be edited. Once inside the editor, all of the commands for manipulating the editor's functions are listed at the top of the display. The caret ^ represents Ctrl, so ^e expands to Ctrl+e. To leave ee(1), press Esc, then choose the leave editor option from the main menu. The editor will prompt to save any changes if the file has been modified.

FreeBSD also comes with more powerful text editors, such as vi(1), as part of the base system. Other editors, like editors/emacs and editors/vim, are part of the FreeBSD Ports Collection. These editors offer more functionality at the expense of being a more complicated to learn. Learning a more powerful editor such as vim or Emacs can save more time in the long run.

Many applications which modify files or require typed input will automatically open a text editor. To alter the default editor used, set the EDITOR environment variable as described in Section 4.9, “Shells”.

4.11. Devices and Device Nodes

A device is a term used mostly for hardware-related activities in a system, including disks, printers, graphics cards, and keyboards. When FreeBSD boots, the majority of the boot messages refer to devices being detected. A copy of the boot messages are saved to /var/run/dmesg.boot.

Each device has a device name and number. For example, acd0 is the first IDE CD-ROM drive, while kbd0 represents the keyboard.

Most devices in a FreeBSD must be accessed through special files called device nodes, which are located in /dev.

4.12. For More Information

4.12.1. Manual Pages

The most comprehensive documentation on FreeBSD is in the form of manual pages. Nearly every program on the system comes with a short reference manual explaining the basic operation and available arguments. These manuals can be viewed using man:

% man command

where command is the name of the command to learn about. For example, to learn more about ls(1), type:

% man ls

The online manual is divided into numbered sections:

  1. User commands.

  2. System calls and error numbers.

  3. Functions in the C libraries.

  4. Device drivers.

  5. File formats.

  6. Games and other diversions.

  7. Miscellaneous information.

  8. System maintenance and operation commands.

  9. Kernel developers.

In some cases, the same topic may appear in more than one section of the online manual. For example, there is a chmod(1) user command and a chmod() system call. To tell man(1) which section to display, specify the section number:

% man 1 chmod

This will display the manual page for the user command chmod(1). References to a particular section of the online manual are traditionally placed in parenthesis in written documentation, so chmod(1) refers to the user command and chmod(2) refers to the system call.

If the command name is unknown, use man -k to search for keywords in the command descriptions:

% man -k mail

This command displays a list of commands that have the keyword mail in their descriptions. This is equivalent to using apropos(1).

To determine what the commands in /usr/bin do, type:

% cd /usr/bin % man -f *

or

% cd /usr/bin % whatis *

4.12.2. GNU Info Files

FreeBSD includes many applications and utilities produced by the Free Software Foundation (FSF). In addition to manual pages, these programs may include hypertext documents called info files. These can be viewed using info(1) or, if editors/emacs is installed, the info mode of emacs.

To use info(1), type:

% info

For a brief introduction, type h. For a quick command reference, type ?.



[1] Refer to syscons(4), atkbd(4), vidcontrol(1) and kbdcontrol(1) for a more technical description of the FreeBSD console and its keyboard drivers.

[2] There are a few tasks that can not be interrupted. For example, if the process is trying to read from a file that is on another computer on the network, and the other computer is unavailable, the process is said to be uninterruptible. Eventually the process will time out, typically after two minutes. As soon as this time out occurs the process will be killed.

Chapter 5. Installing Applications: Packages and Ports

5.1. Synopsis

FreeBSD is bundled with a rich collection of system tools as part of the base system. In addition, FreeBSD provides two complementary technologies for installing third-party software: the FreeBSD Ports Collection, for installing from source, and packages, for installing from pre-built binaries. Either method may be used to install software from local media or from the network.

After reading this chapter, you will know:

  • The difference between binary packages and ports.

  • How to find third-party software that has been ported to FreeBSD.

  • How to manage binary packages using the traditional package system.

  • How to manage binary packages using pkgng.

  • How to build third-party software from source using the Ports Collection.

  • How to find the files installed with the application for post-installation configuration.

  • What to do if a software installation fails.

5.2. Overview of Software Installation

The typical steps for installing third-party software on a UNIX® system include:

  1. Find and download the software, which might be distributed in source code format or as a binary.

  2. Unpack the software from its distribution format. This is typically a tarball compressed with compress(1), gzip(1), or bzip2(1).

  3. Locate the documentation in INSTALL, README or some file in a doc/ subdirectory and read up on how to install the software.

  4. If the software was distributed in source format, compile it. This may involve editing a Makefile or running a configure script.

  5. Test and install the software.

If the software package was not deliberately ported, or tested to work, on FreeBSD, the source code may need editing in order for it to install and run properly. At the time of this writing, over 24,000 third-party applications have been ported to FreeBSD.

FreeBSD provides two technologies which automate these steps.

A FreeBSD package contains pre-compiled copies of all the commands for an application, as well as any configuration files and documentation. A package can be manipulated with the traditional FreeBSD package management commands, such as pkg_add(1), or using the newer pkgng commands, such as pkg install.

A FreeBSD port is a collection of files designed to automate the process of compiling an application from source code. The files that comprise a port contain all the necessary information to automatically download, extract, patch, compile, and install the application.

The ports system can also be used to generate packages which can be manipulated with the FreeBSD package management commands.

Both packages and ports understand dependencies. If a package or port is used to install an application and a dependent library is not already installed, the library will automatically be installed first.

While the two technologies are similar, packages and ports each have their own strengths. Select the technology that meets your requirements for installing a particular application.

Package Benefits
  • A compressed package tarball is typically smaller than the compressed tarball containing the source code for the application.

  • Packages do not require compilation time. For large applications, such as Mozilla, KDE, or GNOME, this can be important on a slow system.

  • Packages do not require any understanding of the process involved in compiling software on FreeBSD.

Port Benefits
  • Packages are normally compiled with conservative options because they have to run on the maximum number of systems. By compiling from the port, one can change the compilation options.

  • Some applications have compile-time options relating to which features are installed. For example, Apache can be configured with a wide variety of different built-in options.

    In some cases, multiple packages will exist for the same application to specify certain settings. For example, Ghostscript is available as a ghostscript package and a ghostscript-nox11 package, depending on whether or not Xorg is installed. Creating multiple packages rapidly becomes impossible if an application has more than one or two different compile-time options.

  • The licensing conditions of some software forbid binary distribution. Such software must be distributed as source code which must be compiled by the end-user.

  • Some people do not trust binary distributions or prefer to read through source code in order to look for potential problems.

  • Source code is needed in order to apply custom patches.

To keep track of updated ports, subscribe to the FreeBSD ports mailing list and the FreeBSD ports bugs mailing list.

Warning:

Before installing any application, check http://vuxml.freebsd.org/ for security issues related to the application or install ports-mgmt/portaudit. Once installed, type portaudit -F -a to check all installed applications for known vulnerabilities.

The remainder of this chapter explains how to use packages and ports to install and manage third-party software on FreeBSD.

5.3. Finding Software

FreeBSD's list of available applications is growing all the time. There are a number of ways to find software to install:

  • The FreeBSD web site maintains an up-to-date searchable list of all the available applications, at http://www.FreeBSD.org/ports/. The ports can be searched by application name or by software category.

  • Dan Langille maintains FreshPorts.org which provides a comprehensive search utility and also tracks changes to the applications in the Ports Collection. Registered users can create a customized watch list in order to receive an automated email when their watched ports are updated.

  • If you do not know the name of an application, try using a site like Freecode.com to find an application, then check back at the FreeBSD site to see if the application has been ported yet.

  • If the Ports Collection is already installed, there are several methods to query the local version of the ports tree. To find out which category a port is in, type whereis file, where file is the program to be installed:

    # whereis lsof lsof: /usr/ports/sysutils/lsof

    Alternately, an echo(1) statement can be used:

    # echo /usr/ports/*/*lsof* /usr/ports/sysutils/lsof

    Note that this will also return any matched files downloaded into the /usr/ports/distfiles directory.

  • Another way to find software is by using the Ports Collection's built-in search mechanism. To use the search feature, cd to /usr/ports then run make search name=program-name where program-name is the name of the software. For example, to search for lsof:

    # cd /usr/ports # make search name=lsof Port: lsof-4.88.d,8 Path: /usr/ports/sysutils/lsof Info: Lists information about open files (similar to fstat(1)) Maint: ler@lerctr.org Index: sysutils B-deps: R-deps:

    Tip:

    The built-in search mechanism uses a file of index information. If a message indicates that the INDEX is required, run make fetchindex to download the current index file. With the INDEX present, make search will be able to perform the requested search.

    The Path: line indicates where to find the port.

    To receive less information, use the quicksearch feature:

    # cd /usr/ports # make quicksearch name=lsof Port: lsof-4.88.d,8 Path: /usr/ports/sysutils/lsof Info: Lists information about open files (similar to fstat(1))

    For more in-depth searching, use make search key=string or make quicksearch key=string, where string is some text to search for. The text can be in comments, descriptions, or dependencies in order to find ports which relate to a particular subject when the name of the program is unknown.

    When using search or quicksearch, the search string is case-insensitive. Searching for LSOF will yield the same results as searching for lsof.

5.4. Using Binary Packages

At the present time, FreeBSD is transitioning toward a new method of package management. Users may wish to investigate the benefits of using PKGng to manage third-party software on FreeBSD. This section describes the traditional method for managing binary packages and only applies to those users who have not yet migrated to the pkgng format.

This method of package management uses a package database directory, /var/db/pkg, to track installed software versions and the files installed with each application. Several utilities interact with the database directory and are used to manage binary packages. These commands begin with pkg_. This section provides an overview of the commands which are used to install, delete, and gather information about binary packages. Each command provides many switches to customize its operation. Refer to the listed man pages for more details and further usage examples.

5.4.1. Installing a Package

To install a binary package from a local FreeBSD media or a remote FreeBSD package server, use pkg_add(1). While a FreeBSD media can provide a source of local packages without requiring a network connection, it may not contain the latest versions of binary packages as new versions are always being rebuilt for the FreeBSD package servers. To install from a package server, always include -r (for remote) with pkg_add(1). This automatically determines the correct object format and release, and then fetches and installs the package from a package server without any further user intervention.

# pkg_add -r lsof

In this example, lsof is used without specifying a version number as the version is not included when the remote fetching feature is used. To specify an alternative FreeBSD FTP mirror, specify the mirror in the PACKAGESITE environment variable. pkg_add(1) uses fetch(3) to download files, which uses various environment variables, including FTP_PASSIVE_MODE, FTP_PROXY, and FTP_PASSWORD. You may need to set one or more of these if you are behind a firewall, or need to use an FTP/HTTP proxy. See fetch(3) for the complete list of FTP-related variables.

Note:

pkg_add(1) will automatically download the latest version of the application if you are using FreeBSD-CURRENT or FreeBSD-STABLE. If you run a -RELEASE version, it instead installs the version of the package that was built with that release. It is possible to change this behavior by overriding PACKAGESITE. For example, on a FreeBSD 9.1-RELEASE system, by default pkg_add(1) will try to fetch packages from ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-9.1-release/Latest/. To force pkg_add(1) to download FreeBSD 9-STABLE packages, set PACKAGESITE to ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-9-stable/Latest/.

Package files are distributed in the .tbz format. Packages are available from ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/packages/ or the /packages directory of the FreeBSD DVD distribution. The layout of the packages directory is similar to that of the /usr/ports tree. Each category has its own directory, and every package can be found within the All directory.

5.4.2. Managing Packages

To list and describe installed packages, use pkg_info(1):

# pkg_info colordiff-1.0.13 Tool to colorize diff output docbook-1.4 Meta-port for the different versions of the DocBook DTD ...

To receive a summary of the versions of all installed packages and a comparison of the installed package versions to the current versions found in the locally installed ports tree, use pkg_version(1):

# pkg_version colordiff = docbook = ...

The symbols in the second column indicate the relative age of the installed version and the version available in the local ports tree.

SymbolMeaning
=The version of the installed package matches the one in the local ports tree.
<The version of the installed package is older than the one in the local ports tree.
>The version of the installed package is newer than the one in the local ports tree, meaning that the local ports tree is probably out of date.
?The installed package cannot be found in the ports index. This can happen when an installed port is removed from the Ports Collection or is renamed.
*There are multiple versions of the package.
!The installed package exists in the index but for some reason pkg_version was unable to compare the version number of the installed package with the corresponding entry in the index.

5.4.3. Deleting a Package

To remove a previously installed software package, use pkg_delete(1):

# pkg_delete xchat-2.8.8_1

Note that pkg_delete(1) requires the full package name and number and that the above command would not work if xchat was given instead of xchat-2.8.8_1. Use pkg_version(1) to find the version of the installed package, or use a wildcard:

# pkg_delete xchat\*

in this case, all packages whose names start with xchat will be deleted.

5.5. Using pkgng for Binary Package Management

pkgng is an improved replacement for the traditional FreeBSD package management tools, offering many features that make dealing with binary packages faster and easier. The first release of pkgng was in August, 2012.

pkgng is not a replacement for port management tools like ports-mgmt/portmaster or ports-mgmt/portupgrade. While ports-mgmt/portmaster and ports-mgmt/portupgrade can install third-party software from both binary packages and the Ports Collection, pkgng installs only binary packages.

5.5.1. Getting Started with pkgng

FreeBSD 9.1 and later includes a "bootstrap" utility for pkgng. The bootstrap utility will download and install pkgng.

To bootstrap the system, run:

# /usr/sbin/pkg

For earlier FreeBSD versions, pkgng must be installed from the Ports Collection, or as a binary package.

To install the pkgng port, run:

# cd /usr/ports/ports-mgmt/pkg # make # make install clean

To install the binary package, run:

# pkg_add -r pkg

Existing FreeBSD installations require conversion of the pkg_install package database to the new format. To convert the package database, run:

# pkg2ng

This step is not required for new installations that do not have third-party software installed.

Important:

This step is not reversible. Once the package database has been converted to the pkgng format, the pkg_install tools should not be used.

Note:

The package database conversion may emit errors as the contents are converted to the new version. Generally, these errors can be safely ignored, however a list of third-party software that was not successfully converted will be listed after pkg2ng has finished. These must be fixed by hand.

To ensure the FreeBSD Ports Collection registers new software with pkgng, and not pkg_install, FreeBSD versions earlier than 10.X require this line in /etc/make.conf:

WITH_PKGNG= yes

5.5.2. Configuring the pkgng Environment

The pkgng package management system uses a package repository for most operations. The default package repository location is defined in /usr/local/etc/pkg.conf or the PACKAGESITE environment variable, which overrides the configuration file.

Additional pkgng configuration options are described in pkg.conf(5).

5.5.3. Basic pkgng Operations

Usage information for pkgng is available in the pkg(8) manual page, or by running pkg without additional arguments.

Each pkgng command argument is documented in a command-specific manual page. To read the manual page for pkg install, for example, run either:

# pkg help install
# man pkg-install

5.5.3.1. Obtaining Information About Installed Packages with pkgng

Information about the packages installed on a system can be viewed by running pkg info. Similar to pkg_info(1), the package version and description for all packages will be listed.

Information about a specific package is available by running:

# pkg info packagename

For example, to see which version of pkgng is installed on the system, run:

# pkg info pkg pkg-1.0.2 New generation package manager

5.5.3.2. Installing and Removing Packages with pkgng

In general, most FreeBSD users will install binary packages by running:

# pkg install packagename

pkg install uses repository data, as mentioned in Section 5.5.2, “Configuring the pkgng Environment”. Conversely, pkg-add(8) does not use repository data, nor does it use the defined PACKAGESITE, so dependencies may not be properly tracked, and missing dependencies will not be fetched from a remote source. This section covers usage of pkg install. For information on usage of pkg add, see pkg-add(8).

Additional binary packages can be installed with pkg install. For example, to install curl:

# pkg install curl Updating repository catalogue Repository catalogue is up-to-date, no need to fetch fresh copy The following packages will be installed: Installing ca_root_nss: 3.13.5 Installing curl: 7.24.0 The installation will require 4 MB more space 1 MB to be downloaded Proceed with installing packages [y/N]: y ca_root_nss-3.13.5.txz 100% 255KB 255.1KB/s 255.1KB/s 00:00 curl-7.24.0.txz 100% 1108KB 1.1MB/s 1.1MB/s 00:00 Checking integrity... done Installing ca_root_nss-3.13.5... done Installing curl-7.24.0... done

The new package and any additional packages that were installed as dependencies can be seen in the installed packages list:

# pkg info ca_root_nss-3.13.5 The root certificate bundle from the Mozilla Project curl-7.24.0 Non-interactive tool to get files from FTP, GOPHER, HTTP(S) servers pkg-1.0.2 New generation package manager

Packages that are no longer needed can be removed with pkg delete. For example, if it turns out that curl is not needed after all:

# pkg delete curl The following packages will be deleted: curl-7.24.0_1 The deletion will free 3 MB Proceed with deleting packages [y/N]: y Deleting curl-7.24.0_1... done

5.5.3.3. Upgrading Installed Packages with pkgng

Packages that are outdated can be found with pkg version. If a local ports tree does not exist, pkg-version(8) will use the remote repository catalogue, otherwise the local ports tree will be used to identify package versions.

Packages can be upgraded to newer versions with pkgng. Suppose a new version of curl has been released. The local package can be upgraded to the new version:

# pkg upgrade Updating repository catalogue repo.txz 100% 297KB 296.5KB/s 296.5KB/s 00:00 The following packages will be upgraded: Upgrading curl: 7.24.0 -> 7.24.0_1 1 MB to be downloaded Proceed with upgrading packages [y/N]: y curl-7.24.0_1.txz 100% 1108KB 1.1MB/s 1.1MB/s 00:00 Checking integrity... done Upgrading curl from 7.24.0 to 7.24.0_1... done

5.5.3.4. Auditing Installed Packages with pkgng

Occasionally, software vulnerabilities may be discovered in software within the Ports Collection. pkgng includes built-in auditing, similar to the ports-mgmt/portaudit package. To audit the software installed on the system, run:

# pkg audit -F

5.5.4. Advanced pkgng Operations

5.5.4.1. Automatically Removing Leaf Dependencies with pkgng

Removing a package may leave behind unnecessary dependencies, like security/ca_root_nss in the example above. Such packages are still installed, but nothing depends on them any more. Unneeded packages that were installed as dependencies can be automatically detected and removed:

# pkg autoremove Packages to be autoremoved: ca_root_nss-3.13.5 The autoremoval will free 723 kB Proceed with autoremoval of packages [y/N]: y Deinstalling ca_root_nss-3.13.5... done

5.5.4.2. Backing Up the pkgng Package Database

Unlike the traditional package management system, pkgng includes its own package database backup mechanism. To manually back up the package database contents, run:

# pkg backup -d pkgng.db

Note:

Replace the file name pkgng.db to a suitable file name.

Additionally, pkgng includes a periodic(8) script to automatically back up the package database daily if daily_backup_pkgng_enable is set to YES in periodic.conf(5).

Tip:

To prevent the pkg_install periodic script from also backing up the package database, set daily_backup_pkgdb_enable to NO in periodic.conf(5).

To restore the contents of a previous package database backup, run:

# pkg backup -r /path/to/pkgng.db

5.5.4.3. Removing Stale pkgng Packages

By default, pkgng stores binary packages in a cache directory as defined by PKG_CACHEDIR in pkg.conf(5). When upgrading packages with pkg upgrade, old versions of the upgraded packages are not automatically removed.

To remove the outdated binary packages, run:

# pkg clean

5.5.4.4. Modifying pkgng Package Metadata

Historically, software within the FreeBSD Ports Collection can undergo major version number changes. Unlike pkg_install, pkgng has a built-in command to update package origins. For example, if lang/php5 was originally at version 5.3, but has been renamed to lang/php53 for the inclusion of version 5.4, pkg_install would require the use of additional software such as ports-mgmt/portmaster to update the package database, reflecting from which port the installation originated.

Unlike the ports-mgmt/portmaster and ports-mgmt/portupgrade ports, the order in which the new and old versions are listed differ. For pkgng, the syntax is:

# pkg set -o category/oldport:category/newport

For example, to change the package origin for the above example, run:

# pkg set -o lang/php5:lang/php53

As another example, to update lang/ruby18 to lang/ruby19, run:

# pkg set -o lang/ruby18:lang/ruby19

As a final example, to change the origin of the libglut shared libraries from graphics/libglut to graphics/freeglut, run:

# pkg set -o graphics/libglut:graphics/freeglut

Note:

When changing package origins, in most cases it is important to reinstall packages that are dependent on the package that has had the origin changed. To force a reinstallation of dependent packages, run:

# pkg install -Rf graphics/freeglut

5.6. Using the Ports Collection

This section provides basic instructions on using the Ports Collection to install or remove software. The detailed description of available make targets and environment variables is available in ports(7).

Warning:

As of mid 2012, the FreeBSD Ports Project has migrated revision control systems from CVS to Subversion. The preferred method for obtaining and maintaining the ports tree is Portsnap. Users requiring local customization of ports (that is, maintaining additional local patches) will probably prefer to use Subversion directly. The CVSup service was phased out as of February 28, 2013.

5.6.1. Obtaining the Ports Collection

The Ports Collection is a set of Makefiles, patches, and description files stored in /usr/ports. This set of files is used to compile and install applications on FreeBSD. The instructions below show several methods of obtaining the Ports Collection if it was not installed during initial FreeBSD setup.

Procedure 5.1. Portsnap Method

Portsnap is a fast and user-friendly tool for retrieving the Ports Collection, the preferred choice for most users. See Using Portsnap for a detailed description of Portsnap.

  1. Download a compressed snapshot of the Ports Collection into /var/db/portsnap.

    # portsnap fetch
  2. When running Portsnap for the first time, extract the snapshot into /usr/ports:

    # portsnap extract
  3. After the first use of Portsnap has been completed as shown above, /usr/ports can be updated with:

    # portsnap fetch # portsnap update
Procedure 5.2. Subversion Method

If more control over the ports tree is needed (for example, for maintaining local changes), Subversion can be used to obtain the Ports Collection. Refer to the Subversion Primer for a detailed description of Subversion.

  1. Subversion must be installed before it can be used to check out the ports tree. If a copy of the ports tree is already present, install Subversion like this:

    # cd /usr/ports/devel/subversion # make install clean

    If the ports tree is not available, Subversion can be installed as a package:

    # pkg_add -r subversion

    If pkgng is being used to manage packages, Subversion can be installed with it instead:

    # pkg install subversion
  2. Check out a copy of the ports tree. Use a specific Subversion mirror close to your geographic location instead of svn0.us-east.FreeBSD.org in the command below for better performance. Committers should read the Subversion Primer first to be sure the correct protocol is chosen.

    # svn checkout https://svn0.us-east.FreeBSD.org/ports/head /usr/ports
  3. To update /usr/ports after the initial Subversion checkout:

    # svn update /usr/ports
Procedure 5.3. Sysinstall Method

This method involves using sysinstall to install the Ports Collection from the installation media. Note that the old copy of Ports Collection from the date of the release will be installed. If you have Internet access, you should always use one of the methods mentioned above.

  1. As root, run sysinstall as shown below:

    # sysinstall
  2. Scroll down and select Configure, press Enter.

  3. Scroll down and select Distributions, press Enter.

  4. Scroll down to ports, press Space.

  5. Scroll up to Exit, press Enter.

  6. Select your desired installation media, such as CDROM, FTP, and so on.

  7. Scroll up to Exit and press Enter.

  8. Press X to exit sysinstall.

5.6.2. Migrating from CVSup/csup to portsnap

Warning:

By February 28, 2013, the ports tree will no longer be exported to CVS and therefore CVSup and csup will no longer provide updates for the ports tree.

Procedure 5.4. Migration to Portsnap

The migration will require about 1 GB of disk space on /usr, plus Portsnap requires about 150 MB disk space on /var.

  1. Disable any automated ports updates you may use, such as a cron(8) job calling CVSup or csup.

  2. Move the existing ports tree to a temporary location:

    # mv /usr/ports /usr/ports.old
  3. Fetch the new ports tree with Portsnap and extract it to /usr/ports:

    # portsnap fetch extract
  4. Move distfiles and saved packages to the new ports tree:

    # mv /usr/ports.old/distfiles /usr/ports # mv /usr/ports.old/packages /usr/ports
  5. Delete the old ports tree:

    # rm -rf /usr/ports.old
  6. If CVSup was used before, it can now be uninstalled:

    # pkg_delete -r -v cvsup-without-gui-\*

    Users of pkgng can use the following command:

    # pkg delete cvsup-without-gui

See Using Portsnap for a detailed description of Portsnap and how to update the ports tree with Portsnap.

5.6.3. Installing Ports

A port skeleton is a set of files that tell FreeBSD system how to compile and install a program. Each port skeleton includes:

  • Makefile: The Makefile contains statements that specify how the application should be compiled and where its components should be installed.

  • distinfo: This file contains information about the files that must be downloaded to build the port, and their checksums (using sha256(1)), to verify that files have not been corrupted during the download.

  • files/: This directory contains any patches needed for the program to compile and install on FreeBSD. This directory may also contain other files used to build the port.

  • pkg-descr: This file provides a more detailed description of the program.

  • pkg-plist: This is a list of all the files that will be installed by the port. It also tells the ports system what files to remove upon deinstallation.

Some ports include other files, such as pkg-message. The ports system uses these files to handle special situations. If you want more details on these files, and on ports in general, refer to the FreeBSD Porter's Handbook.

The port does not include the actual source code, also known as a distfile. Source code is distributed in whatever manner the software author desires. The two methods for installing a FreeBSD port are described below.

Note:

You must be logged in as root to install ports.

Warning:

Before compiling any port, be sure to have an up-to-date Ports Collection and check http://vuxml.freebsd.org/ for security issues related to your port. If ports-mgmt/portaudit is installed, run portaudit -F before installing a new port, to fetch the current vulnerabilities database. A security audit and an update of the database will be performed during the daily security system check. For more information read the portaudit(1) and periodic(8) manual pages.

Using the Ports Collection assumes a working Internet connection. Otherwise, manually obtain and place a copy of the distfile into /usr/ports/distfiles.

To begin, change to the directory of the port to be installed:

# cd /usr/ports/sysutils/lsof

To compile, or build, the port, type make at the prompt. You should see messages similar to the ones in this example:

# make >> lsof_4.57D.freebsd.tar.gz doesn't seem to exist in /usr/ports/distfiles/. >> Attempting to fetch from ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/. ===> Extracting for lsof-4.57 ... [extraction output snipped] ... >> Checksum OK for lsof_4.57D.freebsd.tar.gz. ===> Patching for lsof-4.57 ===> Applying FreeBSD patches for lsof-4.57 ===> Configuring for lsof-4.57 ... [configure output snipped] ... ===> Building for lsof-4.57 ... [compilation output snipped] ... #

Once the compile is complete, you are returned to the prompt. The next step is to install the port using make install:

# make install ===> Installing for lsof-4.57 ... [installation output snipped] ... ===> Generating temporary packing list ===> Compressing manual pages for lsof-4.57 ===> Registering installation for lsof-4.57 ===> SECURITY NOTE: This port has installed the following binaries which execute with increased privileges. #

Once you are returned to the prompt, you should be able to run the installed application. Since lsof is a program that runs with increased privileges, a security warning is shown. During the building and installation of ports, take heed of any other warnings that may appear.

It is a good idea to delete the working subdirectory, which contains all the temporary files used during compilation. Doing so saves disk space and minimizes the chance of problems later when upgrading to the newer version of the port.

# make clean ===> Cleaning for lsof-4.57 #

Note:

You can save two extra steps by just running make install clean instead of make, make install and make clean as three separate steps.

Note:

Using only make install means there will potentially be many waiting periods between user interaction as the default behaviour is to prompt the user for options. To avoid this when there are many dependencies, first run make config-recursive to do the configuration in one batch. Then run make install [clean] afterwards.

Tip:

When using config-recursive, the list of ports to configure are gathered by the all-depends-list make(1) target. It is often recommended to run make config-recursive until all dependent ports options have been defined, and ports options dialog(1) screens no longer appear, to be certain all ports options have been configured as intended.

Note:

Some shells keep a cache of the commands that are available in the directories listed in the PATH environment variable, to speed up lookup operations for the executable file of these commands. If you are using tcsh, you might have to type rehash so that a newly installed command can be used without specifying its full path. Use hash -r instead for the sh shell. Refer to the documentation for the shell for more information.

Some third-party DVD products such as the FreeBSD Toolkit from the FreeBSD Mall contain distfiles. They can be used with the Ports Collection. Mount the DVD on /cdrom. If you use a different mount point, set CD_MOUNTPTS make variable. The needed distfiles will be automatically used if they are present on the disk.

Note:

The licenses of a few ports do not allow their inclusion on the DVD. This could be because a registration form needs to be filled out before downloading or redistribution is not allowed. If you wish to install a port not included on the DVD, you will need to be connected to the Internet.

The ports system uses fetch(1) to download the files, which honors various environment variables, including FTP_PASSIVE_MODE, FTP_PROXY, and FTP_PASSWORD. You may need to set one or more of these if you are behind a firewall, or need to use an FTP/HTTP proxy. See fetch(3) for the complete list.

For users which cannot be connected all the time, the make fetch option is provided. Run this command within /usr/ports and the required files will be downloaded. This command also works in the lower level categories, such as /usr/ports/net. Note that if a port depends on libraries or other ports, this will not fetch the distfiles of ports from another category. Use make fetch-recursive to fetch all the dependencies of a port.

Note:

You can build all the ports in a category or as a whole by running make in the top level directory. This is dangerous, however, as some ports cannot co-exist. In other cases, some ports can install two different files with the same filename.

In some rare cases, users may need to acquire the tarballs from a site other than the default MASTER_SITES. You can override the MASTER_SITES option with the following command:

# cd /usr/ports/directory # make MASTER_SITE_OVERRIDE= \ ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/ fetch

In this example, MASTER_SITES is changed to ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/.

Note:

Some ports provide build options which can be used to enable/disable parts of the application which are unneeded, provide security options, or allow for other customizations. Examples include www/firefox, security/gpgme, and mail/sylpheed-claws. A menu will be displayed at the beginning of a port compile when compile options are available.

5.6.3.1. Overriding the Default Ports Directories

The WRKDIRPREFIX and PREFIX variables can override the default working and target directories. For example:

# make WRKDIRPREFIX=/usr/home/example/ports install

will compile the port in /usr/home/example/ports and install everything under /usr/local.

# make PREFIX=/usr/home/example/local install

will compile the port in /usr/ports and install it in /usr/home/example/local.

And

# make WRKDIRPREFIX=../ports PREFIX=../local install

will combine the two.

Alternatively, these can be set as environmental variables. Refer to the manual page for your shell for instructions on how to set an environmental variable.

5.6.3.2. Reconfiguring Ports

Certain ports provide an ncurses-based menu containing build options. There are several ways to revisit this menu in order to add, remove, or change these options after a port has been built. One method is to cd into the directory containing the port and type make config. Another option is to use make showconfig. Another option is to execute make rmconfig which will remove all selected options and allow you to start over. All of these options, and others, are explained in great detail in the manual page for ports(7).

5.6.4. Removing Installed Ports

Installed ports and packages are uninstalled using the pkg_delete(1) command:

# pkg_delete lsof-4.57

5.6.5. Upgrading Ports

First, list outdated ports that have a newer version available in the Ports Collection with the pkg_version(1) command:

# pkg_version -v

5.6.5.1. Read /usr/ports/UPDATING

Once you have updated your Ports Collection, before attempting a port upgrade, you should check /usr/ports/UPDATING. This file describes various issues and additional steps users may encounter and need to perform when updating a port, including such things as file format changes, changes in locations of configuration files, or other such incompatibilities with previous versions.

If UPDATING contradicts something you read here, UPDATING takes precedence.

5.6.5.2. Upgrading Ports Using Portupgrade

The portupgrade utility is designed to easily upgrade installed ports. It is available from the ports-mgmt/portupgrade port. Install it like any other port, using make install clean:

# cd /usr/ports/ports-mgmt/portupgrade # make install clean

Scan the list of installed ports using pkgdb -F and fix all the inconsistencies it reports. It is a good idea to do this regularly, before every upgrade.

Use portupgrade -a to upgrade all the outdated ports installed on the system. Include -i to be asked for confirmation of every individual upgrade.

# portupgrade -ai

To upgrade only a specified application instead of all available ports, use portupgrade pkgname. Include -R to first upgrade all the ports required by the given application.

# portupgrade -R firefox

To use packages instead of ports, include the -P flag. With this option, portupgrade searches the local directories listed in PKG_PATH, then fetches packages from a remote site if not found locally. If packages can not be found locally or fetched remotely, portupgrade will use ports. To avoid using ports, specify -PP.

# portupgrade -PP gnome2

To just fetch distfiles (or packages, if -P is specified) without building or installing anything, use -F. For further information see portupgrade(1).

5.6.5.3. Upgrading Ports Using portmaster

ports-mgmt/portmaster is another utility for upgrading installed ports. portmaster was designed to use the tools found in the base system without depending upon other ports. It uses the information in /var/db/pkg/ to determine which ports to upgrade. To install the port:

# cd /usr/ports/ports-mgmt/portmaster # make install clean

Portmaster groups ports into four categories:

  • Root ports: no dependencies and is not depended on by other ports

  • Trunk ports: no dependencies, but other ports depend upon it

  • Branch ports: have dependencies and are depended upon by other ports

  • Leaf ports: have dependencies but are not depended upon by other ports

To list all installed software and search for updates, use -L:

# portmaster -L ===>>> Root ports (No dependencies, not depended on) ===>>> ispell-3.2.06_18 ===>>> screen-4.0.3 ===>>> New version available: screen-4.0.3_1 ===>>> tcpflow-0.21_1 ===>>> 7 root ports ... ===>>> Branch ports (Have dependencies, are depended on) ===>>> apache22-2.2.3 ===>>> New version available: apache22-2.2.8 ... ===>>> Leaf ports (Have dependencies, not depended on) ===>>> automake-1.9.6_2 ===>>> bash-3.1.17 ===>>> New version available: bash-3.2.33 ... ===>>> 32 leaf ports ===>>> 137 total installed ports ===>>> 83 have new versions available

All the installed ports can be upgraded using this command:

# portmaster -a

Note:

By default, portmaster will make a backup package before deleting the existing port. If the installation of the new version is successful, portmaster will delete the backup. Using -b will instruct portmaster not to automatically delete the backup. Adding -i will start portmaster in interactive mode, prompting for confirmation before upgrading each port.

If you encounter errors during the upgrade process, use -f to upgrade/rebuild all ports:

# portmaster -af

You can also use portmaster to install new ports on the system, upgrading all dependencies before building and installing the new port:

# portmaster shells/bash

Refer to portmaster(8) for more information.

5.6.6. Ports and Disk Space

Using the Ports Collection will use up disk space over time. After building and installing a port, make clean will clean up the temporary work directory. To sweep the whole Ports Collection:

# portsclean -C

A lot of out-dated source distribution files will collect in distfiles over time. The following command will delete all the distfiles that are no longer referenced by any ports:

# portsclean -D

To remove all distfiles not referenced by any port currently installed on the system:

# portsclean -DD

Note:

The portsclean utility is part of the ports-mgmt/portupgrade suite.

ports-mgmt/pkg_cutleaves automates the task of removing installed ports that are no longer needed.

5.7. Post-Installation Considerations

Regardless of whether the software was installed from a binary package or port, most third-party applications require some level of configuration after installation. The following commands and locations can be used to help determine what was installed with the application.

  • Most applications install at least one default configuration file in /usr/local/etc. The configuration files should be reviewed and possibly edited to meet the system's needs.

  • Applications which provide documentation will install it into /usr/local/share/doc and many applications also install manual pages. This documentation should be consulted before continuing.

  • Some applications run services which must be added to /etc/rc.conf before starting the application. These applications usually install a startup script in /usr/local/etc/rc.d. See Starting Services for more information.

  • Users of csh(1) should run rehash to rebuild the known binary list in the shells PATH.

  • If the system is running the traditional package system, use pkg_info(1) to determine which files, man pages, and binaries were installed with the application. If the system is running pkgng, instead use pkg info.

5.8. Dealing with Broken Ports

When coming across a port that does not build or install:

  1. Find out if there is a fix pending for the port in the Problem Report database. If so, the proposed fix may work.

  2. Ask the maintainer of the port for help. Type make maintainer or read the Makefile to find the maintainer's email address. Remember to include the name and version of the port (send the $FreeBSD: line from the Makefile) and the output leading up to the error when you email the maintainer.

    Note:

    Some ports are not maintained by an individual but instead by a mailing list. Many, but not all, of these addresses look like . Please take this into account when phrasing your questions.

    In particular, ports shown as maintained by are actually not maintained by anyone. Fixes and support, if any, come from the general community who subscribe to that mailing list. More volunteers are always needed!

    If you do not get a response, use send-pr(1) to submit a bug report (see Writing FreeBSD Problem Reports).

  3. Fix it! The Porter's Handbook includes detailed information on the Ports infrastructure so that you can fix the occasional broken port or even submit your own!

  4. Use pkg_add(1) to instead install the package.

Chapter 6. The X Window System

Updated for X.Org's X11 server by Ken Tom and Marc Fonvieille.

6.1. Synopsis

FreeBSD uses X11 to provide users with a powerful graphical user interface. X11 is a freely available version of the X Window System that is implemented in Xorg (and other software packages not discussed here). The default and official flavor of X11 in FreeBSD is Xorg, the X11 server developed by the X.Org Foundation under a license very similar to the one used by FreeBSD.

For more information on the video hardware that X11 supports, check the Xorg web site.

After reading this chapter, you will know:

  • The various components of the X Window System, and how they interoperate.

  • How to install and configure X11.

  • How to install and use different window managers.

  • How to use TrueType® fonts in X11.

  • How to set up your system for graphical logins (XDM).

Before reading this chapter, you should:

6.2. Understanding X

Using X for the first time can be somewhat of a shock to someone familiar with other graphical environments, such as Microsoft® Windows® or Mac OS®.

While it is not necessary to understand all of the details of various X components and how they interact, some basic knowledge makes it possible to take advantage of X's strengths.

6.2.1. Why X?

X is not the first window system written for UNIX®, but it is the most popular of them. X's original development team had worked on another window system prior to writing X. That system's name was W (for Window). X was just the next letter in the Roman alphabet.

X can be called X, X Window System, X11, and a number of other terms. You may find that using the term X Windows to describe X11 can be offensive to some people; for a bit more insight on this, see X(7).

6.2.2. The X Client/Server Model

X was designed from the beginning to be network-centric, and adopts a client-server model.

In the X model, the X server runs on the computer that has the keyboard, monitor, and mouse attached. The server's responsibility includes tasks such as managing the display, handling input from the keyboard and mouse, and other input or output devices (i.e., a tablet can be used as an input device, and a video projector may be an alternative output device). Each X application (such as XTerm or Firefox) is a client. A client sends messages to the server such as Please draw a window at these coordinates, and the server sends back messages such as The user just clicked on the OK button.

In a home or small office environment, the X server and the X clients commonly run on the same computer. However, it is perfectly possible to run the X server on a less powerful desktop computer, and run X applications (the clients) on, say, the powerful and expensive machine that serves the office. In this scenario the communication between the X client and server takes place over the network.

This confuses some people, because the X terminology is exactly backward to what they expect. They expect the X server to be the big powerful machine down the hall, and the X client to be the machine on their desk.

It is important to remember that the X server is the machine with the monitor and keyboard, and the X clients are the programs that display the windows.

There is nothing in the protocol that forces the client and server machines to be running the same operating system, or even to be running on the same type of computer. It is certainly possible to run an X server on Microsoft® Windows® or Apple's Mac OS®, and there are various free and commercial applications available that do exactly that.

6.2.3. The Window Manager

The X design philosophy is much like the UNIX® design philosophy, tools, not policy. This means that X does not try to dictate how a task is to be accomplished. Instead, tools are provided to the user, and it is the user's responsibility to decide how to use those tools.

This philosophy extends to X not dictating what windows should look like on screen, how to move them around with the mouse, what keystrokes should be used to move between windows (i.e., Alt+Tab, in the case of Microsoft® Windows®), what the title bars on each window should look like, whether or not they have close buttons on them, and so on.

Instead, X delegates this responsibility to an application called a Window Manager. There are dozens of window managers available for X. Each of these window managers provides a different look and feel; some of them support virtual desktops; some of them allow customized keystrokes to manage the desktop; some have a Start button or similar device; some are themeable, allowing a complete change of look-and-feel by applying a new theme. Window managers are available in the x11-wm category of the Ports Collection.

In addition, the KDE and GNOME desktop environments both have their own window managers which integrate with the desktop.

Each window manager also has a different configuration mechanism; some expect configuration file written by hand, others feature GUI tools for most of the configuration tasks; at least one (Sawfish) has a configuration file written in a dialect of the Lisp language.

Focus Policy:

Another feature the window manager is responsible for is the mouse focus policy. Every windowing system needs some means of choosing a window to be actively receiving keystrokes, and should visibly indicate which window is active as well.

A familiar focus policy is called click-to-focus. This is the model utilized by Microsoft® Windows®, in which a window becomes active upon receiving a mouse click.

X does not support any particular focus policy. Instead, the window manager controls which window has the focus at any one time. Different window managers will support different focus methods. All of them support click to focus, and the majority of them support several others.

The most popular focus policies are:

focus-follows-mouse

The window that is under the mouse pointer is the window that has the focus. This may not necessarily be the window that is on top of all the other windows. The focus is changed by pointing at another window, there is no need to click in it as well.

sloppy-focus

This policy is a small extension to focus-follows-mouse. With focus-follows-mouse, if the mouse is moved over the root window (or background) then no window has the focus, and keystrokes are simply lost. With sloppy-focus, focus is only changed when the cursor enters a new window, and not when exiting the current window.

click-to-focus

The active window is selected by mouse click. The window may then be raised, and appear in front of all other windows. All keystrokes will now be directed to this window, even if the cursor is moved to another window.

Many window managers support other policies, as well as variations on these. Be sure to consult the documentation for the window manager itself.

6.2.4. Widgets

The X approach of providing tools and not policy extends to the widgets seen on screen in each application.

Widget is a term for all the items in the user interface that can be clicked or manipulated in some way; buttons, check boxes, radio buttons, icons, lists, and so on. Microsoft® Windows® calls these controls.

Microsoft® Windows® and Apple's Mac OS® both have a very rigid widget policy. Application developers are supposed to ensure that their applications share a common look and feel. With X, it was not considered sensible to mandate a particular graphical style, or set of widgets to adhere to.

As a result, do not expect X applications to have a common look and feel. There are several popular widget sets and variations, including Qt, used by KDE, and GTK+, used by the GNOME project. In this respect, there is some convergence in look-and-feel of the UNIX® desktop, which certainly makes things easier for the novice user.

6.3. Installing X11

Xorg is the X11 implementation for FreeBSD. Xorg is the X server of the open source X Window System implementation released by the X.Org Foundation. Xorg is based on the code of XFree86™ 4.4RC2 and X11R6.6. The version of Xorg currently available in the FreeBSD Ports Collection is 7.7.

To build and install Xorg from the Ports Collection:

# cd /usr/ports/x11/xorg # make install clean

Note:

To build Xorg in its entirety, be sure to have at least 4 GB of free space available.

Alternatively, X11 can be installed directly from packages. Binary packages to use with pkg_add(1) tool are also available for X11. When the remote fetching feature of pkg_add(1) is used, the version number of the package must be removed. pkg_add(1) will automatically fetch the latest version of the application.

So to fetch and install the package of Xorg, simply type:

# pkg_add -r xorg

Note:

The examples above will install the complete X11 distribution including the servers, clients, fonts etc. Separate packages and ports of X11 are also available.

To install a minimal X11 distribution you can alternatively install x11/xorg-minimal.

The rest of this chapter will explain how to configure X11, and how to set up a productive desktop environment.

6.4. X11 Configuration

Contributed by Christopher Shumway.

6.4.1. Before Starting

In most cases, X11 is self-configuring. Those with older or unusual equipment may find it helpful to gather some hardware information before beginning configuration.

  • Monitor sync frequencies

  • Video card chipset

  • Video card memory

Screen resolution and refresh rate are determined by the monitor's horizontal and vertical sync frequencies. Almost all monitors support electronic autodetection of these values. A few monitors do not provide these values, and the specifications must be determined from the printed manual or manufacturer web site.

The video card chipset is also autodetected, and used to select the proper video driver. It is beneficial for the user to be aware of which chipset is installed for when autodetection does not provide the desired result.

Video card memory determines the maximum resolution and color depth which can be displayed.

6.4.2. Configuring X11

Xorg uses HAL to autodetect keyboards and mice. The sysutils/hal and devel/dbus ports are installed as dependencies of x11/xorg, but must be enabled by the following entries in the /etc/rc.conf file:

hald_enable="YES" dbus_enable="YES"

These services should be started (either manually or by rebooting) before further Xorg configuration or use is attempted.

Xorg can often work without any further configuration steps by simply typing at prompt:

% startx

The automatic configuration may fail to work with some hardware, or may not set things up quite as desired. In these cases, manual configuration will be necessary.

Note:

Desktop environments like GNOME, KDE or Xfce have tools allowing the user to easily set the screen parameters such as the resolution. So if the default configuration is not acceptable and you planned to install a desktop environment then just continue with the installation of the desktop environment and use the appropriate screen settings tool.

Configuration of X11 is a multi-step process. The first step is to build an initial configuration file. As the super user, simply run:

# Xorg -configure

This will generate an X11 configuration skeleton file in the /root directory called xorg.conf.new (whether you su(1) or do a direct login affects the inherited supervisor $HOME directory variable). The X11 program will attempt to probe the graphics hardware on the system and write a configuration file to load the proper drivers for the detected hardware on the target system.

The next step is to test the existing configuration to verify that Xorg can work with the graphics hardware on the target system. Type:

# Xorg -config xorg.conf.new -retro

If a black and grey grid and an X mouse cursor appear, the configuration was successful. To exit the test, switch to the virtual console used to start it by pressing Ctrl+Alt+Fn (F1 for the first virtual console) and press Ctrl+C.

Note:

The Ctrl+Alt+Backspace key combination may also be used to break out of Xorg. To enable it, you can either type the following command from any X terminal emulator:

% setxkbmap -option terminate:ctrl_alt_bksp

or create a keyboard configuration file for hald called x11-input.fdi and saved in the /usr/local/etc/hal/fdi/policy directory. This file should contain the following lines:

<?xml version="1.0" encoding="iso-8859-1"?> <deviceinfo version="0.2"> <device> <match key="info.capabilities" contains="input.keyboard"> <merge key="input.x11_options.XkbOptions" type="string">terminate:ctrl_alt_bksp</merge> </match> </device> </deviceinfo>

You will have to reboot your machine to force hald to read this file.

The following line will also have to be added to xorg.conf.new, in the ServerLayout or ServerFlags section:

Option "DontZap" "off"

If the mouse does not work, you will need to first configure it before proceeding. See Section 3.10.9, “Mouse Settings” in the FreeBSD install chapter. In recent Xorg versions, the InputDevice sections in xorg.conf are ignored in favor of the autodetected devices. To restore the old behavior, add the following line to the ServerLayout or ServerFlags section of this file:

Option "AutoAddDevices" "false"

Input devices may then be configured as in previous versions, along with any other options needed (e.g., keyboard layout switching).

Note:

As previously explained the hald daemon will, by default, automatically detect your keyboard. There are chances that your keyboard layout or model will not be correct, desktop environments like GNOME, KDE or Xfce provide tools to configure the keyboard. However, it is possible to set the keyboard properties directly either with the help of the setxkbmap(1) utility or with a hald's configuration rule.

For example if one wants to use a PC 102 keys keyboard coming with a french layout, we have to create a keyboard configuration file for hald called x11-input.fdi and saved in the /usr/local/etc/hal/fdi/policy directory. This file should contain the following lines:

<?xml version="1.0" encoding="iso-8859-1"?> <deviceinfo version="0.2"> <device> <match key="info.capabilities" contains="input.keyboard"> <merge key="input.x11_options.XkbModel" type="string">pc102</merge> <merge key="input.x11_options.XkbLayout" type="string">fr</merge> </match> </device> </deviceinfo>

If this file already exists, just copy and add to your file the lines regarding the keyboard configuration.

You will have to reboot your machine to force hald to read this file.

It is possible to do the same configuration from an X terminal or a script with this command line:

% setxkbmap -model pc102 -layout fr

The /usr/local/share/X11/xkb/rules/base.lst file lists the various keyboard, layouts and options available.

The xorg.conf.new configuration file may now be tuned to taste. Open the file in a text editor such as emacs(1) or ee(1). If the monitor is an older or unusual model that does not support autodetection of sync frequencies, those settings can be added to xorg.conf.new under the "Monitor" section:

Section "Monitor" Identifier "Monitor0" VendorName "Monitor Vendor" ModelName "Monitor Model" HorizSync 30-107 VertRefresh 48-120 EndSection

Most monitors support sync frequency autodetection, making manual entry of these values unnecessary. For the few monitors that do not support autodetection, avoid potential damage by only entering values provided by the manufacturer.

X allows DPMS (Energy Star) features to be used with capable monitors. The xset(1) program controls the time-outs and can force standby, suspend, or off modes. If you wish to enable DPMS features for your monitor, you must add the following line to the monitor section:

Option "DPMS"

While the xorg.conf.new configuration file is still open in an editor, select the default resolution and color depth desired. This is defined in the "Screen" section:

Section "Screen" Identifier "Screen0" Device "Card0" Monitor "Monitor0" DefaultDepth 24 SubSection "Display" Viewport 0 0 Depth 24 Modes "1024x768" EndSubSection EndSection

The DefaultDepth keyword describes the color depth to run at by default. This can be overridden with the -depth command line switch to Xorg(1). The Modes keyword describes the resolution to run at for the given color depth. Note that only VESA standard modes are supported as defined by the target system's graphics hardware. In the example above, the default color depth is twenty-four bits per pixel. At this color depth, the accepted resolution is 1024 by 768 pixels.

Finally, write the configuration file and test it using the test mode given above.

Note:

One of the tools available to assist you during troubleshooting process are the X11 log files, which contain information on each device that the X11 server attaches to. Xorg log file names are in the format of /var/log/Xorg.0.log. The exact name of the log can vary from Xorg.0.log to Xorg.8.log and so forth.

If all is well, the configuration file needs to be installed in a common location where Xorg(1) can find it. This is typically /etc/X11/xorg.conf or /usr/local/etc/X11/xorg.conf.

# cp xorg.conf.new /etc/X11/xorg.conf

The X11 configuration process is now complete. Xorg may be now started with the startx(1) utility. The X11 server may also be started with the use of xdm(1).

6.4.3. Advanced Configuration Topics

6.4.3.1. Configuration with Intel® i810 Graphics Chipsets

Configuration with Intel® i810 integrated chipsets requires the agpgart AGP programming interface for X11 to drive the card. See the agp(4) driver manual page for more information.

This will allow configuration of the hardware as any other graphics board. Note on systems without the agp(4) driver compiled in the kernel, trying to load the module with kldload(8) will not work. This driver has to be in the kernel at boot time through being compiled in or using /boot/loader.conf.

6.4.3.2. Adding a Widescreen Flatpanel to the Mix

This section assumes a bit of advanced configuration knowledge. If attempts to use the standard configuration tools above have not resulted in a working configuration, there is information enough in the log files to be of use in getting the setup working. Use of a text editor will be necessary.

Current widescreen (WSXGA, WSXGA+, WUXGA, WXGA, WXGA+, et.al.) formats support 16:10 and 10:9 formats or aspect ratios that can be problematic. Examples of some common screen resolutions for 16:10 aspect ratios are:

  • 2560x1600

  • 1920x1200

  • 1680x1050

  • 1440x900

  • 1280x800

At some point, it will be as easy as adding one of these resolutions as a possible Mode in the Section "Screen" as such:

Section "Screen" Identifier "Screen0" Device "Card0" Monitor "Monitor0" DefaultDepth 24 SubSection "Display" Viewport 0 0 Depth 24 Modes "1680x1050" EndSubSection EndSection

Xorg is smart enough to pull the resolution information from the widescreen via I2C/DDC information so it knows what the monitor can handle as far as frequencies and resolutions.

If those ModeLines do not exist in the drivers, one might need to give Xorg a little hint. Using /var/log/Xorg.0.log one can extract enough information to manually create a ModeLine that will work. Simply look for information resembling this:

(II) MGA(0): Supported additional Video Mode: (II) MGA(0): clock: 146.2 MHz Image Size: 433 x 271 mm (II) MGA(0): h_active: 1680 h_sync: 1784 h_sync_end 1960 h_blank_end 2240 h_border: 0 (II) MGA(0): v_active: 1050 v_sync: 1053 v_sync_end 1059 v_blanking: 1089 v_border: 0 (II) MGA(0): Ranges: V min: 48 V max: 85 Hz, H min: 30 H max: 94 kHz, PixClock max 170 MHz

This information is called EDID information. Creating a ModeLine from this is just a matter of putting the numbers in the correct order:

ModeLine <name> <clock> <4 horiz. timings> <4 vert. timings>

So that the ModeLine in Section "Monitor" for this example would look like this:

Section "Monitor" Identifier "Monitor1" VendorName "Bigname" ModelName "BestModel" ModeLine "1680x1050" 146.2 1680 1784 1960 2240 1050 1053 1059 1089 Option "DPMS" EndSection

Now having completed these simple editing steps, X should start on your new widescreen monitor.

6.5. Using Fonts in X11

Contributed by Murray Stokely.

6.5.1. Type1 Fonts

The default fonts that ship with X11 are less than ideal for typical desktop publishing applications. Large presentation fonts show up jagged and unprofessional looking, and small fonts are almost completely unintelligible. However, there are several free, high quality Type1 (PostScript®) fonts available which can be readily used with X11. For instance, the URW font collection (x11-fonts/urwfonts) includes high quality versions of standard type1 fonts (Times Roman®, Helvetica®, Palatino® and others). The Freefonts collection (x11-fonts/freefonts) includes many more fonts, but most of them are intended for use in graphics software such as the Gimp, and are not complete enough to serve as screen fonts. In addition, X11 can be configured to use TrueType® fonts with a minimum of effort. For more details on this, see the X(7) manual page or the section on TrueType® fonts.

To install the above Type1 font collections from the Ports Collection, run the following commands:

# cd /usr/ports/x11-fonts/urwfonts # make install clean

And likewise with the freefont or other collections. To have the X server detect these fonts, add an appropriate line to the X server configuration file (/etc/X11/xorg.conf), which reads:

FontPath "/usr/local/lib/X11/fonts/URW/"

Alternatively, at the command line in the X session run:

% xset fp+ /usr/local/lib/X11/fonts/URW % xset fp rehash

This will work but will be lost when the X session is closed, unless it is added to the startup file (~/.xinitrc for a normal startx session, or ~/.xsession when logging in through a graphical login manager like XDM). A third way is to use the new /usr/local/etc/fonts/local.conf file: see the section on anti-aliasing.

6.5.2. TrueType® Fonts

Xorg has built in support for rendering TrueType® fonts. There are two different modules that can enable this functionality. The freetype module is used in this example because it is more consistent with the other font rendering back-ends. To enable the freetype module just add the following line to the "Module" section of the /etc/X11/xorg.conf file.

Load "freetype"

Now make a directory for the TrueType® fonts (for example, /usr/local/lib/X11/fonts/TrueType) and copy all of the TrueType® fonts into this directory. Keep in mind that TrueType® fonts cannot be directly taken from a Macintosh®; they must be in UNIX®/MS-DOS®/Windows® format for use by X11. Once the files have been copied into this directory, use ttmkfdir to create a fonts.dir file, so that the X font renderer knows that these new files have been installed. ttmkfdir is available from the FreeBSD Ports Collection as x11-fonts/ttmkfdir.

# cd /usr/local/lib/X11/fonts/TrueType # ttmkfdir -o fonts.dir

Now add the TrueType® directory to the font path. This is just the same as described above for Type1 fonts, that is, use

% xset fp+ /usr/local/lib/X11/fonts/TrueType % xset fp rehash

or add a FontPath line to the xorg.conf file.

That's it. Now Gimp, Apache OpenOffice, and all of the other X applications should now recognize the installed TrueType® fonts. Extremely small fonts (as with text in a high resolution display on a web page) and extremely large fonts (within StarOffice) will look much better now.

6.5.3. Anti-Aliased Fonts

Updated by Joe Marcus Clarke.

All fonts in X11 that are found in /usr/local/lib/X11/fonts/ and ~/.fonts/ are automatically made available for anti-aliasing to Xft-aware applications. Most recent applications are Xft-aware, including KDE, GNOME, and Firefox.

In order to control which fonts are anti-aliased, or to configure anti-aliasing properties, create (or edit, if it already exists) the file /usr/local/etc/fonts/local.conf. Several advanced features of the Xft font system can be tuned using this file; this section describes only some simple possibilities. For more details, please see fonts-conf(5).

This file must be in XML format. Pay careful attention to case, and make sure all tags are properly closed. The file begins with the usual XML header followed by a DOCTYPE definition, and then the <fontconfig> tag:

<?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig>

As previously stated, all fonts in /usr/local/lib/X11/fonts/ as well as ~/.fonts/ are already made available to Xft-aware applications. If you wish to add another directory outside of these two directory trees, add a line similar to the following to /usr/local/etc/fonts/local.conf:

<dir>/path/to/my/fonts</dir>

After adding new fonts, and especially new font directories, you should run the following command to rebuild the font caches:

# fc-cache -f

Anti-aliasing makes borders slightly fuzzy, which makes very small text more readable and removes staircases from large text, but can cause eyestrain if applied to normal text. To exclude font sizes smaller than 14 point from anti-aliasing, include these lines:

<match target="font"> <test name="size" compare="less"> <double>14</double> </test> <edit name="antialias" mode="assign"> <bool>false</bool> </edit> </match> <match target="font"> <test name="pixelsize" compare="less" qual="any"> <double>14</double> </test> <edit mode="assign" name="antialias"> <bool>false</bool> </edit> </match>

Spacing for some monospaced fonts may also be inappropriate with anti-aliasing. This seems to be an issue with KDE, in particular. One possible fix for this is to force the spacing for such fonts to be 100. Add the following lines:

<match target="pattern" name="family"> <test qual="any" name="family"> <string>fixed</string> </test> <edit name="family" mode="assign"> <string>mono</string> </edit> </match> <match target="pattern" name="family"> <test qual="any" name="family"> <string>console</string> </test> <edit name="family" mode="assign"> <string>mono</string> </edit> </match>

(this aliases the other common names for fixed fonts as "mono"), and then add:

<match target="pattern" name="family"> <test qual="any" name="family"> <string>mono</string> </test> <edit name="spacing" mode="assign"> <int>100</int> </edit> </match>

Certain fonts, such as Helvetica, may have a problem when anti-aliased. Usually this manifests itself as a font that seems cut in half vertically. At worst, it may cause applications to crash. To avoid this, consider adding the following to local.conf:

<match target="pattern" name="family"> <test qual="any" name="family"> <string>Helvetica</string> </test> <edit name="family" mode="assign"> <string>sans-serif</string> </edit> </match>

Once you have finished editing local.conf make sure you end the file with the </fontconfig> tag. Not doing this will cause your changes to be ignored.

Finally, users can add their own settings via their personal .fonts.conf files. To do this, each user should simply create a ~/.fonts.conf. This file must also be in XML format.

One last point: with an LCD screen, sub-pixel sampling may be desired. This basically treats the (horizontally separated) red, green and blue components separately to improve the horizontal resolution; the results can be dramatic. To enable this, add the line somewhere in the local.conf file:

<match target="font"> <test qual="all" name="rgba"> <const>unknown</const> </test> <edit name="rgba" mode="assign"> <const>rgb</const> </edit> </match>

Note:

Depending on the sort of display, rgb may need to be changed to bgr, vrgb or vbgr: experiment and see which works best.

6.6. The X Display Manager

Contributed by Seth Kingsley.

6.6.1. Overview

The X Display Manager (XDM) is an optional part of the X Window System that is used for login session management. This is useful for several types of situations, including minimal X Terminals, desktops, and large network display servers. Since the X Window System is network and protocol independent, there are a wide variety of possible configurations for running X clients and servers on different machines connected by a network. XDM provides a graphical interface for choosing which display server to connect to, and entering authorization information such as a login and password combination.

Think of XDM as providing the same functionality to the user as the getty(8) utility (see Section 26.3.2, “Configuration” for details). That is, it performs system logins to the display being connected to and then runs a session manager on behalf of the user (usually an X window manager). XDM then waits for this program to exit, signaling that the user is done and should be logged out of the display. At this point, XDM can display the login and display chooser screens for the next user to login.

6.6.2. Using XDM

To start using XDM, install the x11/xdm port (it is not installed by default in recent versions of Xorg). The XDM daemon program may then be found in /usr/local/bin/xdm. This program can be run at any time as root and it will start managing the X display on the local machine. If XDM is to be run every time the machine boots up, a convenient way to do this is by adding an entry to /etc/ttys. For more information about the format and usage of this file, see Section 26.3.2.1, “Adding an Entry to /etc/ttys. There is a line in the default /etc/ttys file for running the XDM daemon on a virtual terminal:

ttyv8 "/usr/local/bin/xdm -nodaemon" xterm off secure

By default this entry is disabled; in order to enable it change field 5 from off to on and restart init(8) using the directions in Section 26.3.2.2, “Force init to Reread /etc/ttys. The first field, the name of the terminal this program will manage, is ttyv8. This means that XDM will start running on the 9th virtual terminal.

6.6.3. Configuring XDM

The XDM configuration directory is located in /usr/local/lib/X11/xdm. In this directory there are several files used to change the behavior and appearance of XDM. Typically these files will be found:

FileDescription
XaccessClient authorization ruleset.
XresourcesDefault X resource values.
XserversList of remote and local displays to manage.
XsessionDefault session script for logins.
Xsetup_*Script to launch applications before the login interface.
xdm-configGlobal configuration for all displays running on this machine.
xdm-errorsErrors generated by the server program.
xdm-pidThe process ID of the currently running XDM.

Also in this directory are a few scripts and programs used to set up the desktop when XDM is running. The purpose of each of these files will be briefly described. The exact syntax and usage of all of these files is described in xdm(1).

The default configuration is a simple rectangular login window with the hostname of the machine displayed at the top in a large font and Login: and Password: prompts below. This is a good starting point for changing the look and feel of XDM screens.

6.6.3.1. Xaccess

The protocol for connecting to XDM-controlled displays is called the X Display Manager Connection Protocol (XDMCP). This file is a ruleset for controlling XDMCP connections from remote machines. It is ignored unless the xdm-config is changed to listen for remote connections. By default, it does not allow any clients to connect.

6.6.3.2. Xresources

This is an application-defaults file for the display chooser and login screens. In it, the appearance of the login program can be modified. The format is identical to the app-defaults file described in the X11 documentation.

6.6.3.3. Xservers

This is a list of the remote displays the chooser should provide as choices.

6.6.3.4. Xsession

This is the default session script for XDM to run after a user has logged in. Normally each user will have a customized session script in ~/.xsession that overrides this script.

6.6.3.5. Xsetup_*

These will be run automatically before displaying the chooser or login interfaces. There is a script for each display being used, named Xsetup_ followed by the local display number (for instance Xsetup_0). Typically these scripts will run one or two programs in the background such as xconsole.

6.6.3.6. xdm-config

This contains settings in the form of app-defaults that are applicable to every display that this installation manages.

6.6.3.7. xdm-errors

This contains the output of the X servers that XDM is trying to run. If a display that XDM is trying to start hangs for some reason, this is a good place to look for error messages. These messages are also written to the user's ~/.xsession-errors file on a per-session basis.

6.6.4. Running a Network Display Server

In order for other clients to connect to the display server, you must edit the access control rules and enable the connection listener. By default these are set to conservative values. To make XDM listen for connections, first comment out a line in the xdm-config file:

! SECURITY: do not listen for XDMCP or Chooser requests ! Comment out this line if you want to manage X terminals with xdm DisplayManager.requestPort: 0

and then restart XDM. Remember that comments in app-defaults files begin with a ! character, not the usual #. More strict access controls may be desired — look at the example entries in Xaccess, and refer to the xdm(1) manual page for further information.

6.6.5. Replacements for XDM

Several replacements for the default XDM program exist. One of them, KDM (bundled with KDE) is described later in this chapter. The KDM display manager offers many visual improvements and cosmetic frills, as well as the functionality to allow users to choose their window manager of choice at login time.

6.7. Desktop Environments

Contributed by Valentino Vaschetto.

This section describes the different desktop environments available for X on FreeBSD. A desktop environment can mean anything ranging from a simple window manager to a complete suite of desktop applications, such as KDE or GNOME.

6.7.1. GNOME

6.7.1.1. About GNOME

GNOME is a user-friendly desktop environment that enables users to easily use and configure their computers. GNOME includes a panel (for starting applications and displaying status), a desktop (where data and applications can be placed), a set of standard desktop tools and applications, anda set of conventions that make it easy for applications to cooperate and be consistent with each other. Users of other operating systems or environments should feel right at home using the powerful graphics-driven environment that GNOME provides. More information regarding GNOME on FreeBSD can be found on the FreeBSD GNOME Project's web site. The web site also contains fairly comprehensive FAQs about installing, configuring, and managing GNOME.

6.7.1.2. Installing GNOME

The software can be easily installed from a package or the Ports Collection:

To install the GNOME package from the network, simply type:

# pkg_add -r gnome2

For pkgng users, the equivalent command is:

# pkg install gnome2

To build GNOME from source, use the ports tree:

# cd /usr/ports/x11/gnome2 # make install clean

For proper operation, GNOME requires the /proc filesystem to be mounted. Add

proc /proc procfs rw 0 0

to /etc/fstab to mount procfs(5) automatically during startup.

Once GNOME is installed, the X server must be told to start GNOME instead of a default window manager.

The easiest way to start GNOME is with GDM, the GNOME Display Manager. GDM is installed as part of the GNOME desktop, although it is disabled by default. It can be enabled by adding this line to /etc/rc.conf:

gdm_enable="YES"

Once you have rebooted, GDM will start automatically.

It is often desirable to start all GNOME services together with GDM. To achieve this, add the following line to /etc/rc.conf:

gnome_enable="YES"

GNOME may also be started from the command-line by properly configuring a file named .xinitrc. If a custom .xinitrc is already in place, simply replace the line that starts the current window manager with one that starts /usr/local/bin/gnome-session instead. If nothing special has been done to the configuration file, then it is enough simply to type:

% echo "/usr/local/bin/gnome-session" > ~/.xinitrc

Next, type startx, and the GNOME desktop environment will be started.

Note:

If an older display manager, like XDM, is being used, this will not work. Instead, create an executable .xsession file with the same command in it. To do this, edit the file and replace the existing window manager command with /usr/local/bin/gnome-session:

% echo "#!/bin/sh" > ~/.xsession % echo "/usr/local/bin/gnome-session" >> ~/.xsession % chmod +x ~/.xsession

Yet another option is to configure the display manager to allow choosing the window manager at login time; the section on KDE details explains how to do this for KDM, the display manager of KDE.

6.7.2. KDE

6.7.2.1. About KDE

KDE is an easy to use contemporary desktop environment. Some of the things that KDE brings to the user are:

  • A beautiful contemporary desktop

  • A desktop exhibiting complete network transparency

  • An integrated help system allowing for convenient, consistent access to help on the use of the KDE desktop and its applications

  • Consistent look and feel of all KDE applications

  • Standardized menu and toolbars, keybindings, color-schemes, etc.

  • Internationalization: KDE is available in more than 55 languages

  • Centralized, consistent, dialog-driven desktop configuration

  • A great number of useful KDE applications

KDE comes with a web browser called Konqueror, which is a solid competitor to other existing web browsers on UNIX® systems. More information on KDE can be found on the KDE website. For FreeBSD specific information and resources on KDE, consult the KDE/FreeBSD initiative's website.

6.7.2.2. Installing KDE

Just as with GNOME or any other desktop environment, the software can be easily installed from a package or the Ports Collection:

To install the KDE 4 package from the network, type:

# pkg_add -r kde4

pkg_add(1) will automatically fetch the latest version of the application.

For pkgng users, the equivalent command is:

# pkg install kde4

To build KDE from source, use the ports tree:

# cd /usr/ports/x11/kde4 # make install clean

The first time the port is installed, a menu will be shown for selecting options. Accepting the defaults is recommended.

KDE 4 is a large application, and will take quite some time to compile even on a fast computer.

After KDE has been installed, the X server must be told to launch this application instead of the default window manager. This is accomplished by editing the .xinitrc file:

% echo "exec /usr/local/kde4/bin/startkde" > ~/.xinitrc

Now, whenever the X Window System is invoked with startx, KDE will be the desktop.

If a display manager such as XDM is being used, the configuration is slightly different. Edit the .xsession file instead. Instructions for KDM are described later in this chapter.

6.7.3. More Details on KDE

Now that KDE is installed on the system, most things can be discovered through the help pages, or just by pointing and clicking at various menus. Windows® or Mac® users will feel quite at home.

The best reference for KDE is the on-line documentation. KDE comes with its own web browser, Konqueror, dozens of useful applications, and extensive documentation. The remainder of this section discusses the technical items that are difficult to learn by random exploration.

6.7.3.1. The KDE Display Manager

An administrator of a multi-user system may wish to have a graphical login screen to welcome users. XDM can be used, as described earlier. However, KDE includes an alternative, KDM, which is designed to look more attractive and include more login-time options. In particular, users can easily choose (via a menu) which desktop environment (KDE, GNOME, or something else) to run after logging on.

KDE 4 requires that procfs(5) be mounted, and this line must be added to /etc/rc.conf:

kdm4_enable="YES"

6.7.4. Xfce

6.7.4.1. About Xfce

Xfce is a desktop environment based on the GTK+ toolkit used by GNOME, but is much more lightweight and meant for those who want a simple, efficient desktop which is nevertheless easy to use and configure. Visually, it looks very much like CDE, found on commercial UNIX® systems. Some of Xfce's features are:

  • A simple, easy-to-handle desktop

  • Fully configurable via mouse, with drag and drop, etc.

  • Main panel similar to CDE, with menus, applets and applications launchers

  • Integrated window manager, file manager, sound manager, GNOME compliance module, and more

  • Themeable (since it uses GTK+)

  • Fast, light and efficient: ideal for older/slower machines or machines with memory limitations

More information on Xfce can be found on the Xfce website.

6.7.4.2. Installing Xfce

To install the Xfce from the network, simply type:

# pkg_add -r xfce4

For pkgng users, the equivalent command is:

# pkg install xfce4

Alternatively, to build from source, use the Ports Collection:

# cd /usr/ports/x11-wm/xfce4 # make install clean

Now, tell the X server to launch Xfce the next time X is started. Simply type this:

% echo "/usr/local/bin/startxfce4" > ~/.xinitrc

The next time X is started, Xfce will be the desktop. As before, if a display manager like XDM is being used, create an .xsession, as described in the section on GNOME, but with the /usr/local/bin/startxfce4 command; or, configure the display manager to allow choosing a desktop at login time, as explained in the section on kdm.

Part II. Common Tasks

Now that the basics have been covered, this part of the FreeBSD Handbook will discuss some frequently used features of FreeBSD. These chapters:

  • Introduce you to popular and useful desktop applications: browsers, productivity tools, document viewers, etc.

  • Introduce you to a number of multimedia tools available for FreeBSD.

  • Explain the process of building a customized FreeBSD kernel, to enable extra functionality on your system.

  • Describe the print system in detail, both for desktop and network-connected printer setups.

  • Show you how to run Linux applications on your FreeBSD system.

Some of these chapters recommend that you do some prior reading, and this is noted in the synopsis at the beginning of each chapter.

Chapter 7. Desktop Applications

Contributed by Christophe Juniet.

7.1. Synopsis

While FreeBSD is popular as a server for its performance and stability, it is also suited for day-to-day use as a desktop. With over 24,000 applications available as packages or ports, it is easy to build a customized desktop that runs a wide variety of desktop applications. This chapter demonstrates how to install some popular desktop applications effortlessly using packages or the FreeBSD Ports Collection.

As FreeBSD features Linux® binary compatibility, many applications developed for Linux® can be installed on a FreeBSD desktop. Many of the ports using Linux® binary compatibility start with linux-. This chapter assumes that Linux® binary compatibility has been enabled before any Linux® applications are installed.

This chapter demonstrates how to install the following desktop applications:

Type of ApplicationApplication NamePackage NamePorts Name
BrowserFirefoxfirefoxwww/firefox
BrowserOperaoperawww/opera
BrowserKonquerorkde4-baseappsx11/kde4-baseapps
BrowserChromiumchromiumwww/chromium
ProductivityCalligracalligraeditors/calligra
ProductivityAbiWordabiwordeditors/abiword
ProductivityThe GIMPgimpgraphics/gimp
ProductivityApache OpenOfficeopenofficeeditors/openoffice-3
ProductivityLibreOfficelibreofficeeditors/libreoffice
Document ViewerAcrobat Reader®no package due to license restrictionprint/acroread9
Document Viewergvgvprint/gv
Document ViewerXpdfxpdfgraphics/xpdf
Document ViewerGQviewgqviewgraphics/gqview
FinanceGnuCashgnucashfinance/gnucash
FinanceGnumericgnumericmath/gnumeric
FinanceKMyMoneykmymoney-kde4finance/kmymoney-kde4

Before reading this chapter, you should know how to:

  • Install additional software using packages or ports.

  • Enable Linux® binary compatibility.

For information on how to configure a multimedia environment, refer to Chapter 8, Multimedia. For information on how to set up and use electronic mail, refer to Chapter 28, Electronic Mail.

7.2. Browsers

FreeBSD does not come with a pre-installed web browser. Instead, the www category of the Ports Collection contains many browsers which can be installed as a package or compiled from the Ports Collection.

The KDE and GNOME desktop environments include their own HTML browser. Refer to Section 6.7, “Desktop Environments” for more information on how to set up these complete desktops.

Some light-weight browsers include www/dillo2, www/links, and www/w3m.

This section demonstrates how to install the following popular web browsers and indicates if the application is resource-heavy, takes time to compile from ports, or has any major dependencies.

Application NameResources NeededInstallation from PortsNotes
FirefoxmediumheavyFreeBSD and Linux® versions are available
OperalightlightFreeBSD and Linux® versions are available
KonquerormediumheavyRequires KDE libraries
ChromiummediumheavyRequires Gtk+

7.2.1. Firefox

Firefox is a modern, free, open source browser that is fully ported to FreeBSD. It features a standards-compliant HTML display engine, tabbed browsing, popup blocking, extensions, improved security, and more. Firefox is based on the Mozilla codebase.

Install the package of the latest release version of Firefox by typing:

# pkg_add -r firefox

To instead install Firefox Extended Support Release (ESR) version, use:

# pkg_add -r firefox-esr

Localized versions are available in www/firefox-i18n and www/firefox-esr-i18n.

The Ports Collection can instead be used to compile the desired version of firefox from source code. This example builds www/firefox, where firefox can be replaced with the ESR or localized version to install.

# cd /usr/ports/www/firefox # make install clean

7.2.1.1. Firefox and Java™ Plugin

Note:

The following sections assume that Firefox is already installed.

java/icedtea-web provides a free software web browser plugin for running Java applets. It can be installed as a package. To alternately compile the port:

# cd /usr/ports/java/icedtea-web # make install clean

Keep the default configuration options when compiling the port.

Once installed, start firefox, enter about:plugins in the location bar and press Enter. A page listing the installed plugins will be displayed. The Java plugin should be listed.

If the browser is unable to find the plugin, each user will have to run the following command and relaunch the browser:

% ln -s /usr/local/lib/IcedTeaPlugin.so \ $HOME/.mozilla/plugins/

7.2.1.2. Firefox and Adobe® Flash™ Plugin

A native Adobe® Flash™ plugin is not available for FreeBSD. However, a software layer (wrapper) for running the Linux® version of the plugin exists. This wrapper also provides support for other browser plugins such as RealPlayer®.

To install and enable this plugin:

  1. Install the www/nspluginwrapper port. Due to licensing restrictions, a package is not available. This port requires emulators/linux_base-f10 which is a large port.

  2. Install the www/linux-f10-flashplugin11 port. Due to licensing restrictions, a package is not available.

  3. # ln -s /usr/local/lib/npapi/linux-f10-flashplugin/libflashplayer.so \ /usr/local/lib/browser_plugins/

    Create the /usr/local/lib/browser_plugins directory if it is not already present.

  4. Before the plugin is first used, each user must run:

    % nspluginwrapper -v -a -i

    When the plugin port has been updated and reinstalled, each user must run:

    % nspluginwrapper -v -a -u

    Start the browser, enter about:plugins in the location bar and press Enter. A list of all the currently available plugins will be shown.

7.2.1.3. Firefox and Swfdec Flash™ Plugin

Swfdec is the library for decoding and rendering Flash™ animations. Swfdec-Mozilla is a plugin for Firefox browsers that uses the Swfdec library for playing SWF files. It is still in heavy development.

To install the package:

# pkg_add -r swfdec-plugin

If the package is not available, compile and install it from the Ports Collection:

# cd /usr/ports/www/swfdec-plugin # make install clean

Restart the browser for this plugin to take effect.

7.2.2. Opera

Opera is a full-featured and standards-compliant browser which is still lightweight and fast. It comes with a built-in mail and news reader, an IRC client, an RSS/Atom feeds reader, and more. It is available as a native FreeBSD version and as a version that runs under Linux® emulation.

This command installs the package of the FreeBSD version of Opera. Replace opera with linux-opera to instead install the Linux® version.

# pkg_add -r opera

Alternately, install either version through the Ports Collection. This example compiles the native version:

# cd /usr/ports/www/opera # make install clean

To install the Linux® version, substitute linux-opera in place of opera.

To install Adobe® Flash™ plugin support, first compile the www/linux-f10-flashplugin11 port, as a package is not available due to licensing restrictions. Then install either the www/opera-linuxplugins port or package. This example compiles both from ports:

# cd /usr/ports/www/linux-f10-flashplugin11 # make install clean # cd /usr/ports/www/opera-linuxplugins # make install clean

Once installed, check the presence of the plugin by starting the browser, entering opera:plugins in the location bar and pressing Enter. A list should appear with all the currently available plugins.

To add the Java plugin, follow the instructions for Firefox.

7.2.3. Konqueror

Konqueror is part of x11/kde4-baseapps. Konqueror is more than a web browser as it is also a file manager and a multimedia viewer.

Konqueror supports WebKit as well as its own KHTML. WebKit is a rendering engine used by many modern browsers including Chromium. To use WebKit with Konqueror on FreeBSD, install the www/kwebkitpart package or port. This example compiles the port:

# cd /usr/ports/www/kwebkitpart # make install clean

To enable WebKit within Konqueror, click Settings, Configure Konqueror. In the General settings page, click the drop-down menu next to Default web browser engine and change KHTML to WebKit.

Konqueror also supports Flash. A How To guide for getting Flash support on Konqueror is available at http://freebsd.kde.org/howtos/konqueror-flash.php.

7.2.4. Chromium

Chromium is an open source browser project that aims to build a safer, faster, and more stable web browsing experience. Chromium features tabbed browsing, popup blocking, extensions, and much more. Chromium is the open source project upon which the Google Chrome web browser is based.

Chromium can be installed as a package by typing:

# pkg_add -r chromium

Alternatively, Chromium can be compiled from source using the Ports Collection:

# cd /usr/ports/www/chromium # make install clean

Note:

The executable for Chromium is /usr/local/bin/chrome, not /usr/local/bin/chromium.

7.2.4.1. Chromium and Java™ Plugin

Note:

The following sections assume that Chromium is already installed.

To install Java™ plugin support, follow the instructions in Section 7.2.1.1, “Firefox and Java™ Plugin”.

Once Java™ support is installed, start Chromium, and enter about:plugins in the address bar. IcedTea-Web should be listed as one of the installed plugins.

If Chromium does not display the IcedTea-Web plugin, run the following commands, and restart the web browser:

# mkdir -p /usr/local/share/chromium/plugins # ln -s /usr/local/lib/IcedTeaPlugin.so \ /usr/local/share/chromium/plugins/

7.2.4.2. Chromium and Adobe® Flash™ Plugin

Configuring Chromium and Adobe® Flash™ is similar to the instructions for Firefox. No additional configuration should be necessary, since Chromium is able to use some plugins from other browsers.

7.3. Productivity

When it comes to productivity, new users often look for a good office suite or a friendly word processor. While some desktop environments like KDE already provide an office suite, there is no default productivity package. Several office suites and word processors are available for FreeBSD, regardless of the installed desktop environment.

This section demonstrates how to install the following popular productivity software and indicates if the application is resource-heavy, takes time to compile from ports, or has any major dependencies.

Application NameResources NeededInstallation from PortsMajor Dependencies
CalligralightheavyKDE
AbiWordlightlightGtk+ or GNOME
The GimplightheavyGtk+
Apache OpenOfficeheavyhugeJDK and Mozilla
LibreOfficesomewhat heavyhugeGtk+, or KDE/ GNOME, or JDK

7.3.1. Calligra

The KDE community provides its desktop environment with an office suite which can be used outside of KDE. Calligra includes standard components that can be found in other office suites. Words is the word processor, Sheets is the spreadsheet program, Stage manages slide presentations, and Karbon is used to draw graphical documents.

editors/calligra can be installed as a package or a port. To install the package:

# pkg_add -r calligra

If the package is not available, use the Ports Collection instead:

# cd /usr/ports/editors/calligra # make install clean

7.3.2. AbiWord

AbiWord is a free word processing program similar in look and feel to Microsoft® Word. It is suitable for typing papers, letters, reports, memos, and so forth. It is fast, contains many features, and is user-friendly.

AbiWord can import or export many file formats, including some proprietary ones like Microsoft® .doc.

To install the AbiWord package:

# pkg_add -r abiword

If the package is not available, it can be compiled from the Ports Collection:

# cd /usr/ports/editors/abiword # make install clean

7.3.3. The GIMP

For image authoring or picture retouching, The GIMP provides a sophisticated image manipulation program. It can be used as a simple paint program or as a quality photo retouching suite. It supports a large number of plugins and features a scripting interface. The GIMP can read and write a wide range of file formats and supports interfaces with scanners and tablets.

To install the package:

# pkg_add -r gimp

Alternately, use the Ports Collection:

# cd /usr/ports/graphics/gimp # make install clean

The graphics category of the Ports Collection contains several GIMP-related plugins, help files, and user manuals.

7.3.4. Apache OpenOffice

On 1 June 2011, Oracle® donated the OpenOffice.org code base to the Apache Software Foundation. OpenOffice.org is now known as Apache OpenOffice and is developed under the wing of the Apache Software Foundation's Incubator.

Apache OpenOffice includes all of the mandatory applications in a complete office productivity suite: a word processor, spreadsheet, presentation manager, and drawing program. Its user interface is very similar to other office suites, and it can import and export in various popular file formats. It is available in a number of different languages and internationalization has been extended to interfaces, spell checkers, and dictionaries.

The word processor of Apache OpenOffice uses a native XML file format for increased portability and flexibility. The spreadsheet program features a macro language which can be interfaced with external databases. Apache OpenOffice is stable and runs natively on Windows®, Solaris™, Linux®, FreeBSD, and Mac OS® X. More information about Apache OpenOffice can be found on the Apache OpenOffice web site. For FreeBSD specific information, and to directly download packages, refer to the web site of the FreeBSD Apache OpenOffice Porting Team.

To install the Apache OpenOffice package:

# pkg_add -r apache-openoffice

Note:

When running a -RELEASE version of FreeBSD, this should work. Otherwise, download the latest package from the website of the FreeBSD Apache OpenOffice Porting Team and install it using pkg_add(1). Both the current release and development versions are available for download at this web site.

Once the package is installed, type the following command to launch Apache OpenOffice:

% openoffice-X.Y.Z

where X.Y.Z is the version number of the installed version of Apache OpenOffice.

Note:

During the first launch, some questions will be asked and a .openoffice.org folder will be created in the user's home directory.

If the desired Apache OpenOffice package is not available, compiling the port is still an opton. However, this requires a lot of disk space and a fairly long time to compile:

# cd /usr/ports/editors/openoffice-3 # make install clean

Note:

To build a localized version, replace the previous command with:

# make LOCALIZED_LANG=your_language install clean

Replace your_language with the correct language ISO-code. A list of supported language codes is available in files/Makefile.localized, located in the port's directory.

7.3.5. LibreOffice

LibreOffice is a free software office suite developed by The Document Foundation. It is compatible with other major office suites and available on a variety of platforms. It is a rebranded fork of OpenOffice.org which includes all of the mandatory applications in a complete office productivity suite: a word processor, spreadsheet, presentation manager, drawing program, database management program, and a tool for creating and editing mathematical formula. It is available in a number of different languages and internationalization has been extended to interfaces, spell checkers, and dictionaries.

The word processor of LibreOffice uses a native XML file format for increased portability and flexibility. The spreadsheet program features a macro language which can be interfaced with external databases. LibreOffice is stable and runs natively on Windows®, Linux®, FreeBSD, and Mac OS® X. More information about LibreOffice can be found on the LibreOffice web site.

To install the English version of the LibreOffice package:

# pkg_add -r libreoffice

The editors category of the Ports Collection contains several localizations for LibreOffice. When installing a localized package, replace libreoffice with the name of the localized package.

Once the package is installed, type the following command to run LibreOffice:

% libreoffice

Note:

During the first launch, some questions will be asked and a .libreoffice folder will be created in the user's home directory.

If the desired LibreOffice package is not available, compiling the port is still an option. However, this requires a lot of disk space and a fairly long time to compile. This example compiles the English version:

# cd /usr/ports/editors/libreoffice # make install clean

Note:

To build a localized version, cd into the port directory of the desired language. Supported languages can be found in the editors category of the Ports Collection.

7.4. Document Viewers

Some new document formats have gained popularity since the advent of UNIX® and the viewers they require may not be available in the base system. This section demonstrates how to install the following viewers:

Application NameResources NeededInstallation from PortsMajor Dependencies
Acrobat Reader®lightlightLinux® binary compatibility
gvlightlightXaw3d
XpdflightlightFreeType
GQviewlightlightGtk+ or GNOME

7.4.1. Acrobat Reader®

Many documents are now distributed as Portable Document Format (PDF) files. One popular viewer for PDFs is Acrobat Reader®, released by Adobe® for Linux®. As FreeBSD can run Linux® binaries, it is also available for FreeBSD. Due to licensing restrictions, a package is not available so it must be compiled from ports. Several localizations are available from the print category of the Ports Collection.

This command installs the English version of Acrobat Reader® 9 from the Ports Collection. To instead install a localized version, cd into the desired port's directory.

# cd /usr/ports/print/acroread9 # make install clean

7.4.2. gv

gv is a PostScript® and PDF viewer. It is based on ghostview, but has a nicer look due to the Xaw3d library. It is fast with a clean interface. gv has many configurable features, such as orientation, paper size, scale, and anti-aliasing. Almost any operation can be performed with either the keyboard or the mouse.

To install gv as a package:

# pkg_add -r gv

If a package is unavailable, use the Ports Collection:

# cd /usr/ports/print/gv # make install clean

7.4.3. Xpdf

For users that prefer a small FreeBSD PDF viewer, xpdf provides a light-weight and efficient viewer which requires few resources. It uses the standard X fonts and does not require Motif® or any other X toolkit.

To install the Xpdf package:

# pkg_add -r xpdf

If the package is not available, use the Ports Collection:

# cd /usr/ports/graphics/xpdf # make install clean

Once the installation is complete, launch xpdf and use the right mouse button to activate the menu.

7.4.4. GQview

GQview is an image manager which supports viewing a file with a single click, launching an external editor, and thumbnail previews. It also features a slideshow mode and some basic file operations, making it easy to manage image collections and to find duplicate files. GQview supports full screen viewing and internationalization.

To install the GQview package:

# pkg_add -r gqview

If the package is not available, use the Ports Collection:

# cd /usr/ports/graphics/gqview # make install clean

7.5. Finance

For managing personal finances on a FreeBSD desktop, some powerful and easy-to-use applications can be installed. Some are compatible with widespread file formats, such as the formats used by Quicken® and Excel.

This section covers these programs:

Application NameResources NeededInstallation from PortsMajor Dependencies
GnuCashlightheavyGNOME
GnumericlightheavyGNOME
KMyMoneylightheavyKDE

7.5.1. GnuCash

GnuCash is part of the GNOME effort to provide user-friendly, yet powerful, applications to end-users. GnuCash can be used to keep track of income and expenses, bank accounts, and stocks. It features an intuitive interface while remaining professional.

GnuCash provides a smart register, a hierarchical system of accounts, and many keyboard accelerators and auto-completion methods. It can split a single transaction into several more detailed pieces. GnuCash can import and merge Quicken QIF files. It also handles most international date and currency formats.

To install the GnuCash package:

# pkg_add -r gnucash

If the package is not available, use the Ports Collection:

# cd /usr/ports/finance/gnucash # make install clean

7.5.2. Gnumeric

Gnumeric is a spreadsheet program developed by the GNOME community. It features convenient automatic guessing of user input according to the cell format with an autofill system for many sequences. It can import files in a number of popular formats, including Excel, Lotus 1-2-3, and Quattro Pro. It has a large number of built-in functions and allows all of the usual cell formats such as number, currency, date, time, and much more.

To install Gnumeric as a package:

# pkg_add -r gnumeric

If the package is not available, use the Ports Collection:

# cd /usr/ports/math/gnumeric # make install clean

7.5.3. KMyMoney

KMyMoney is a personal finance application created by the KDE community. KMyMoney intends to provide and incorporate all the important features found in commercial personal finance manager applications. It also highlights ease-of-use and proper double-entry accounting among its features. KMyMoney imports from standard Quicken Interchange Format (QIF) files, tracks investments, handles multiple currencies, and provides a wealth of reports.

To install KMyMoney as a package:

# pkg_add -r kmymoney-kde4

If the package is not available, use the Ports Collection:

# cd /usr/ports/finance/kmymoney-kde4 # make install clean

Chapter 8. Multimedia

Edited by Ross Lippert.

8.1. Synopsis

FreeBSD supports a wide variety of sound cards, allowing users to enjoy high fidelity output from a FreeBSD system. This includes the ability to record and playback audio in the MPEG Audio Layer 3 (MP3), Waveform Audio File (WAV), Ogg Vorbis, and other formats. The FreeBSD Ports Collection contains many applications for editing recorded audio, adding sound effects, and controlling attached MIDI devices.

FreeBSD also supports the playback of video files and DVDs. The FreeBSD Ports Collection contains applications to encode, convert, and playback various video media.

This chapter describes how to configure sound cards, video playback, TV tuner cards, and scanners on FreeBSD. It also describes some of the applications which are available for using these devices.

After reading this chapter, you will know how to:

  • Configure a sound card on FreeBSD.

  • Troubleshoot the sound setup.

  • Playback and encode MP3s and other audio.

  • Prepare a FreeBSD system for video playback.

  • Playback DVDs, .mpg, and .avi files.

  • Rip CD and DVD content into files.

  • Configure a TV card.

  • Install and setup MythTV on FreeBSD

  • Configure an image scanner.

  • How to configure an image scanner.

Before reading this chapter, you should:

Warning:

Audio CDs have specialized encodings which differ from the usual ISO-filesystem. This means that they should not be mounted using mount(8).

8.2. Setting Up the Sound Card

Contributed by Moses Moore.
Enhanced by Marc Fonvieille.

8.2.1. Configuring the System

Before beginning the configuration, determine the model of the sound card and the chip it uses. FreeBSD supports a wide variety of sound cards. Check the supported audio devices list of the Hardware Notes to see if the card is supported and which FreeBSD driver it uses.

In order to use the sound device, the proper device driver must be loaded. This may be accomplished in one of two ways. The easiest way is to load a kernel module for the sound card with kldload(8). This example loads the driver for a Creative SoundBlaster® Live! sound card:

# kldload snd_emu10k1

To automate the loading of this driver at boot time, add the driver to /boot/loader.conf. The line for this driver is:

snd_emu10k1_load="YES"

Other available sound modules are listed in /boot/defaults/loader.conf. When unsure which driver to use, load the snd_driver module:

# kldload snd_driver

This is a metadriver which loads all of the most common sound drivers and can be used to speed up the search for the correct driver. It is also possible to load all sound drivers by adding the metadriver to /boot/loader.conf.

To determine which driver was selected for the sound card after loading the snd_driver metadriver, type cat /dev/sndstat.

Users who prefer to statically compile in support for the sound card in a custom kernel should refer to the instructions in the next section. For more information about recompiling a kernel, refer to Chapter 9, Configuring the FreeBSD Kernel.

8.2.1.1. Configuring a Custom Kernel with Sound Support

When using a custom kernel to provide sound support, make sure that the audio framework driver exists in the custom kernel configuration file:

device sound

Next, add support for the sound card. Therefore, you need to know which driver supports the card. To continue the example of the Creative SoundBlaster® Live! sound card from the previous section, use the following line in the custom kernel configuration file:

device snd_emu10k1

Be sure to read the manual page of the driver for the syntax to use. The explicit syntax for the kernel configuration of every supported sound driver can also be found in /usr/src/sys/conf/NOTES.

Non-PnP ISA sound cards may require the IRQ and I/O port settings of the card to be added to /boot/device.hints. During the boot process, loader(8) reads this file and passes the settings to the kernel. For example, an old Creative SoundBlaster® 16 ISA non-PnP card will use the snd_sbc(4) driver in conjunction with snd_sb16. For this card, the following lines must be added to the kernel configuration file:

device snd_sbc device snd_sb16

If the card uses the 0x220 I/O port and IRQ 5, these lines must also be added to /boot/device.hints:

hint.sbc.0.at="isa" hint.sbc.0.port="0x220" hint.sbc.0.irq="5" hint.sbc.0.drq="1" hint.sbc.0.flags="0x15"

In this case, the card uses the 0x220 I/O port and the IRQ 5.

The syntax used in /boot/device.hints is described in sound(4) and the manual page for the driver of the sound card.

The settings shown above are the defaults. In some cases, the IRQ or other settings may need to be changed to match the card. Refer to snd_sbc(4) for more information about this card.

8.2.2. Testing the Sound Card

After rebooting into the custom kernel, or after loading the required module, the sound card should appear in the system message buffer. Run dmesg(8) and look for a message like:

pcm0: <Intel ICH3 (82801CA)> port 0xdc80-0xdcbf,0xd800-0xd8ff irq 5 at device 31.5 on pci0 pcm0: [GIANT-LOCKED] pcm0: <Cirrus Logic CS4205 AC97 Codec>

The status of the sound card may also be checked using this command:

# cat /dev/sndstat FreeBSD Audio Driver (newpcm) Installed devices: pcm0: <Intel ICH3 (82801CA)> at io 0xd800, 0xdc80 irq 5 bufsz 16384 kld snd_ich (1p/2r/0v channels duplex default)

The output may vary between systems. If no pcm devices are listed, go back and review the kernel configuration file and make sure the correct device driver was chosen. Common problems are listed in Section 8.2.2.1, “Common Problems”.

If all goes well, the sound card should now work in os;. If the CD-ROM or DVD-ROM drive's audio-out pins are properly connected to the sound card, one can insert an audio CD in the drive and play it with cdcontrol(1):

% cdcontrol -f /dev/acd0 play 1

Various applications, such as audio/workman provide a friendlier interface. The audio/mpg123 port can be installed to listen to MP3 audio files.

Another quick way to test the card is to send data to /dev/dsp:

% cat filename > /dev/dsp

where filename can be any file. This command should produce some noise, confirming that the sound card is actually working.

Note:

The /dev/dsp* device nodes will be created automatically as needed. When not in use, they do not exist and will not appear in the output of ls(1).

Sound card mixer levels can be changed using mixer(8). More details can be found in mixer(8).

8.2.2.1. Common Problems

ErrorSolution
sb_dspwr(XX) timed out

The I/O port is not set correctly.

bad irq XX

The IRQ is set incorrectly. Make sure that the set IRQ and the sound IRQ are the same.

xxx: gus pcm not attached, out of memory

There is not enough available memory to use the device.

xxx: can't open /dev/dsp!

Check with fstat | grep dsp if another application is holding the device open. Noteworthy troublemakers are esound and KDE's sound support.

Another issue is that modern graphics cards often come with their own sound driver, for use with HDMI and similar. This sound device will sometimes be enumerated before the sound card and the sound card will subsequently not be used as the default playback device. To check if this is the case, run dmesg and look for pcm. The output looks something like this:

... hdac0: HDA Driver Revision: 20100226_0142 hdac1: HDA Driver Revision: 20100226_0142 hdac0: HDA Codec #0: NVidia (Unknown) hdac0: HDA Codec #1: NVidia (Unknown) hdac0: HDA Codec #2: NVidia (Unknown) hdac0: HDA Codec #3: NVidia (Unknown) pcm0: <HDA NVidia (Unknown) PCM #0 DisplayPort> at cad 0 nid 1 on hdac0 pcm1: <HDA NVidia (Unknown) PCM #0 DisplayPort> at cad 1 nid 1 on hdac0 pcm2: <HDA NVidia (Unknown) PCM #0 DisplayPort> at cad 2 nid 1 on hdac0 pcm3: <HDA NVidia (Unknown) PCM #0 DisplayPort> at cad 3 nid 1 on hdac0 hdac1: HDA Codec #2: Realtek ALC889 pcm4: <HDA Realtek ALC889 PCM #0 Analog> at cad 2 nid 1 on hdac1 pcm5: <HDA Realtek ALC889 PCM #1 Analog> at cad 2 nid 1 on hdac1 pcm6: <HDA Realtek ALC889 PCM #2 Digital> at cad 2 nid 1 on hdac1 pcm7: <HDA Realtek ALC889 PCM #3 Digital> at cad 2 nid 1 on hdac1 ...

Here the graphics card (NVidia) has been enumerated before the sound card (Realtek ALC889). To use the sound card as the default playback device, change hw.snd.default_unit to the unit that should be used for playback:

# sysctl hw.snd.default_unit=n

Here, n is the number of the sound device to use. In this example, it should be 4. Make this change permanent by adding the following line to /etc/sysctl.conf:

hw.snd.default_unit=4

8.2.3. Utilizing Multiple Sound Sources

Contributed by Munish Chopra.

It is often desirable to have multiple sources of sound that are able to play simultaneously. FreeBSD uses Virtual Sound Channels, which can be enabled using sysctl(8). Virtual channels allow one to multiplex the sound card's playback by mixing sound in the kernel.

To set the number of virtual channels, three sysctl(8) knobs are available:

# sysctl dev.pcm.0.play.vchans=4 # sysctl dev.pcm.0.rec.vchans=4 # sysctl hw.snd.maxautovchans=4

The above example allocates four virtual channels, which is a practical number for everyday use. Both dev.pcm.0.play.vchans=4 and dev.pcm.0.rec.vchans=4 are the number of virtual channels pcm0 has for playback and recording, and are configurable after a device has been attached. hw.snd.maxautovchans is the number of virtual channels a new audio device is given when it is attached using kldload(8). Since the pcm module can be loaded independently of the hardware drivers, hw.snd.maxautovchans indicates how many virtual channels will be given to devices when they are attached. Refer to pcm(4) for more information.

Note:

The number of virtual channels for a device cannot be changed while it is in use. First, close any programs using the device, such as music players or sound daemons.

The correct pcm device will automatically be allocated transparently to a program that requests /dev/dsp0.

8.2.4. Setting Default Values for Mixer Channels

Contributed by Josef El-Rayes.

The default values for the different mixer channels are hardcoded in the source code of the pcm(4) driver. There are many different applications and daemons that allow values to be set for the mixer that are remembered between invocations, but this is not a clean solution. It is possible to set default mixer values at the driver level. This is accomplished by defining the appropriate values in /boot/device.hints, as seen in this example:

hint.pcm.0.vol="50"

This will set the volume channel to a default value of 50 when the pcm(4) module is loaded.

8.3. MP3 Audio

Contributed by Chern Lee.

This section describes some MP3 players available for FreeBSD, how to rip audio CD tracks, and how to encode and decode MP3s.

8.3.1. MP3 Players

A popular graphical MP3 player is XMMS. Winamp skins can be used with XMMS since the interface is almost identical to that of Nullsoft's Winamp. XMMS also has native plug-in support.

XMMS can be installed from the multimedia/xmms port or package.

XMMS's interface is intuitive, with a playlist, graphic equalizer, and more. Those familiar with Winamp will find XMMS simple to use.

The audio/mpg123 port provides an alternative, command-line MP3 player.

mpg123 can be run by specifying the sound device and the MP3 file on the command line. Assuming the audio device is /dev/dsp1.0 and the MP3 file is Foobar-GreatestHits.mp3, enter the following to play the file:

# mpg123 -a /dev/dsp1.0 Foobar-GreatestHits.mp3 High Performance MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2 and 3. Version 0.59r (1999/Jun/15). Written and copyrights by Michael Hipp. Uses code from various people. See 'README' for more! THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK! Playing MPEG stream from Foobar-GreatestHits.mp3 ... MPEG 1.0 layer III, 128 kbit/s, 44100 Hz joint-stereo

8.3.2. Ripping CD Audio Tracks

Before encoding a CD or CD track to MP3, the audio data on the CD must be ripped to the hard drive. This is done by copying the raw CD Digital Audio (CDDA) data to WAV files.

The cdda2wav tool, which is installed with the sysutils/cdrtools suite, is used for ripping audio information from CDs and the information associated with them.

With the audio CD in the drive, the following command can be issued as root to rip an entire CD into individual (per track) WAV files:

# cdda2wav -D 0,1,0 -B

The -D 0,1,0 indicates the SCSI device 0,1,0, which corresponds to the output of cdrecord -scanbus.

cdda2wav will support ATAPI (IDE) CDROM drives. To rip from an IDE drive, specify the device name in place of the SCSI unit numbers. For example, to rip track 7 from an IDE drive:

# cdda2wav -D /dev/acd0 -t 7

To rip individual tracks, make use of the -t as shown:

# cdda2wav -D 0,1,0 -t 7

This example rips track seven of the audio CDROM. To rip a range of tracks, such as track one to seven, specify a range:

# cdda2wav -D 0,1,0 -t 1+7

dd(1) can also be used to extract audio tracks on ATAPI drives, as described in Section 19.5.5, “Duplicating Audio CDs”.

8.3.3. Encoding MP3s

Lame is a popular MP3 encoder which can be installed from the audio/lame port. Due to licensing restrictions, a package is not available.

The following command will convert the ripped WAV files audio01.wav to audio01.mp3:

# lame -h -b 128 \ --tt "Foo Song Title" \ --ta "FooBar Artist" \ --tl "FooBar Album" \ --ty "2001" \ --tc "Ripped and encoded by Foo" \ --tg "Genre" \ audio01.wav audio01.mp3

128 kbits is a standard MP3 bitrate. The 160 and 192 bitrates provide higher quality. The higher the bitrate, the larger the size of the resulting MP3. -h turns on the higher quality but a little slower mode. The options beginning with --t indicate ID3 tags, which usually contain song information, to be embedded within the MP3 file. Additional encoding options can be found in the lame manual page.

8.3.4. Decoding MP3s

In order to burn an audio CD from MP3s, they must first be converted to a non-compressed WAV format. Both XMMS and mpg123 support the output of MP3 to an uncompressed file format.

Writing to Disk in XMMS:

  1. Launch XMMS.

  2. Right-click the window to bring up the XMMS menu.

  3. Select Preferences under Options.

  4. Change the Output Plugin to Disk Writer Plugin.

  5. Press Configure.

  6. Enter or browse to a directory to write the uncompressed files to.

  7. Load the MP3 file into XMMS as usual, with volume at 100% and EQ settings turned off.

  8. Press Play. The XMMS will appear as if it is playing the MP3, but no music will be heard. It is actually playing the MP3 to a file.

  9. When finished, be sure to set the default Output Plugin back to what it was before in order to listen to MP3s again.

Writing to stdout in mpg123:

  • Run mpg123 -s audio01.mp3 > audio01.pcm

XMMS writes a file in the WAV format, while mpg123 converts the MP3 into raw PCM audio data. Both of these formats can be used with cdrecord to create audio CDs, whereas burncd(8) requires a raw Pulse-Code Modulation (PCM). When using WAV files, there will be a small tick sound at the beginning of each track. This sound is the header of the WAV file. One can remove the header with SoX, which can be installed from the audio/sox port or package:

% sox -t wav -r 44100 -s -w -c 2 track.wav track.raw

Refer to Section 19.5, “Creating and Using CD Media” for more information on using a CD burner in FreeBSD.

8.4. Video Playback

Contributed by Ross Lippert.

Before configuring video playback, determine the model of the video card and the chip it uses. While Xorg supports a wide variety of video cards, fewer give good playback performance. To obtain a list of extensions supported by the Xorg server using the card, run xdpyinfo(1) while Xorg is running.

It is a good idea to have a short MPEG test file for evaluating various players and options. Since some DVD applications look for DVD media in /dev/dvd by default, or have this device name hardcoded in them, it might be useful to make symbolic links to the proper devices:

# ln -sf /dev/acd0 /dev/dvd # ln -sf /dev/acd0 /dev/rdvd

Due to the nature of devfs(5), manually created links will not persist after a system reboot. In order to create the symbolic links automatically when the system boots, add the following lines to /etc/devfs.conf:

link acd0 dvd link acd0 rdvd

DVD decryption invokes special DVD-ROM functions and requires write permission on the DVD devices.

To enhance the shared memory Xorg interface, it is recommended to increase the values of these sysctl(8) variables:

kern.ipc.shmmax=67108864 kern.ipc.shmall=32768

8.4.1. Determining Video Capabilities

There are several possible ways to display video under Xorg. What works is largely hardware dependent. Each method described below will have varying quality across different hardware.

Common video interfaces include:

  1. Xorg: normal output using shared memory.

  2. XVideo: an extension to the Xorg interface which supports video in any drawable object.

  3. SDL: the Simple Directmedia Layer.

  4. DGA: the Direct Graphics Access.

  5. SVGAlib: low level console graphics layer.

8.4.1.1. XVideo

Xorg has an extension called XVideo, also known as Xvideo, Xv, and xv. It allows video to be directly displayed in drawable objects through a special acceleration. This extension provides good quality playback even on low-end machines.

To check whether the extension is running, use xvinfo:

% xvinfo

XVideo is supported for the card if the result looks like:

X-Video Extension version 2.2 screen #0 Adaptor #0: "Savage Streams Engine" number of ports: 1 port base: 43 operations supported: PutImage supported visuals: depth 16, visualID 0x22 depth 16, visualID 0x23 number of attributes: 5 "XV_COLORKEY" (range 0 to 16777215) client settable attribute client gettable attribute (current value is 2110) "XV_BRIGHTNESS" (range -128 to 127) client settable attribute client gettable attribute (current value is 0) "XV_CONTRAST" (range 0 to 255) client settable attribute client gettable attribute (current value is 128) "XV_SATURATION" (range 0 to 255) client settable attribute client gettable attribute (current value is 128) "XV_HUE" (range -180 to 180) client settable attribute client gettable attribute (current value is 0) maximum XvImage size: 1024 x 1024 Number of image formats: 7 id: 0x32595559 (YUY2) guid: 59555932-0000-0010-8000-00aa00389b71 bits per pixel: 16 number of planes: 1 type: YUV (packed) id: 0x32315659 (YV12) guid: 59563132-0000-0010-8000-00aa00389b71 bits per pixel: 12 number of planes: 3 type: YUV (planar) id: 0x30323449 (I420) guid: 49343230-0000-0010-8000-00aa00389b71 bits per pixel: 12 number of planes: 3 type: YUV (planar) id: 0x36315652 (RV16) guid: 52563135-0000-0000-0000-000000000000 bits per pixel: 16 number of planes: 1 type: RGB (packed) depth: 0 red, green, blue masks: 0x1f, 0x3e0, 0x7c00 id: 0x35315652 (RV15) guid: 52563136-0000-0000-0000-000000000000 bits per pixel: 16 number of planes: 1 type: RGB (packed) depth: 0 red, green, blue masks: 0x1f, 0x7e0, 0xf800 id: 0x31313259 (Y211) guid: 59323131-0000-0010-8000-00aa00389b71 bits per pixel: 6 number of planes: 3 type: YUV (packed) id: 0x0 guid: 00000000-0000-0000-0000-000000000000 bits per pixel: 0 number of planes: 0 type: RGB (packed) depth: 1 red, green, blue masks: 0x0, 0x0, 0x0

The formats listed, such as YUV2 and YUV12, are not present with every implementation of XVideo and their absence may hinder some players.

If the result looks like:

X-Video Extension version 2.2 screen #0 no adaptors present

XVideo is probably not supported for the card. This means that it will be more difficult for the display to meet the computational demands of rendering video. Depending on the video card and processor, one might still be able to have a satisfying experience.

8.4.1.2. Simple Directmedia Layer

The Simple Directmedia Layer, SDL, is a porting layer for many operating systems allowing cross-platform applications to be developed which make efficient use of sound and graphics. The SDL layer provides a low-level abstraction to the hardware which can sometimes be more efficient than the Xorg interface.

SDL can be installed using the devel/sdl12 package or port.

8.4.1.3. Direct Graphics Access

DGA is an Xorg extension which allows a program to bypass the Xorg server and directly alter the framebuffer. Because it relies on a low level memory mapping, programs using it must be run as root.

The DGA extension can be tested and benchmarked using dga(1). When dga is running, it changes the colors of the display whenever a key is pressed. To quit, press q.

8.4.2. Ports and Packages Dealing with Video

This section introduces some of the software available from the FreeBSD Ports Collection which can be used for video playback.

Many of the video applications which run on FreeBSD were developed as Linux® applications. Many of these applications are still beta-quality. Some of the problems commonly encountered with video packages on FreeBSD include:

  1. An application cannot playback a file which another application produced.

  2. An application cannot playback a file which the application itself produced.

  3. The same application on two different machines, rebuilt on each machine for that machine, plays back the same file differently.

  4. A seemingly trivial filter, like rescaling of the image size, results in bad artifacts from a buggy rescaling routine.

  5. An application frequently dumps core.

  6. Documentation is not installed with the port and can be found either on the web or under the port's work directory.

Many applications may also exhibit Linux®-isms. There may be issues resulting from the way some standard libraries are implemented in the Linux® distributions, or some features of the Linux® kernel which have been assumed by the authors of the applications. These issues are not always noticed and worked around by the port maintainers, which can lead to problems like these:

  1. The use of /proc/cpuinfo to detect processor characteristics.

  2. A misuse of threads which causes a program to hang upon completion instead of truly terminating.

  3. Relies on software which is not yet available in the FreeBSD Ports Collection.

8.4.2.1. MPlayer

MPlayer is a command-line video player with an optional graphical interface which aims to provide speed and flexibility. This application, as well as other graphical front-ends, is available from the FreeBSD Ports Collection.

8.4.2.1.1. Building MPlayer

MPlayer is available as a package or port in multimedia/mplayer. Several compile options are available and a variety of hardware checks occur during the build process. For these reasons, some users prefer to build the port rather than install the package. The available options will be displayed in a menu after these commands are input:

# cd /usr/ports/multimedia/mplayer # make

The menu options should be reviewed to determine the type of support to compile into the port. If an option is not selected, MPlayer will not be able to display that type of video format. Use the arrow keys and spacebar to select the required formats. When finished, press Enter to continue the port compile and installation.

By default, this package or port will build the mplayer command line utility and the gmplayer graphical utility. To encode videos, install the multimedia/mencoder port. Due to licensing restrictions, a package is not available for MEncoder.

8.4.2.1.2. Using MPlayer

The first time MPlayer is run, it will create ~/.mplayer in the user's home directory. This subdirectory contains default versions of the user-specific configuration files.

This section describes only a few common uses. Refer to the mplayer manual page for a complete description of its numerous options.

To play the file testfile.avi, specify the video interfaces with -vo:

% mplayer -vo xv testfile.avi
% mplayer -vo sdl testfile.avi
% mplayer -vo x11 testfile.avi
# mplayer -vo dga testfile.avi
# mplayer -vo 'sdl:dga' testfile.avi

It is worth trying all of these options, as their relative performance depends on many factors and will vary significantly with hardware.

To play a DVD, replace the testfile.avi with dvd://N -dvd-device DEVICE, where N is the title number to play and DEVICE is the device node for the DVD-ROM. For example, to play title 3 from /dev/dvd:

# mplayer -vo xv dvd://3 -dvd-device /dev/dvd

Note:

The default DVD device can be defined during the build of the MPlayer port by including the WITH_DVD_DEVICE=/path/to/desired/device option. By default, the device is /dev/acd0. More details can be found in the port's Makefile.options.

To stop, pause, advance, and so on, consult the keybindings, which are displayed by running mplayer -h, or read the manual page.

Additional playback options include -fs -zoom, which engages fullscreen mode, and -framedrop, which helps performance.

Each user can add commonly used options to their ~/.mplayer/config like so:

vo=xv fs=yes zoom=yes

mplayer can be used to rip a DVD title to a .vob. To dump the second title from a DVD:

# mplayer -dumpstream -dumpfile out.vob dvd://2 -dvd-device /dev/dvd

The output file, out.vob, will be MPEG and can be manipulated by the other packages described in this section.

The MPlayer documentation is technically informative and should be consulted by anyone wishing to obtain a high level of expertise with UNIX® video. The MPlayer mailing list is hostile to anyone who has not bothered to read the documentation, so before making a bug report, read the documentation first.

8.4.2.1.3. MEncoder

Before using mencoder, it is a good idea to become familiar with the options described in the HTML documentation. There are innumerable ways to improve quality, lower bitrate, and change formats, and some of these options may make the difference between good or bad performance. Improper combinations of command line options can yield output files that are unplayable even by mplayer.

Here is an example of a simple copy:

% mencoder input.avi -oac copy -ovc copy -o output.avi

To rip to a file, use -dumpfile with mplayer.

To convert input.avi to the MPEG4 codec with MPEG3 audio encoding, first install the audio/lame port. Due to licensing restrictions, a package is not available. Once installed, type:

% mencoder input.avi -oac mp3lame -lameopts br=192 \ -ovc lavc -lavcopts vcodec=mpeg4:vhq -o output.avi

This will produce output playable by applications such as mplayer and xine.

input.avi can be replaced with dvd://1 -dvd-device /dev/dvd and run as root to re-encode a DVD title directly. Since it may take a few tries to get the desired result, it is recommended to dump the title to a file and to work on the file.

8.4.2.2. The xine Video Player

xine is a video player with a reusable base library and a modular executable which can be extended with plugins. It can be installed using the multimedia/xine package or port.

In practice, xine requires either a fast CPU with a fast video card, or support for the XVideo extension. The xine video player performs best on XVideo interfaces.

By default, the xine player starts a graphical user interface. The menus can then be used to open a specific file.

Alternatively, xine may be invoked to play a file immediately without the graphical interface:

% xine

Alternatively, it may be invoked to play a file immediately without the GUI with the command:

% xine -g -p mymovie.avi

The xine HOWTO contains a chapter on performance improvement which is general to all players.

8.4.2.3. The transcode Utilities

transcode provides a suite of tools for re-encoding video and audio files. transcode can be used to merge video files or repair broken files using command line tools with stdin/stdout stream interfaces.

transcode can be installed using the multimedia/transcode package or port. Many users prefer to compile the port as it provides a menu of compile options for specifying the support and codecs to compile in. If an option is not selected, transcode will not be able to encode that format. Use the arrow keys and spacebar to select the required formats. When finished, press Enter to continue the port compile and installation.

This example demonstrates how to convert a DivX file into a PAL MPEG-1 file (PAL VCD):

% transcode -i input.avi -V --export_prof vcd-pal -o output_vcd % mplex -f 1 -o output_vcd.mpg output_vcd.m1v output_vcd.mpa

The resulting MPEG file, output_vcd.mpg, is ready to be played with MPlayer. The file can be burned on a CD-R media to create a Video CD. In this, install and use the multimedia/vcdimager and sysutils/cdrdao programs.

In addition to the manual page for transcode, refer to the transcode wiki for further information and examples.

8.5. Setting Up TV Cards

Original contribution by Josef El-Rayes.
Enhanced and adapted by Marc Fonvieille.

8.5.1. Introduction

TV cards allow can be used to watch broadcast or cable TV on a computer. Most cards accept composite video via an RCA or S-video input and some cards include a FM radio tuner.

FreeBSD provides support for PCI-based TV cards using a Brooktree Bt848/849/878/879 or a Conexant CN-878/Fusion 878a video capture chip with the bktr(4) driver. Ensure the board comes with a supported tuner. Consult bktr(4) for a list of supported tuners.

8.5.2. Loading the Driver

In order to use the card, the bktr(4) driver must be loaded. To automate this at boot time, add the following line to /boot/loader.conf:

bktr_load="YES"

Alternatively, one can statically compile support for the TV card into a custom kernel. In that case, add the following lines to the custom kernel configuration file:

device bktr device iicbus device iicbb device smbus

These additional devices are necessary as the card components are interconnected via an I2C bus. Then, build and install a new kernel.

To test the driver, reboot the system. The TV card should appear in the boot messages, as seen in this example:

bktr0: <BrookTree 848A> mem 0xd7000000-0xd7000fff irq 10 at device 10.0 on pci0 iicbb0: <I2C bit-banging driver> on bti2c0 iicbus0: <Philips I2C bus> on iicbb0 master-only iicbus1: <Philips I2C bus> on iicbb0 master-only smbus0: <System Management Bus> on bti2c0 bktr0: Pinnacle/Miro TV, Philips SECAM tuner.

The messages will differ according to the hardware. Check the messages to determine if the tuner is correctly detected. It is still possible to override some of the detected parameters with sysctl(8) MIBs and kernel configuration file options. For example, to force the tuner to a Philips SECAM tuner, add the following line to a custom kernel configuration file:

options OVERRIDE_TUNER=6

or, use sysctl(8):

# sysctl hw.bt848.tuner=6

Refer to bktr(4) and /usr/src/sys/conf/NOTES for more details on the available options.

8.5.3. Useful Applications

To use the TV card, install one of the following applications:

  • multimedia/fxtv provides TV-in-a-window and image/audio/video capture capabilities.

  • multimedia/xawtv is another TV application with similar features.

  • audio/xmradio provides an application for using the FM radio tuner of a TV card.

More applications are available in the FreeBSD Ports Collection.

8.5.4. Troubleshooting

If any problems are encountered with the TV card, check that the video capture chip and the tuner are supported by bktr(4) and that the right configuration options were used. For more support and various questions about TV cards, refer to the archives of the freebsd-multimedia mailing list.

8.6. MythTV

MythTV is a popular, open source PVR application. This section demonstrates how to install and setup MythTV on FreeBSD. Refer to the MythTV wiki for more information on how to use MythTV.

MythTV requires a frontend and a backend; however, it allows the user to have the frontend and backend on different machines.

For the frontend, multimedia/mythtv-frontend is required, as well as an X server, which can be found in x11/xorg. Ideally, the frontend computer also has a video card that supports XvMC and, optionally, a LIRC-compatible remote.

For the backend, multimedia/mythtv is required, along with the MySQL™ database server. Optionally a tuner and storage for any recorded data. The MySQL™ package should be automatically installed as a dependency when installing multimedia/mythtv.

8.6.1. Hardware

MythTV is designed to utilize V4L to access video input devices such as encoders and tuners. At this time, MythTV works best with USB DVB-S/C/T cards supported by multimedia/webcamd, as it provides a V4L userland application. Any DVB card supported by webcamd should work with MythTV. A list of known working cards can be found here. Drivers are also available for Hauppauge cards in the following ports: multimedia/pvr250 and multimedia/pvrxxx, but they provide a non-standard driver interface that does not work with versions of MythTV greater than 0.23. Due to licensing restrictions, no packages are available and these two ports must be compiled.

The HTPC wiki page contains a list of all available DVB drivers.

8.6.2. Setting up MythTV

To install the MythTV port:

# cd /usr/ports/multimedia/mythtv # make install

Once installed, set up the MythTV database:

# mysql -uroot -p < /usr/local/share/mythtv/database/mc.sql

Configure the backend:

# mythtv-setup

Start the backend:

# echo 'mythbackend_enable="YES"' >> /etc/rc.conf # service mythbackend start

8.7. Image Scanners

Written by Marc Fonvieille.

In FreeBSD, access to image scanners is provided by the SANE (Scanner Access Now Easy) API available through the FreeBSD Ports Collection. SANE will also use some FreeBSD device drivers to provide access to the scanner hardware.

FreeBSD supports both SCSI and USB scanners. Be sure the scanner is supported by SANE prior to performing any configuration. Refer to the supported devices list for more information about supported scanners.

8.7.1. Kernel Configuration

Both SCSI and USB interfaces are supported. Depending upon the scanner interface, different device drivers are required.

8.7.1.1. USB Interface

The GENERIC kernel by default includes the device drivers needed to support USB scanners. Users with a custom kernel should ensure that the following lines are present in the custom kernel configuration file:

device usb device uhci device ohci device ehci

Plug in the USB scanner. Use dmesg(8) to determine whether the scanner appears in the system message buffer:

ugen0.2: <EPSON> at usbus0

These messages indicate that the scanner is using either /dev/ugen0.2 or /dev/uscanner0, depending on the FreeBSD version. For this example, a EPSON Perfection® 1650 USB scanner was used.

8.7.1.2. SCSI Interface

If the scanner uses a SCSI interface, it is important to know which SCSI controller board it will use. Depending upon the SCSI chipset, a custom kernel configuration file may be needed. The GENERIC kernel supports the most common SCSI controllers. Refer to /usr/src/sys/conf/NOTES to determine the correct line to add to a custom kernel configuration file. In addition to the SCSI adapter driver, the following lines are needed in the kernel configuration file:

device scbus device pass

Verify that the device is displayed in the system message buffer:

pass2 at aic0 bus 0 target 2 lun 0 pass2: <AGFA SNAPSCAN 600 1.10> Fixed Scanner SCSI-2 device pass2: 3.300MB/s transfers

If the scanner was not powered-on at system boot, it is still possible to manually force the detection by performing a SCSI bus scan with the camcontrol(8) command:

# camcontrol rescan all Re-scan of bus 0 was successful Re-scan of bus 1 was successful Re-scan of bus 2 was successful Re-scan of bus 3 was successful

The scanner should now appear in the SCSI devices list:

# camcontrol devlist <IBM DDRS-34560 S97B> at scbus0 target 5 lun 0 (pass0,da0) <IBM DDRS-34560 S97B> at scbus0 target 6 lun 0 (pass1,da1) <AGFA SNAPSCAN 600 1.10> at scbus1 target 2 lun 0 (pass3) <PHILIPS CDD3610 CD-R/RW 1.00> at scbus2 target 0 lun 0 (pass2,cd0)

Refer to scsi(4) and camcontrol(8) for more details about SCSI devices on FreeBSD.

8.7.2. SANE Configuration

The SANE system is split in two parts: the backends (graphics/sane-backends) and the frontends (graphics/sane-frontends). The backends provide access to the scanner. The SANE's supported devices list specifies which backend will support the image scanner. The correct backend is needed in order to use the scanner. The frontends provide the graphical scanning interface, xscanimage.

After installing the graphics/sane-backends port or package, use sane-find-scanner to check the scanner detection by the SANE system:

# sane-find-scanner -q found SCSI scanner "AGFA SNAPSCAN 600 1.10" at /dev/pass3

The output should show the interface type of the scanner and the device node used to attach the scanner to the system. The vendor and the product model may or may not appear.

Note:

Some USB scanners require firmware to be loaded. Refer to sane-find-scanner(1) and sane(7) for details.

Next, check if the scanner will be identified by a scanning frontend. By default, the SANE backends come with a command line tool called scanimage(1). This command can be used to list the devices and perform an image acquisition. Use -L to list the scanner devices:

# scanimage -L device `snapscan:/dev/pass3' is a AGFA SNAPSCAN 600 flatbed scanner

Here is the output for the USB scanner used in Section 8.7.1.1, “USB Interface”:

# scanimage -L device 'epson2:libusb:/dev/usb:/dev/ugen0.2' is a Epson GT-8200 flatbed scanner

In this output, 'epson2:libusb:/dev/usb:/dev/ugen0.2' is the backend name (epson2) and the device node (/dev/ugen0.2) used by the scanner.

Note:

No output or a message saying that no scanners were identified indicates that scanimage(1) is unable to identify the scanner. If this happens, edit the backend configuration file in /usr/local/etc/sane.d/ and define the scanner device used.

In the above example, the USB scanner is perfectly detected and working.

To determine if the scanner is correctly identified:

# scanimage -L No scanners were identified. If you were expecting something different, check that the scanner is plugged in, turned on and detected by the sane-find-scanner tool (if appropriate). Please read the documentation which came with this software (README, FAQ, manpages).

Since the scanner is not identified, edit /usr/local/etc/sane.d/epson2.conf. In this example, the scanner model is EPSON Perfection® 1650 and it uses the epson2 backend. When editing, read the help comments in the backend configuration file. Line changes are simple: comment out all lines that have the wrong interface for the scanner. In this example, comment out all lines starting with the word scsi as the scanner uses the USB interface. Then, at the end of the file, add a line specifying the interface and the device node used. In this case, add the following line:

usb /dev/uscanner0

Save the edits and verify that the scanner is identified:

# scanimage -L device `epson:/dev/uscanner0' is a Epson GT-8200 flatbed scanner

The `epson:/dev/uscanner0' field now gives the right backend name and the device node.

Once scanimage -L sees the scanner, the configuration is complete and the device is now ready to scan.

While scanimage(1) can be used to perform an image acquisition from the command line, it is often preferable to use a graphical interface to perform image scanning. The graphics/sane-frontends package or port installs a simple but efficient graphical interface, xscanimage.

Xsane, which is installed with the graphics/xsane package or port, is another popular graphical scanning frontend. It offers advanced features such as various scanning modes, color correction, and batch scans. Both of these applications are usable as a GIMP plugin.

8.7.3. Giving Other Users Access to the Scanner

In order to have access to the scanner, a user needs read and write permissions to the device node used by the scanner. In the previous example, the USB scanner uses the device node /dev/ugen0.2 which is really a symlink to the real device node /dev/usb/0.2.0. The symlink and the device node are owned, respectively, by the wheel and operator groups. Adding the user to these groups will allow access to the scanner. However, for security reasons, always think twice before adding a user to any group, especially wheel. A better solution is to create a group to make the scanner device accessible to members of this group.

This example creates a group called usb using pw(8):

# pw groupadd usb

Then, make the /dev/ugen0.2 symlink and the /dev/usb/0.2.0 device node accessible to the usb group with write permissions of (0660 or 0664. All of this is done by adding the following lines to /etc/devfs.rules:

[system=5] add path ugen0.2 mode 0660 group usb add path usb/0.2.0 mode 0666 group usb

Finally, add the users to usb in order to allow access to the scanner:

# pw groupmod usb -m joe

For more details refer to pw(8).

Chapter 9. Configuring the FreeBSD Kernel

Updated and restructured by Jim Mock.
Originally contributed by Jake Hamby.

9.1. Synopsis

The kernel is the core of the FreeBSD operating system. It is responsible for managing memory, enforcing security controls, networking, disk access, and much more. While much of FreeBSD is dynamically configurable, it is still occasionally necessary to configure and compile a custom kernel.

After reading this chapter, you will know:

  • When to build a custom kernel.

  • How to customize a kernel configuration file.

  • How to use the kernel configuration file to create and build a new kernel.

  • How to install the new kernel.

  • How to troubleshoot if things go wrong.

All of the commands listed in the examples in this chapter should be executed as root.

9.2. Why Build a Custom Kernel?

Traditionally, FreeBSD used a monolithic kernel. The kernel was one large program, supported a fixed list of devices, and in order to change the kernel's behavior, one had to compile a new kernel, and then reboot into the new kernel.

Today, most of the functionality in the FreeBSD kernel is contained in modules which can be dynamically loaded and unloaded from the kernel as necessary. This allows the running kernel to adapt immediately to new hardware or for new functionality to be brought into the kernel. This is known as a modular kernel.

Occasionally, it is still necessary to perform static kernel configuration. This may be because the functionality is so tied to the kernel that it can not be made dynamically loadable. Some security environments prevent the loading and unloading of kernel modules, and require that only needed functionality is statically compiled into the kernel.

Building a custom kernel is often a rite of passage for advanced BSD users. This process, while time consuming, can provide benefits to the FreeBSD system. Unlike the GENERIC kernel, which must support a wide range of hardware, a custom kernel can be stripped down to only provide support for that computer's hardware. This has a number of benefits, such as:

  • Faster boot time. Since the kernel will only probe the hardware on the system, the time it takes the system to boot can decrease.

  • Lower memory usage. A custom kernel often uses less memory than the GENERIC kernel by omitting unused features and device drivers. This is important because the kernel code remains resident in physical memory at all times, preventing that memory from being used by applications. For this reason, a custom kernel is useful on a system with a small amount of RAM.

  • Additional hardware support. A custom kernel can add in support for devices which are not present in the GENERIC kernel.

9.3. Finding the System Hardware

Written by Tom Rhodes.

Before venturing into kernel configuration, it would be wise to get an inventory of the machine's hardware. In cases where FreeBSD is not the primary operating system, the inventory list can be created by viewing the current operating system configuration. For example, Microsoft®'s Device Manager contains information about installed devices.

Note:

Some versions of Microsoft® Windows® have a System icon which will display a screen where Device Manager may be accessed.

If another operating system does not exist on the machine, the administrator must find this information out manually. One method is using dmesg(8) and man(1). Most device drivers on FreeBSD have a manual page, listing supported hardware. During the boot probe, found hardware will be listed. For example, the following lines indicate that the psm(4) driver found a mouse:

psm0: <PS/2 Mouse> irq 12 on atkbdc0 psm0: [GIANT-LOCKED] psm0: [ITHREAD] psm0: model Generic PS/2 mouse, device ID 0

This driver will need to be included in the custom kernel configuration file or loaded using loader.conf(5).

On occasion, the data from dmesg will only show system messages instead of the boot probe output. In these situations, the output may be obtained by reading /var/run/dmesg.boot.

Another method for finding hardware is to use pciconf(8) which provides more verbose output. For example:

ath0@pci0:3:0:0: class=0x020000 card=0x058a1014 chip=0x1014168c rev=0x01 hdr=0x00 vendor = 'Atheros Communications Inc.' device = 'AR5212 Atheros AR5212 802.11abg wireless' class = network subclass = ethernet

This output, obtained by using pciconf -lv, shows that the ath driver located a wireless Ethernet device. Type man ath to read ath(4).

The -k flag, when passed to man(1) can be used to provide useful information. For example, to display a list of manual pages which contain the specified word:

# man -k Atheros
ath(4) - Atheros IEEE 802.11 wireless network driver ath_hal(4) - Atheros Hardware Access Layer (HAL)

Armed with a hardware inventory list, the process of building a custom kernel should appear less daunting.

9.4. Kernel Drivers, Subsystems, and Modules

Before building a custom kernel, consider the reason for doing so. If there is a need for specific hardware support, it may already exist as a module.

Kernel modules exist in /boot/kernel and may be dynamically loaded into the running kernel using kldload(8). Most, if not all kernel drivers have a loadable module and manual page. For example, the ath(4) wireless Ethernet driver has the following information in its manual page:

Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5): if_ath_load="YES"

Adding if_ath_load="YES" to /boot/loader.conf will enable loading this module dynamically at boot time.

In some cases, there is no associated module. This is mostly true for certain subsystems. One way to tell if a driver is available is to check for the module itself.

Warning:

It is easy to remove support for a device or option and end up with a broken kernel. For example, if the ata(4) driver is removed from the kernel configuration file, a system using ATA disk drivers may not boot. When in doubt, just leave support in the kernel.

9.5. Building and Installing a Custom Kernel

Note:

It is required to have the full FreeBSD source tree installed to build the kernel.

The kernel build is located at /usr/src/sys. It contains a number of subdirectories representing different parts of the kernel. These include arch/conf, which contains the kernel configuration file, and compile, which is the staging area where the kernel will be built. arch contains subdirectories for each supported architecture: i386, amd64, ia64, powerpc, sparc64, and pc98. Everything inside a particular architecture's directory deals with that architecture only and the rest of the code is machine independent code common to all platforms. Notice the logical organization of the directory structure, with each supported device, file system, and option in its own subdirectory.

The examples in this chapter assume the i386 architecture. If the system has a different architecture, change the path names accordingly.

Note:

If /usr/src/ does not exist or it is empty, source has not been installed. The easiest way to install source is to use svn as described in Section A.5, “Using Subversion. One should also create a symlink to /usr/src/sys/:

# ln -s /usr/src/sys /sys

Next, cd to arch/conf and copy the GENERIC configuration file to the name of the custom kernel. For example:

# cd /usr/src/sys/i386/conf # cp GENERIC MYKERNEL

Traditionally, this name is in all capital letters. When maintaining multiple FreeBSD machines with different hardware, it is a good idea to name it after the machine's hostname. This example uses MYKERNEL.

Tip:

When finished customizing the kernel configuration file, save a backup copy to a location outside of /usr/src. Do not edit GENERIC directly.

Alternately, keep the kernel configuration file elsewhere and create a symbolic link to the file in i386.

For example:

# cd /usr/src/sys/i386/conf # mkdir /root/kernels # cp GENERIC /root/kernels/MYKERNEL # ln -s /root/kernels/MYKERNEL

Edit MYKERNEL with a text editor. The default editor is vi, whose usage is covered well in many books in the bibliography. An easier editor for beginners, called ee, is also available. Feel free to change the comment lines at the top to reflect the configuration or the changes made to differentiate it from GENERIC.

If the GENERIC configuration file seems overwhelming, follow the descriptions in the Configuration File section slowly and carefully.

Note:

After syncing the source tree with the latest sources, always read /usr/src/UPDATING before performing any update steps. This file describes any important issues or areas requiring special attention within the updated source code. /usr/src/UPDATING always matches the version of the FreeBSD source and contains more up-to-date information than this Handbook.

After saving the edits, compile the source code for the kernel.

Procedure 9.1. Building a Kernel

Note:

It is required to have the full FreeBSD source tree installed to build the kernel.

  1. cd to /usr/src:

    # cd /usr/src
  2. Compile the new kernel by specifying the name of the custom kernel configuration file:

    # make buildkernel KERNCONF=MYKERNEL
  3. Install the new kernel:

    # make installkernel KERNCONF=MYKERNEL

Tip:

By default, when a custom kernel is compiled, all kernel modules are rebuilt as well. To update a kernel faster or to build only custom modules, edit /etc/make.conf before starting to build the kernel:

MODULES_OVERRIDE = linux acpi sound/sound sound/driver/ds1 ntfs

This variable specifies the list of modules to build instead the default of building of all of them.

WITHOUT_MODULES = linux acpi sound ntfs

This variable sets up a list of top level modules to exclude from the build process. For other available variables, refer to make.conf(5).

The new kernel will be copied to /boot/kernel as /boot/kernel/kernel and the old kernel will be moved to /boot/kernel.old/kernel. Now, shutdown the system and reboot into the new kernel. If something goes wrong, refer to the troubleshooting instructions and the section which explains how to recover when the new kernel does not boot.

Note:

Other files relating to the boot process, such as the boot loader(8) and configuration, are stored in /boot. Third party or custom modules can be placed in /boot/kernel, although users should be aware that keeping modules in sync with the compiled kernel is very important. Modules not intended to run with the compiled kernel may result in instability.

9.6. The Configuration File

Updated by Joel Dahl.

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, in the order they are listed in GENERIC. For an exhaustive list of architecture dependent options and devices, refer to NOTES in the same directory as GENERIC for that architecture. For architecture independent options, refer to /usr/src/sys/conf/NOTES.

An include directive is available for use in configuration files. This allows another configuration file to be included in the current one, making it easy to maintain small changes relative to an existing file. For example, if only a small number of additional options or drivers are required, this allows a delta to be maintained with respect to GENERIC:

include GENERIC ident MYKERNEL options IPFIREWALL options DUMMYNET options IPFIREWALL_DEFAULT_TO_ACCEPT options IPDIVERT

Using this method, the local configuration file expresses local differences from a GENERIC kernel. As upgrades are performed, new features added to GENERIC will be also be added to the local kernel unless they are specifically prevented using nooptions or nodevice. A comprehensive list of configuration directives and their descriptions may be found in config(5).

The remainder of this chapter addresses the contents of a typical configuration file and the role various options and devices play.

Note:

To build a file which contains all available options, run the following command as root:

# cd /usr/src/sys/i386/conf && make LINT

The following is an example of the GENERIC kernel configuration file with various additional comments where needed for clarity. This example should match the copy in /usr/src/sys/i386/conf/GENERIC fairly closely.

machine i386

This is the machine architecture. It must be either amd64, i386, ia64, pc98, powerpc, or sparc64.

cpu I486_CPU cpu I586_CPU cpu I686_CPU

This option specifies the type of CPU. It is fine to have multiple instances of the CPU entries, but for a custom kernel it is best to specify the CPU. To determine the CPU type, review the boot messages in /var/run/dmesg.boot.

ident GENERIC

This is the identification of the kernel. Change this to the new kernel name, such as MYKERNEL. The value in the ident string will print when the kernel boots.

#To statically compile in device wiring instead of /boot/device.hints #hints "GENERIC.hints" # Default places to look for devices.

device.hints(5) is used to configure options for device drivers. The default location is /boot/device.hints. The hints option compiles these hints statically into the kernel so that there is no need to create /boot/device.hints.

makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols

This option enables debugging information when passed to gcc(1).

options SCHED_ULE # ULE scheduler

The default system scheduler for FreeBSD. Keep this.

options PREEMPTION # Enable kernel thread preemption

Allows kernel threads to be preempted by higher priority threads. This helps with interactivity and allows interrupt threads to run sooner rather than waiting.

options INET # InterNETworking

Networking support. This is mandatory as most programs require at least loopback networking.

options INET6 # IPv6 communications protocols

This enables the IPv6 communication protocols.

options FFS # Berkeley Fast Filesystem

This is the basic hard drive file system. Leave it in if the system boots from the hard disk.

options SOFTUPDATES # Enable FFS Soft Updates support

This option enables Soft Updates in the kernel which helps to speed up write access on the disks. Even when this functionality is provided by the kernel, it must be turned on for specific disks. Review the output of mount(8) to determine if Soft Updates is enabled. If the soft-updates option is not in the output, it can be activated using tunefs(8) for existing file systems or newfs(8) for new file systems.

options UFS_ACL # Support for access control lists

This option enables kernel support for access control lists (ACLs). This relies on the use of extended attributes and UFS2, and the feature is described in detail in Section 15.11, “Filesystem Access Control Lists (ACL)s”. ACLs are enabled by default and should not be disabled in the kernel if they have been used previously on a file system, as this will remove the ACLs, changing the way files are protected in unpredictable ways.

options UFS_DIRHASH # Improve performance on big directories

This option includes functionality to speed up disk operations on large directories, at the expense of using additional memory. Keep this for a large server or interactive workstation, and remove it from smaller systems where memory is at a premium and disk access speed is less important, such as a firewall.

options MD_ROOT # MD is a potential root device

This option enables support for a memory backed virtual disk used as a root device.

options NFSCLIENT # Network Filesystem Client options NFSSERVER # Network Filesystem Server options NFS_ROOT # NFS usable as /, requires NFSCLIENT

The network file system (NFS). These lines can be commented unless the system needs to mount partitions from a NFS file server over TCP/IP.

options MSDOSFS # MSDOS Filesystem

The MS-DOS® file system. Unless the system needs to mount a DOS formatted hard drive partition at boot time, comment this out. It will be automatically loaded the first time a DOS partition is mounted. The emulators/mtools package allows access to DOS floppies without having to mount and unmount them and does not require MSDOSFS.

options CD9660 # ISO 9660 Filesystem

The ISO 9660 file system for CDROMs. Comment it out if the system does not have a CDROM drive or only mounts data CDs occasionally since it will be dynamically loaded the first time a data CD is mounted. Audio CDs do not need this file system.

options PROCFS # Process filesystem (requires PSEUDOFS)

The process file system. This is a pretend file system mounted on /proc which allows some programs to provide more information on what processes are running. Use of PROCFS is not required under most circumstances, as most debugging and monitoring tools have been adapted to run without PROCFS. The default installation will not mount this file system by default.

options PSEUDOFS # Pseudo-filesystem framework

Kernels making use of PROCFS must also include support for PSEUDOFS.

options GEOM_PART_GPT # GUID Partition Tables.

Adds support for GUID Partition Tables (GPT). GPT provides the ability to have a large number of partitions per disk, 128 in the standard configuration.

options COMPAT_43 # Compatible with BSD 4.3 [KEEP THIS!]

Compatibility with 4.3BSD. Leave this in as some programs will act strangely if this is commented out.

options COMPAT_FREEBSD4 # Compatible with FreeBSD4

This option is required to support applications compiled on older versions of FreeBSD that use older system call interfaces. It is recommended that this option be used on all i386™ systems that may run older applications. Platforms that gained support after FreeBSD 4.X, such as ia64 and SPARC64®, do not require this option.

options COMPAT_FREEBSD5 # Compatible with FreeBSD5

This option is required to support applications compiled on FreeBSD 5.X versions that use FreeBSD 5.X system call interfaces.

options COMPAT_FREEBSD6 # Compatible with FreeBSD6

This option is required to support applications compiled on FreeBSD 6.X versions that use FreeBSD 6.X system call interfaces.

options COMPAT_FREEBSD7 # Compatible with FreeBSD7

This option is required on FreeBSD 8 and above to support applications compiled on FreeBSD 7.X versions that use FreeBSD 7.X system call interfaces.

options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI

This causes the kernel to pause for 5 seconds before probing each SCSI device in the system. If the system only has IDE hard drives, ignore this or lower the number to speed up booting. However, if FreeBSD has trouble recognizing the SCSI devices, the number will have to be raised again.

options KTRACE # ktrace(1) support

This enables kernel process tracing, which is useful in debugging.

options SYSVSHM # SYSV-style shared memory

This option provides for System V shared memory. The most common use of this is the XSHM extension in X, which many graphics-intensive programs will automatically take advantage of for extra speed. If Xorg is installed, include this.

options SYSVMSG # SYSV-style message queues

Support for System V messages. This option only adds a few hundred bytes to the kernel.

options SYSVSEM # SYSV-style semaphores

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

Note:

Using -p with ipcs(1) will list any processes using each of these System V facilities.

options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions

Real-time extensions added in the 1993 POSIX®. Certain applications in the Ports Collection use these.

options KBD_INSTALL_CDEV # install a CDEV entry in /dev

This option is required to allow the creation of keyboard device nodes in /dev.

device apic # I/O APIC

This device enables the use of the I/O APIC for interrupt delivery. It can be used in both uni-processor and SMP kernels, but is required for SMP kernels. Add options SMP to include support for multiple processors.

Note:

This device exists only on the i386 architecture and this configuration line should not be used on other architectures.

device eisa

Include this for systems with an EISA motherboard. This enables auto-detection and configuration support for all devices on the EISA bus.

device pci

Include this for systems with a PCI motherboard. This enables auto-detection of PCI cards and gatewaying from the PCI to ISA bus.

# Floppy drives device fdc

This is the floppy drive controller.

# ATA and ATAPI devices device ata

This driver supports all ATA and ATAPI devices. Only one device ata line is needed for the kernel to detect all PCI ATA/ATAPI devices on modern machines.

device atadisk # ATA disk drives

This is needed along with device ata for ATA disk drives.

device ataraid # ATA RAID drives

This is needed along with device ata for ATA RAID drives.

device atapicd # ATAPI CDROM drives

This is needed along with device ata for ATAPI CDROM drives.

device atapifd # ATAPI floppy drives

This is needed along with device ata for ATAPI floppy drives.

device atapist # ATAPI tape drives

This is needed along with device ata for ATAPI tape drives.

options ATA_STATIC_ID # Static device numbering

This makes the controller number static. Without this, the device numbers are dynamically allocated.

# SCSI Controllers device ahb # EISA AHA1742 family device ahc # AHA2940 and onboard AIC7xxx devices options AHC_REG_PRETTY_PRINT # Print register bitfields in debug # output. Adds ~128k to driver. device ahd # AHA39320/29320 and onboard AIC79xx devices options AHD_REG_PRETTY_PRINT # Print register bitfields in debug # output. Adds ~215k to driver. device amd # AMD 53C974 (Teckram DC-390(T)) device isp # Qlogic family #device ispfw # Firmware for QLogic HBAs- normally a module device mpt # LSI-Logic MPT-Fusion #device ncr # NCR/Symbios Logic device sym # NCR/Symbios Logic (newer chipsets + those of `ncr') device trm # Tekram DC395U/UW/F DC315U adapters device adv # Advansys SCSI adapters device adw # Advansys wide SCSI adapters device aha # Adaptec 154x SCSI adapters device aic # Adaptec 15[012]x SCSI adapters, AIC-6[23]60. device bt # Buslogic/Mylex MultiMaster SCSI adapters device ncv # NCR 53C500 device nsp # Workbit Ninja SCSI-3 device stg # TMC 18C30/18C50

In this section, comment out any SCSI controllers not on the system. For an IDE only system, these lines can be removed. The *_REG_PRETTY_PRINT lines are debugging options for their respective drivers.

# SCSI peripherals device scbus # SCSI bus (required for SCSI) device ch # SCSI media changers device da # Direct Access (disks) device sa # Sequential Access (tape etc) device cd # CD device pass # Passthrough device (direct SCSI access) device ses # SCSI Environmental Services (and SAF-TE)

Comment out any SCSI peripherals not on the system. If the system only has IDE hardware, these lines can be removed completely.

Note:

The USB umass(4) driver and a few other drivers use the SCSI subsystem even though they are not real SCSI devices. Do not remove SCSI support if any such drivers are included in the kernel configuration.

# RAID controllers interfaced to the SCSI subsystem device amr # AMI MegaRAID device arcmsr # Areca SATA II RAID device asr # DPT SmartRAID V, VI and Adaptec SCSI RAID device ciss # Compaq Smart RAID 5* device dpt # DPT Smartcache III, IV - See NOTES for options device hptmv # Highpoint RocketRAID 182x device hptrr # Highpoint RocketRAID 17xx, 22xx, 23xx, 25xx device iir # Intel Integrated RAID device ips # IBM (Adaptec) ServeRAID device mly # Mylex AcceleRAID/eXtremeRAID device twa # 3ware 9000 series PATA/SATA RAID # RAID controllers device aac # Adaptec FSA RAID device aacp # SCSI passthrough for aac (requires CAM) device ida # Compaq Smart RAID device mfi # LSI MegaRAID SAS device mlx # Mylex DAC960 family device pst # Promise Supertrak SX6000 device twe # 3ware ATA RAID

Supported RAID controllers. If the system does not have any of these, comment them out or remove them.

# atkbdc0 controls both the keyboard and the PS/2 mouse device atkbdc # AT keyboard controller

The atkbdc keyboard controller provides I/O services for the AT keyboard and PS/2 style pointing devices. This controller is required by atkbd(4) and psm(4).

device atkbd # AT keyboard

The atkbd(4) driver, together with the atkbdc(4) controller, provides access to the AT 84 keyboard or the AT enhanced keyboard which is connected to the AT keyboard controller.

device psm # PS/2 mouse

Use this device if the mouse plugs into the PS/2 mouse port.

device kbdmux # keyboard multiplexer

Basic support for keyboard multiplexing. If the system does not use more than one keyboard, this line can be safely removed.

device vga # VGA video card driver

The vga(4) video card driver.

device splash # Splash screen and screen saver support

Required by the boot splash screen and screen savers.

# syscons is the default console driver, resembling an SCO console device sc

sc(4) is the default console driver and resembles a SCO console. Since most full-screen programs access the console through a terminal database library like termcap, it should not matter whether this or vt, the VT220 compatible console driver, is used. When a user logs in, the TERM variable can be set to scoansi if full-screen programs have trouble running under this console.

# Enable this for the pcvt (VT220 compatible) console driver #device vt #options XSERVER # support for X server on a vt console #options FAT_CURSOR # start with block cursor

This is a VT220-compatible console driver, backward compatible to VT100/102. It works well on some laptops which have hardware incompatibilities with sc. Users may need to set TERM to vt100 or vt220 after login. This driver is useful when connecting to a large number of different machines over the network, where termcap or terminfo entries for the sc device are not available as vt100 should be available on virtually any platform.

device agp

Include this if the system has an AGP card. This will enable support for AGP and AGP GART for boards which have these features.

# Add suspend/resume support for the i8254. device pmtimer

Timer device driver for power management events, such as APM and ACPI.

# PCCARD (PCMCIA) support # PCMCIA and cardbus bridge support device cbb # cardbus (yenta) bridge device pccard # PC Card (16-bit) bus device cardbus # CardBus (32-bit) bus

PCMCIA support. Keep this on laptop systems.

# Serial (COM) ports device sio # 8250, 16[45]50 based serial ports

These are the serial ports referred to as COM ports in Windows®.

Note:

If the system has an internal modem on COM4 and a serial port at COM2, change the IRQ of the modem to 2. For a multiport serial card, refer to sio(4) for more information on the proper values to add to /boot/device.hints. Some video cards, notably those based on S3 chips, use I/O addresses in the form of 0x*2e8. Since many cheap serial cards do not fully decode the 16-bit I/O address space, they clash with these cards, making the COM4 port practically unavailable.

Each serial port is required to have a unique IRQ and the default IRQs for COM3 and COM4 cannot be used. The exception is multiport cards where shared interrupts are supported.

# Parallel port device ppc

This is the ISA bus parallel port interface.

device ppbus # Parallel port bus (required)

Provides support for the parallel port bus.

device lpt # Printer

Adds support for parallel port printers.

Note:

All three of the above are required to enable parallel printer support.

device ppi # Parallel port interface device

The general-purpose I/O (geek port) + IEEE1284 I/O.

#device vpo # Requires scbus and da

This is for an Iomega Zip drive. It requires scbus and da support. Best performance is achieved with ports in EPP 1.9 mode.

#device puc

Uncomment this device if the system has a dumb serial or parallel PCI card that is supported by the puc(4) glue driver.

# PCI Ethernet NICs. device de # DEC/Intel DC21x4x (Tulip) device em # Intel PRO/1000 adapter Gigabit Ethernet Card device ixgb # Intel PRO/10GbE Ethernet Card device txp # 3Com 3cR990 (Typhoon) device vx # 3Com 3c590, 3c595 (Vortex)

Various PCI network card drivers. Comment out or remove any of these which are not present in the system.

# PCI Ethernet NICs that use the common MII bus controller code. # NOTE: Be sure to keep the 'device miibus' line in order to use these NICs! device miibus # MII bus support

MII bus support is required for some PCI 10/100 Ethernet NICs, namely those which use MII-compliant transceivers or implement transceiver control interfaces that operate like an MII. Adding device miibus to the kernel config pulls in support for the generic miibus API and all of the PHY drivers, including a generic one for PHYs that are not specifically handled by an individual driver.

device bce # Broadcom BCM5706/BCM5708 Gigabit Ethernet device bfe # Broadcom BCM440x 10/100 Ethernet device bge # Broadcom BCM570xx Gigabit Ethernet device dc # DEC/Intel 21143 and various workalikes device fxp # Intel EtherExpress PRO/100B (82557, 82558) device lge # Level 1 LXT1001 gigabit ethernet device msk # Marvell/SysKonnect Yukon II Gigabit Ethernet device nge # NatSemi DP83820 gigabit ethernet device nve # nVidia nForce MCP on-board Ethernet Networking device pcn # AMD Am79C97x PCI 10/100 (precedence over 'lnc') device re # RealTek 8139C+/8169/8169S/8110S device rl # RealTek 8129/8139 device sf # Adaptec AIC-6915 (Starfire) device sis # Silicon Integrated Systems SiS 900/SiS 7016 device sk # SysKonnect SK-984x & SK-982x gigabit Ethernet device ste # Sundance ST201 (D-Link DFE-550TX) device stge # Sundance/Tamarack TC9021 gigabit Ethernet device ti # Alteon Networks Tigon I/II gigabit Ethernet device tl # Texas Instruments ThunderLAN device tx # SMC EtherPower II (83c170 EPIC) device vge # VIA VT612x gigabit ethernet device vr # VIA Rhine, Rhine II device wb # Winbond W89C840F device xl # 3Com 3c90x (Boomerang, Cyclone)

Drivers that use the MII bus controller code.

# ISA Ethernet NICs. pccard NICs included. device cs # Crystal Semiconductor CS89x0 NIC # 'device ed' requires 'device miibus' device ed # NE[12]000, SMC Ultra, 3c503, DS8390 cards device ex # Intel EtherExpress Pro/10 and Pro/10+ device ep # Etherlink III based cards device fe # Fujitsu MB8696x based cards device ie # EtherExpress 8/16, 3C507, StarLAN 10 etc. device lnc # NE2100, NE32-VL Lance Ethernet cards device sn # SMC's 9000 series of Ethernet chips device xe # Xircom pccard Ethernet # ISA devices that use the old ISA shims #device le

ISA Ethernet drivers. See /usr/src/sys/i386/conf/NOTES for details of which cards are supported by which driver.

# Wireless NIC cards device wlan # 802.11 support

Generic 802.11 support. This line is required for wireless networking.

device wlan_wep # 802.11 WEP support device wlan_ccmp # 802.11 CCMP support device wlan_tkip # 802.11 TKIP support

Crypto support for 802.11 devices. These lines are needed on systems which use encryption and 802.11i security protocols.

device an # Aironet 4500/4800 802.11 wireless NICs. device ath # Atheros pci/cardbus NIC's device ath_hal # Atheros HAL (Hardware Access Layer) device ath_rate_sample # SampleRate tx rate control for ath device awi # BayStack 660 and others device ral # Ralink Technology RT2500 wireless NICs. device wi # WaveLAN/Intersil/Symbol 802.11 wireless NICs. #device wl # Older non 802.11 Wavelan wireless NIC.

Support for various wireless cards.

# Pseudo devices device loop # Network loopback

This is the generic loopback device for TCP/IP. This is mandatory.

device random # Entropy device

Cryptographically secure random number generator.

device ether # Ethernet support

ether is only needed if the system has an Ethernet card. It includes generic Ethernet protocol code.

device sl # Kernel SLIP

sl provides SLIP support. This has been almost entirely supplanted by PPP, which is easier to set up, better suited for modem-to-modem connection, and more powerful.

device ppp # Kernel PPP

This is for kernel PPP support for dial-up connections. There is also a version of PPP implemented as a userland application that uses tun and offers more flexibility and features such as demand dialing.

device tun # Packet tunnel.

This is used by the userland PPP software. See the PPP section of the Handbook for more information.

device pty # Pseudo-ttys (telnet etc)

This is a pseudo-terminal or simulated login port. It is used by incoming telnet and rlogin sessions, xterm, and some other applications such as Emacs.

device md # Memory disks

Memory disk pseudo-devices.

device gif # IPv6 and IPv4 tunneling

This implements IPv6 over IPv4 tunneling, IPv4 over IPv6 tunneling, IPv4 over IPv4 tunneling, and IPv6 over IPv6 tunneling. The gif device is auto-cloning, and will create device nodes as needed.

device faith # IPv6-to-IPv4 relaying (translation)

This pseudo-device captures packets that are sent to it and diverts them to the IPv4/IPv6 translation daemon.

# The `bpf' device enables the Berkeley Packet Filter. # Be aware of the administrative consequences of enabling this! # Note that 'bpf' is required for DHCP. device bpf # Berkeley packet filter

The Berkeley Packet Filter pseudo-device allows network interfaces to be placed in promiscuous mode, capturing every packet on a broadcast network such as an Ethernet network. These packets can be captured to disk and or examined using tcpdump(1).

Note:

The bpf(4) device is also used by dhclient(8). If DHCP is used, leave this uncommented.

# USB support device uhci # UHCI PCI->USB interface device ohci # OHCI PCI->USB interface device ehci # EHCI PCI->USB interface (USB 2.0) device usb # USB Bus (required) #device udbp # USB Double Bulk Pipe devices device ugen # Generic device uhid # Human Interface Devices device ukbd # Keyboard device ulpt # Printer device umass # Disks/Mass storage - Requires scbus and da device ums # Mouse device ural # Ralink Technology RT2500USB wireless NICs device urio # Diamond Rio 500 MP3 player device uscanner # Scanners # USB Ethernet, requires mii device aue # ADMtek USB Ethernet device axe # ASIX Electronics USB Ethernet device cdce # Generic USB over Ethernet device cue # CATC USB Ethernet device kue # Kawasaki LSI USB Ethernet device rue # RealTek RTL8150 USB Ethernet

Support for various USB devices.

# FireWire support device firewire # FireWire bus code device sbp # SCSI over FireWire (Requires scbus and da) device fwe # Ethernet over FireWire (non-standard!)

Support for various Firewire devices.

For more information and additional devices supported by FreeBSD, see /usr/src/sys/i386/conf/NOTES.

9.6.1. Large Memory Configurations (PAE)

Large memory configuration machines require access to more than the 4 gigabyte limit on User+Kernel Virtual Address (KVA) space. Due to this limitation, Intel added support for 36-bit physical address space access in the Pentium® Pro and later line of CPUs.

The Physical Address Extension (PAE) capability of the Intel® Pentium® Pro and later CPUs allows memory configurations of up to 64 gigabytes. FreeBSD provides support for this capability via the PAE kernel configuration option, available in all current release versions of FreeBSD. Due to the limitations of the Intel memory architecture, no distinction is made for memory above or below 4 gigabytes. Memory allocated above 4 gigabytes is simply added to the pool of available memory.

To enable PAE support in the kernel, add the following line to the kernel configuration file:

options PAE

Note:

The PAE support in FreeBSD is only available for Intel® IA-32 processors. It should also be noted that the PAE support in FreeBSD has not received wide testing, and should be considered beta quality compared to other stable features of FreeBSD.

PAE support in FreeBSD has a few limitations:

  • A process is not able to access more than 4 gigabytes of virtual memory space.

  • Device drivers that do not use the bus_dma(9) interface will cause data corruption in a PAE enabled kernel and are not recommended for use. For this reason, a PAE kernel configuration file is provided in FreeBSD which excludes all drivers not known to work in a PAE enabled kernel.

  • Some system tunables determine memory resource usage by the amount of available physical memory. Such tunables can unnecessarily over-allocate due to the large memory nature of a PAE system. One such example is the kern.maxvnodes sysctl, which controls the maximum number of vnodes allowed in the kernel. It is advised to adjust this and other such tunables to a reasonable value.

  • It might be necessary to increase the kernel virtual address (KVA) space or to reduce the amount of specific kernel resource that is heavily used in order to avoid KVA exhaustion. The KVA_PAGES kernel option can be used for increasing the KVA space.

For performance and stability concerns, it is advised to consult tuning(7). pae(4) contains up-to-date information on FreeBSD's PAE support.

9.7. If Something Goes Wrong

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

config fails:

If config(8) fails, it is probably a simple error. Fortunately, config(8) will print the line number that it had trouble with. For example, for this message:

config: line 17: syntax error

Make sure the keyword on line 17 is typed correctly by comparing it to the GENERIC kernel or another reference.

make fails:

If make fails, it usually signals an error in the kernel description which is not severe enough for config(8) to catch. Review the configuration, and if you still cannot resolve the problem, send an email to the FreeBSD general questions mailing list with the kernel configuration.

The kernel does not boot:

If the new kernel does not boot, or fails to recognize devices, do not panic! Fortunately, FreeBSD has an excellent mechanism for recovering from incompatible kernels. Simply choose the kernel to boot from at the FreeBSD boot loader. This can be accessed when the system boot menu appears by selecting the Escape to a loader prompt option. At the prompt, type boot kernel.old, or the name of any other kernel that will boot properly. 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, check over the configuration file and try to build it again. One helpful resource is /var/log/messages which records the kernel messages from every successful boot. Also, dmesg(8) will print the kernel messages from the current boot.

Note:

When troubleshooting a kernel, make sure to keep GENERIC, or some other kernel that is known to work, on hand as a different name that will not get erased on the next build. Do not rely on kernel.old because when installing a new kernel, kernel.old is overwritten with the last installed kernel which may be non-functional. As soon as possible, move the working kernel to the proper /boot/kernel location or commands such as ps(1) may not work properly. To do this, simply rename the directory containing the good kernel:

# mv /boot/kernel /boot/kernel.bad # mv /boot/kernel.good /boot/kernel
The kernel works, but ps(1) does not work any more:

If the kernel version differs from the one that the system utilities have been built with, for example, a -CURRENT kernel on a -RELEASE, many system status commands like ps(1) and vmstat(8) will not work. To fix this, recompile and install a world built with the same version of the source tree as the kernel. This is one reason why it is not a good idea to use a different version of the kernel than the rest of the operating system.

Chapter 10. Printing

Contributed by Sean Kelly.
Restructured and updated by Jim Mock.

10.1. Synopsis

FreeBSD can be used to print with a wide variety of printers, from the oldest impact printer to the latest laser printers, and everything in between, allowing you to produce high-quality printed output from the applications you run.

FreeBSD can also be configured to act as a print server on a network; in this capacity FreeBSD can receive print jobs from a variety of other computers, including other FreeBSD computers, Windows® and Mac OS® hosts. FreeBSD will ensure that one job at a time is printed, and can keep statistics on which users and machines are doing the most printing, produce banner pages showing whose printout is whose, and more.

After reading this chapter, you will know:

  • How to configure the FreeBSD print spooler.

  • How to install print filters, to handle special print jobs differently, including converting incoming documents to print formats that your printers understand.

  • How to enable header, or banner pages on your printout.

  • How to print with printers connected to other computers.

  • How to print with printers connected directly to the network.

  • How to control printer restrictions, including limiting the size of print jobs, and preventing certain users from printing.

  • How to keep printer statistics, and account for printer usage.

  • How to troubleshoot printing problems.

Before reading this chapter, you should:

10.2. Introduction

In order to use printers with FreeBSD you may set them up to work with the Berkeley line printer spooling system, also known as the LPD spooling system, or just LPD. It is the standard printer control system in FreeBSD. This chapter introduces LPD and will guide you through its configuration.

If you are already familiar with LPD or another printer spooling system, you may wish to skip to section Basic Setup.

LPD controls everything about a host's printers. It is 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 jobs.

  • It prevents multiple users from accessing a printer at the same time by maintaining a queue for each printer.

  • It can print header pages (also known as banner or burst pages) so users can easily find jobs they have printed in a stack of printouts.

  • It takes care of communications parameters for printers connected on serial ports.

  • It can send jobs over the network to a 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 (/etc/printcap), 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.

10.2.1. Why You Should Use the Spooler

The spooler still provides benefit on a single-user system and should be used because:

  • LPD prints jobs in the background; you do not 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 will not 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 will more easily support other software you may later add or already have.

10.3. Basic Setup

To use printers with the LPD spooling system, you will need to set up both your printer hardware and the LPD software. This document describes two levels of setup:

  • See section Simple Printer Setup to learn how to connect a printer, tell LPD how to communicate with it, and print plain text files to the printer.

  • See section Advanced Printer Setup to learn 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.

10.3.1. Simple Printer Setup

This section tells how to configure printer hardware and the LPD software to use the printer. It teaches the basics:

  • Section Hardware Setup gives some hints on connecting the printer to a port on your computer.

  • Section Software Setup shows how to set up the LPD spooler configuration file (/etc/printcap).

If you are setting up a printer that uses a network protocol to accept data to print instead of a computer's local interfaces, see Printers With Networked Data Stream Interfaces.

Although this section is called Simple Printer Setup, it is 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.

10.3.1.1. 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 have already connected your printer and have successfully printed with it under another operating system, you can probably skip to section Software Setup.

10.3.1.1.1. Ports and Cables

Printers sold for use on PC's today generally come with one or more of the following three interfaces:

  • Serial interfaces, also known as RS-232 or COM ports, use a serial port on your computer to send data to the printer. Serial interfaces are common in the computer industry and cables are readily available and also easy to construct. Serial interfaces sometimes need special cables and might require you to configure somewhat complex communications options. Most PC serial ports have a maximum transmission rate of 115200 bps, which makes printing large graphic print jobs with them impractical.

  • Parallel interfaces use a parallel port on your computer to send data to the printer. Parallel interfaces are common in the PC market and are faster than RS-232 serial. Cables are readily available but more difficult to construct by hand. There are usually no communications options with parallel interfaces, making their configuration exceedingly simple.

    Parallel interfaces are sometimes known as Centronics interfaces, named after the connector type on the printer.

  • USB interfaces, named for the Universal Serial Bus, can run at even faster speeds than parallel or RS-232 serial interfaces. Cables are simple and cheap. USB is superior to RS-232 Serial and to Parallel for printing, but it is not as well supported under UNIX® systems. A way to avoid this problem is to purchase a printer that has both a USB interface and a Parallel interface, as many printers do.

In general, Parallel interfaces usually offer just one-way communication (computer to printer) while serial and USB gives you two-way. Newer parallel ports (EPP and ECP) and printers can communicate in both directions under FreeBSD when a IEEE-1284-compliant cable is used.

Two-way communication to the printer over a parallel port is generally done in one of two ways. The first method uses a custom-built printer driver for FreeBSD that speaks the proprietary language used by the printer. This is common with inkjet printers and can be used for reporting ink levels and other status information. The second method is used when the printer supports PostScript®.

PostScript® jobs are actually programs sent to the printer; they need not 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 has 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 to the user.

10.3.1.1.2. 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 ppc0 to FreeBSD; the second is ppc1, and so on. The printer device name uses the same scheme: /dev/lpt0 for the printer on the first parallel ports etc.

10.3.1.1.3. 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 are unsure what the proper serial cable is, you may wish to try one of the following alternatives:

  • A modem cable connects each pin of the connector on one end of the cable straight through to its corresponding pin of the connector on the other end. This type of cable is also known as a DTE-to-DCE cable.

  • A null-modem cable connects some pins straight through, swaps others (send data to receive data, for example), and shorts some internally in each connector hood. This type of cable is also known as a DTE-to-DTE cable.

  • A serial printer cable, required for some unusual printers, is like the null-modem cable, but sends some signals to their counterparts instead of being internally shorted.

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 baud rate) that both your computer and the printer can support. Choose 7 or 8 data bits; none, even, or odd parity; and 1 or 2 stop bits. Also choose a flow control protocol: either none, or XON/XOFF (also known as in-band or software) flow control. Remember these settings for the software configuration that follows.

10.3.1.2. Software Setup

This section describes the software setup necessary to print with the LPD spooling system in FreeBSD.

Here is an outline of the steps involved:

  1. Configure your kernel, if necessary, for the port you are using for the printer; section Kernel Configuration tells you what you need to do.

  2. Set the communications mode for the parallel port, if you are using a parallel port; section Setting the Communication Mode for the Parallel Port gives details.

  3. Test if the operating system can send data to the printer. Section Checking Printer Communications gives some suggestions on how to do this.

  4. Set up LPD for the printer by modifying the file /etc/printcap. You will find out how to do this later in this chapter.

10.3.1.2.1. 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 is not already configured for one.

To find out if the kernel you are currently using supports a serial interface, type:

# grep sioN /var/run/dmesg.boot

Where N is the number of the serial port, starting from zero. If you see output similar to the following:

sio2 at port 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:

# grep ppcN /var/run/dmesg.boot

Where N is the number of the parallel port, starting from zero. If you see output similar to the following:

ppc0: <Parallel port> at port 0x378-0x37f irq 7 on isa0 ppc0: SMC-like chipset (ECP/EPP/PS2/NIBBLE) in COMPATIBLE mode ppc0: FIFO with 16/16/8 bytes threshold

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 are 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 and the section that follows.

10.3.1.3. Setting the Communication Mode for the Parallel Port

When you are using the parallel interface, you can choose whether FreeBSD should use interrupt-driven or polled communication with the printer. The generic printer device driver (lpt(4)) on FreeBSD uses the ppbus(4) system, which controls the port chipset with the ppc(4) driver.

  • The interrupt-driven method is the default with the GENERIC kernel. With this method, the operating system uses an IRQ line to determine when the printer is ready for data.

  • The polled method directs the operating system to repeatedly ask the printer if it is ready for more data. When it responds ready, the kernel sends more data.

The interrupt-driven method is usually somewhat faster but uses up a precious IRQ line. Some newer HP printers are claimed not to work correctly in interrupt mode, apparently due to some (not yet exactly understood) timing problem. These printers need polled mode. You should use whichever one works. Some printers will work in both modes, but are painfully slow in interrupt mode.

You can set the communications mode in two ways: by configuring the kernel or by using the lptcontrol(8) program.

To set the communications mode by configuring the kernel:

  1. Edit your kernel configuration file. Look for an ppc0 entry. If you are setting up the second parallel port, use ppc1 instead. Use ppc2 for the third port, and so on.

    • If you want interrupt-driven mode, edit the following line:

      hint.ppc.0.irq="N"

      in the /boot/device.hints file and replace N with the right IRQ number. The kernel configuration file must also contain the ppc(4) driver:

      device ppc
    • If you want polled mode, remove in your /boot/device.hints file, the following line:

      hint.ppc.0.irq="N"

      In some cases, this is not enough to put the port in polled mode under FreeBSD. Most of time it comes from acpi(4) driver, this latter is able to probe and attach devices, and therefore, control the access mode to the printer port. You should check your acpi(4) configuration to correct this problem.

  2. Save the file. Then configure, build, and install the kernel, then reboot. See kernel configuration for more details.

To set the communications mode with lptcontrol(8):

  1. Type:

    # lptcontrol -i -d /dev/lptN

    to set interrupt-driven mode for lptN.

  2. Type:

    # lptcontrol -p -d /dev/lptN

    to set polled-mode for lptN.

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.

10.3.1.4. 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 is a lot easier to debug printer communication and the spooling system separately.

To test the printer, we will send some text to it. For printers that can immediately print characters sent to them, the program lptest(1) is perfect: it generates all 96 printable ASCII characters in 96 lines.

For a PostScript® (or other language-based) printer, we will need a more sophisticated test. A small PostScript® program, such as the following, will suffice:

%!PS 100 100 moveto 300 300 lineto stroke 310 310 moveto /Helvetica findfont 12 scalefont setfont (Is this thing working?) show showpage

The above PostScript® code can be placed into a file and used as shown in the examples appearing in the following sections.

Note:

When this document refers to a printer language, it is assuming a language like PostScript®, and not Hewlett Packard's PCL. Although PCL has great functionality, you can intermingle plain text with its escape sequences. PostScript® cannot directly print plain text, and that is the kind of printer language for which we must make special accommodations.

10.3.1.4.1. 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:

  1. Become root with su(1).

  2. Send data to the printer.

    • If the printer can print plain text, then use lptest(1). Type:

      # lptest > /dev/lptN

      Where N is the number of the parallel port, starting from zero.

    • If the printer understands PostScript® or other printer language, then send a small program to the printer. Type:

      # cat > /dev/lptN

      Then, line by line, type the program carefully as you cannot edit a line once you have pressed RETURN or ENTER. When you have finished entering the program, press CONTROL+D, or whatever your end of file key is.

      Alternatively, you can put the program in a file and type:

      # cat file > /dev/lptN

      Where file is the name of the file containing the program you want to send to the printer.

You should see something print. Do not worry if the text does not look right; we will fix such things later.

10.3.1.4.2. 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:

  1. Become root with su(1).

  2. Edit the file /etc/remote. Add the following entry:

    printer:dv=/dev/port:br#bps-rate:pa=parity

    Where port is the device entry for the serial port (ttyu0, ttyu1, etc.), bps-rate is the bits-per-second rate at which the printer communicates, and parity is the parity required by the printer (either even, odd, none, or zero).

    Here is 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/ttyu2:br#19200:pa=none
  3. Connect to the printer with tip(1). Type:

    # tip printer

    If this step does not work, edit the file /etc/remote again and try using /dev/cuaaN instead of /dev/ttyuN.

  4. Send data to the printer.

    • If the printer can print plain text, then use lptest(1). Type:

      % $lptest
    • If the printer understands PostScript® or other printer language, then send a small program to the printer. Type the program, line by line, very carefully as backspacing or other editing keys may be significant to the printer. You may also need to type a special end-of-file key for the printer so it knows it received the whole program. For PostScript® printers, press CONTROL+D.

      Alternatively, you can put the program in a file and type:

      % >file

      Where file is the name of the file containing the program. After tip(1) sends the file, press any required end-of-file key.

You should see something print. Do not worry if the text does not look right; we will fix that later.

10.3.1.5. 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 have been able to send some simple data to the printer. Now, we are 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 printcap(5) file is straightforward. Use your favorite text editor to make changes to /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:

  1. Pick a name (and a few convenient aliases) for the printer, and put them in the /etc/printcap file; see the Naming the Printer section for more information on naming.

  2. Turn off header pages (which are on by default) by inserting the sh capability; see the Suppressing Header Pages section for more information.

  3. Make a spooling directory, and specify its location with the sd capability; see the Making the Spooling Directory section for more information.

  4. Set the /dev entry to use for the printer, and note it in /etc/printcap with the lp capability; see the Identifying the Printer Device for more information. Also, if the printer is on a serial port, set up the communication parameters with the ms# capability which is discussed in the Configuring Spooler Communications Parameters section.

  5. Install a plain text input filter; see the Installing the Text Filter section for details.

  6. Test the setup by printing something with the lpr(1) command. More details are available in the Trying It Out and Troubleshooting sections.

Note:

Language-based printers, such as PostScript® printers, cannot directly print plain text. The simple setup outlined above and described in the following sections assumes that if you are installing such a printer you will print only files that the printer can understand.

Users often expect that they can print plain text to any of the printers installed on your system. Programs that interface to LPD to do their printing usually make the same assumption. If you are installing such a printer and want to be able to print jobs in the printer language and print plain text jobs, you are strongly urged to add an additional step to the simple setup outlined above: install an automatic plain-text-to-PostScript® (or other printer language) conversion program. The section entitled Accommodating Plain Text Jobs on PostScript® Printers tells how to do this.

10.3.1.5.1. Naming the Printer

The first (easy) step is to pick a name for your printer. It really does not matter whether you choose functional or whimsical names since you can also provide a number of aliases for the printer.

At least one of the printers specified in the /etc/printcap should have the alias lp. This is the default printer's name. If users do not have the PRINTER environment variable nor specify a printer name on the command line of any of the LPD commands, then lp will be the default printer they get to use.

Also, it is common practice to make the last alias for a printer be a full description of the printer, including make and model.

Once you have picked a name and some common aliases, put them in the /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 rattan and has as aliases line, diablo, lp, and Diablo 630 Line Printer. Since it has the alias lp, it is also the default printer. The second is named bamboo, and has as aliases ps, PS, S, panasonic, and Panasonic KX-P4455 PostScript v51.4.

10.3.1.5.2. Suppressing Header Pages

The LPD spooling system will by default print a header page for each job. The header page contains the user name who requested the job, the host from which the job came, and the name of the job, in nice large letters. Unfortunately, all this extra text gets in the way of debugging the simple printer setup, so we will suppress header pages.

To suppress header pages, add the sh capability to the entry for the printer in /etc/printcap. Here is an example /etc/printcap with sh added:

# # /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. Every line in an entry except the last ends in a backslash character.

10.3.1.5.3. Making the Spooling Directory

The next step in the simple spooler setup is to make a spooling directory, a directory where print jobs reside until they are printed, and where a number of other spooler support files live.

Because of the variable nature of spooling directories, it is customary to put these directories under /var/spool. It is not necessary to backup the contents of spooling directories, either. Recreating them is as simple as running mkdir(1).

It is also customary to make the directory with a name that is identical to the name of the printer, as shown below:

# 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 will do this for our two example printers rattan and bamboo:

# mkdir /var/spool/lpd # mkdir /var/spool/lpd/rattan # mkdir /var/spool/lpd/bamboo

Note:

If you are concerned about the privacy of jobs that users print, you might want to protect the spooling directory so it is not publicly accessible. Spooling directories should be owned and be readable, writable, and searchable by user daemon and group daemon, and no one else. We will do this for our example printers:

# 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 sd capability:

# # /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 and each line end escaped with a backslash.

If you do not specify a spooling directory with sd, the spooling system will use /var/spool/lpd as a default.

10.3.1.5.4. Identifying the Printer Device

In the Hardware Setup section, we identified the port and the relevant /dev directory entry that 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 lp capability.

In our running example, let us assume that rattan is on the first parallel port, and bamboo is on a sixth serial port; here are the additions to /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/ttyu5:

If you do not specify the lp capability for a printer in your /etc/printcap file, LPD uses /dev/lp as a default. /dev/lp currently does not exist in FreeBSD.

If the printer you are installing is connected to a parallel port, skip to the section entitled, Installing the Text Filter. Otherwise, be sure to follow the instructions in the next section.

10.3.1.5.5. 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 do not 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 lp capability:

br#bps-rate

Sets the communications speed of the device to bps-rate, where bps-rate can be 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, or 115200 bits-per-second.

ms#stty-mode

Sets the options for the terminal device after opening the device. stty(1) explains the available options.

When LPD opens the device specified by the lp capability, it sets the characteristics of the device to those specified with the ms# capability. Of particular interest will be the parenb, parodd, cs5, cs6, cs7, cs8, cstopb, crtscts, and ixon modes, which are explained in the stty(1) manual page.

Let us add to our example printer on the sixth serial port. We will set the bps rate to 38400. For the mode, we will set no parity with -parenb, 8-bit characters with cs8, no modem control with clocal and hardware flow control with crtscts:

bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ :sh:sd=/var/spool/lpd/bamboo:\ :lp=/dev/ttyu5:ms#-parenb cs8 clocal crtscts:
10.3.1.5.6. Installing the Text Filter

We are now ready to tell LPD what text filter to use to send jobs to the printer. A text filter, also known as an input filter, is a program that LPD runs when it has a job to print. When LPD runs the text filter for a printer, it sets the filter's standard input to the job to print, and its standard output to the printer device specified with the lp capability. The filter is expected to read the job from standard input, perform any necessary translation for the printer, and write the results to standard output, which will get printed. For more information on the text filter, see the Filters section.

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 lpf that handles backspacing and underlining for printers that might not deal with such character streams well. And, of course, you can use any other filter program you want. The filter lpf is described in detail in section entitled lpf: a Text Filter.

First, let us 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 && 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 if capability in /etc/printcap. We will 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/ttyu5:ms#-parenb cs8 clocal crtscts:\ :if=/usr/local/libexec/if-simple:

Note:

A copy of the if-simple script can be found in the /usr/share/examples/printing directory.

10.3.1.5.7. Turn on LPD

lpd(8) is run from /etc/rc, controlled by the lpd_enable variable. This variable defaults to NO. If you have not done so already, add the line:

lpd_enable="YES"

to /etc/rc.conf, and then either restart your machine, or just run lpd(8).

# lpd
10.3.1.5.8. Trying It Out

You have reached the end of the simple LPD setup. Unfortunately, congratulations are not quite yet in order, since we still have 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 lpr(1), which submits a job for printing.

You can combine lpr(1) with the lptest(1) program, introduced in section Checking Printer Communications to generate some test text.

To test the simple LPD setup:

Type:

# lptest 20 5 | lpr -Pprinter-name

Where printer-name is a the name of a printer (or an alias) specified in /etc/printcap. To test the default printer, type lpr(1) without any -P argument. Again, if you are testing a printer that expects PostScript®, send a PostScript® program in that language instead of using lptest(1). You can do so by putting the program in a file and typing lpr file.

For a PostScript® printer, you should get the results of the program. If you are using lptest(1), then your results should look like the following:

!"#$%&'()*+,-./01234 "#$%&'()*+,-./012345 #$%&'()*+,-./0123456 $%&'()*+,-./01234567 %&'()*+,-./012345678

To further test the printer, try downloading larger programs (for language-based printers) or running lptest(1) with different arguments. For example, lptest 80 60 will produce 60 lines of 80 characters each.

If the printer did not work, see the Troubleshooting section.

10.4. Advanced Printer Setup

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

10.4.1. Filters

Although LPD handles network protocols, queuing, access control, and other aspects of printing, most of the real work happens in the filters. Filters are programs that communicate with the printer and handle its device dependencies and special requirements. In the simple printer setup, we installed a plain text filter—an extremely simple one that should work with most printers (section Installing the Text Filter).

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 you have to provide filters yourself. The good news is that many are generally available; when they are not, they are usually easy to write.

Also, FreeBSD comes with one, /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 is about all it does.) There are also several filters and filter components in the FreeBSD Ports Collection.

Here is what you will find in this section:

  • Section How Filters Work, 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 is 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 for each of your printers.

  • LPD expects every printer to be able to print plain text by default. This presents a problem for PostScript® printers (or other language-based printers) which cannot directly print plain text. Section Accommodating Plain Text Jobs on PostScript® Printers tells you what you should do to overcome this problem. You should read this section if you have a PostScript® printer.

  • PostScript® is a popular output format for many programs. Some people even write PostScript® code directly. Unfortunately, PostScript® printers are expensive. Section Simulating PostScript® on Non PostScript® Printers tells how you can further modify a printer's text filter to accept and print PostScript® data on a non PostScript® printer. You should read this section if you do not have a PostScript® printer.

  • Section Conversion Filters 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 lpr -t to print troff data, or lpr -d to print TeX DVI data, or lpr -v to print raster image data, and so forth. The reading of this section is recommended.

  • Section Output Filters tells all about a not often used feature of LPD: output filters. Unless you are printing header pages (see Header Pages), you can probably skip that section altogether.

  • Section lpf: a Text Filter describes lpf, a fairly complete if simple text filter for line printers (and laser printers that act like line printers) that comes with FreeBSD. If you need a quick way to get printer accounting working for plain text, or if you have a printer which emits smoke when it sees backspace characters, you should definitely consider lpf.

Note:

A copy of the various scripts described below can be found in the /usr/share/examples/printing directory.

10.4.1.1. 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 lf capability in /etc/printcap, or /dev/console by default).

Which filter LPD starts and the filter's arguments depend on what is listed in the /etc/printcap file and what arguments the user specified for the job on the lpr(1) command line. For example, if the user typed lpr -t, LPD would start the troff filter, listed in the tf capability for the destination printer. If the user wanted to print plain text, it would start the if filter (this is mostly true: see Output Filters for details).

There are three kinds of filters you can specify in /etc/printcap:

  • The text filter, confusingly called the input filter in LPD documentation, handles regular text printing. Think of it as the default filter. LPD expects every printer to be able to print plain text by default, and it is the text filter's job to make sure backspaces, tabs, or other special characters do not confuse the printer. If you are in an environment where you have to account for printer usage, the text filter must also account for pages printed, usually by counting the number of lines printed and comparing that to the number of lines per page the printer supports. The text filter is started with the following argument list:

    filter-name [-c] -w width -l length -i indent -n login -h host acct-file

    where

    -c

    appears if the job is submitted with lpr -l

    width

    is the value from the pw (page width) capability specified in /etc/printcap, default 132

    length

    is the value from the pl (page length) capability, default 66

    indent

    is the amount of the indentation from lpr -i, default 0

    login

    is the account name of the user printing the file

    host

    is the host name from which the job was