Summary

This is a handbook for FreeBSD, covering installation, day-to-day use, and various tasks. It details system configuration, software installation, and common tasks. The guide features descriptions of installation and network setup, along with various utilities and desktop environments.

Full Transcript

FreeBSD Handbook Abstract Welcome to FreeBSD! This handbook covers the installation and day to day use of FreeBSD 14.1- RELEASE and 13.4-RELEASE. This book is the result of ongoing work by many individuals. Some sections might be outdated. Those interested in helping to update and expand this docu...

FreeBSD Handbook Abstract Welcome to FreeBSD! This handbook covers the installation and day to day use of FreeBSD 14.1- RELEASE and 13.4-RELEASE. This book is the result of ongoing work by many individuals. Some sections might be outdated. Those interested in helping to update and expand this document should send email to the FreeBSD documentation project mailing list. The latest version of this book is available from the FreeBSD web site. Previous versions can be obtained from https://docs.FreeBSD.org/doc/. The book can be downloaded in a variety of formats and compression options from the FreeBSD download server or one of the numerous mirror sites. Searches can be performed on the handbook and other documents on the search page. 1 Table of Contents Preface................................................................................... 10 Intended Audience....................................................................... 10 Fourth Edition........................................................................... 10 Third Edition............................................................................ 10 Second Edition (2004).................................................................... 11 First Edition (2001)...................................................................... 11 Organization of This Book................................................................ 12 Conventions used in this book............................................................ 15 Acknowledgments....................................................................... 16 I: Getting Started........................................................................... 18 1. Introduction.......................................................................... 19 1.1. Synopsis.......................................................................... 19 1.2. Welcome to FreeBSD!.............................................................. 19 1.3. About the FreeBSD Project.......................................................... 21 2. Installing FreeBSD..................................................................... 26 2.1. Synopsis.......................................................................... 26 2.2. Minimum Hardware Requirements................................................. 26 2.3. Pre-Installation Tasks.............................................................. 26 2.4. Starting the Installation............................................................ 30 2.5. Using bsdinstall................................................................... 34 2.6. Allocating Disk Space.............................................................. 39 2.7. Fetching Distribution Files.......................................................... 62 2.8. Network Interfaces, Accounts, Time Zone, Services and Hardening..................... 65 2.9. Troubleshooting................................................................... 94 2.10. Using the Live CD................................................................. 94 3. FreeBSD Basics........................................................................ 95 3.1. Synopsis.......................................................................... 95 3.2. Virtual Consoles and Terminals..................................................... 95 3.3. Users and Basic Account Management............................................... 98 3.4. Permissions...................................................................... 107 3.5. Directory Structure............................................................... 112 3.6. Disk Organization................................................................ 114 3.7. Mounting and Unmounting File Systems............................................ 120 3.8. Processes and Daemons........................................................... 122 3.9. Shells............................................................................ 125 3.10. Text Editors..................................................................... 128 3.11. Devices and Device Nodes........................................................ 128 3.12. Manual Pages................................................................... 128 2 4. Installing Applications: Packages and Ports............................................. 131 4.1. Synopsis......................................................................... 131 4.2. Overview of Software Installation.................................................. 131 4.3. Finding Software................................................................. 132 4.4. Using pkg for Binary Package Management......................................... 133 4.5. Using the Ports Collection......................................................... 142 4.6. Building Packages with poudriere.................................................. 150 4.7. Post-Installation Considerations.................................................... 153 4.8. Dealing with Broken Ports......................................................... 154 5. The X Window System................................................................ 155 5.1. Synopsis......................................................................... 155 5.2. Installing Xorg................................................................... 155 5.3. Graphic card drivers.............................................................. 156 5.4. Xorg Configuration............................................................... 158 5.5. Using Fonts in Xorg............................................................... 163 6. Wayland on FreeBSD................................................................. 168 6.1. Synopsis......................................................................... 168 6.2. Wayland Overview............................................................... 168 6.3. The Wayfire Compositor.......................................................... 170 6.4. The Hikari Compositor............................................................ 172 6.5. The Sway Compositor............................................................. 174 6.6. Using Xwayland.................................................................. 175 6.7. Remote Desktop Using VNC........................................................ 178 6.8. Wayland Login Manager.......................................................... 178 6.9. Useful Utilities.................................................................... 179 7. Network............................................................................. 181 7.1. Synopsis......................................................................... 181 7.2. Setting up the Network............................................................ 181 7.3. Wired Networks.................................................................. 182 7.4. Wireless Networks................................................................ 190 7.5. Hostname........................................................................ 194 7.6. DNS............................................................................. 194 7.7. Troubleshooting.................................................................. 196 II: Common Tasks......................................................................... 198 8. Desktop Environments................................................................ 199 8.1. Synopsis......................................................................... 199 8.2. Desktop Environments............................................................ 199 8.3. Browsers........................................................................ 206 8.4. Development tools................................................................ 209 8.5. Desktop office productivity........................................................ 211 8.6. Document Viewers................................................................ 213 3 8.7. Finance.......................................................................... 214 9. Multimedia.......................................................................... 216 9.1. Synopsis......................................................................... 216 9.2. Setting Up the Sound Card......................................................... 216 9.3. Audio players.................................................................... 219 9.4. Video players..................................................................... 220 9.5. Conferencing and Meetings........................................................ 222 9.6. Image Scanners.................................................................. 224 10. Configuring the FreeBSD Kernel...................................................... 228 10.1. Synopsis........................................................................ 228 10.2. Why Build a Custom Kernel?..................................................... 228 10.3. Finding the System Hardware.................................................... 229 10.4. The Configuration File........................................................... 230 10.5. Building and Installing a Custom Kernel........................................... 232 10.6. If Something Goes Wrong........................................................ 233 11. Printing............................................................................ 235 11.1. Quick Start...................................................................... 235 11.2. Printer Connections............................................................. 236 11.3. Common Page Description Languages............................................. 237 11.4. Direct Printing.................................................................. 239 11.5. LPD (Line Printer Daemon)....................................................... 239 11.6. Other Printing Systems........................................................... 248 12. Linux Binary Compatibility.......................................................... 249 12.1. Synopsis........................................................................ 249 12.2. Configuring Linux Binary Compatibility........................................... 249 12.3. Linux userlands................................................................. 250 12.4. Advanced Topics................................................................ 254 13. WINE.............................................................................. 258 13.1. Synopsis........................................................................ 258 13.2. WINE Overview & Concepts...................................................... 259 13.3. Installing WINE on FreeBSD...................................................... 261 13.4. Running a First WINE Program on FreeBSD........................................ 263 13.5. Configuring WINE Installation.................................................... 264 13.6. WINE Management GUIs......................................................... 272 13.7. WINE in Multi-User FreeBSD Installations......................................... 286 13.8. WINE on FreeBSD FAQ........................................................... 288 III: System Administration................................................................. 292 14. Configuration, Services, Logging and Power Management.............................. 293 14.1. Synopsis........................................................................ 293 14.2. Configuration Files.............................................................. 293 14.3. Managing Services in FreeBSD.................................................... 298 4 14.4. Cron and Periodic............................................................... 300 14.5. Configuring System Logging...................................................... 304 14.6. Power and Resource Management................................................ 313 14.7. Adding Swap Space.............................................................. 319 15. The FreeBSD Booting Process......................................................... 321 15.1. Synopsis........................................................................ 321 15.2. FreeBSD Boot Process............................................................ 321 15.3. Device Hints.................................................................... 327 15.4. Shutdown Sequence............................................................. 328 16. Security............................................................................ 329 16.1. Synopsis........................................................................ 329 16.2. Introduction.................................................................... 329 16.3. Securing Accounts............................................................... 330 16.4. Intrusion Detection System (IDS).................................................. 336 16.5. Secure levels.................................................................... 338 16.6. File flags........................................................................ 340 16.7. OpenSSH....................................................................... 341 16.8. OpenSSL........................................................................ 346 16.9. Kerberos........................................................................ 350 16.10. TCP Wrappers.................................................................. 358 16.11. Access Control Lists............................................................. 359 16.12. Capsicum...................................................................... 361 16.13. Process Accounting............................................................. 361 16.14. Resource Limits................................................................ 362 16.15. Monitoring Third Party Security Issues........................................... 365 16.16. FreeBSD Security Advisories..................................................... 366 17. Jails and Containers................................................................. 372 17.1. Synopsis........................................................................ 372 17.2. Jail Types....................................................................... 372 17.3. Host Configuration.............................................................. 375 17.4. Classic Jail (Thick Jail)............................................................ 378 17.5. Thin Jails....................................................................... 380 17.6. Jail Management................................................................ 389 17.7. Jail Upgrading................................................................... 391 17.8. Jail Resource Limits.............................................................. 393 17.9. Jail Managers and Containers..................................................... 393 18. Mandatory Access Control............................................................ 395 18.1. Synopsis........................................................................ 395 18.2. Key Terms...................................................................... 396 18.3. Understanding MAC Labels....................................................... 397 18.4. Planning the Security Configuration............................................... 401 5 18.5. Available MAC Policies........................................................... 402 18.6. User Lock Down................................................................. 409 18.7. Nagios in a MAC Jail............................................................. 410 18.8. Troubleshooting the MAC Framework............................................. 414 19. Security Event Auditing.............................................................. 416 19.1. Synopsis........................................................................ 416 19.2. Key Terms...................................................................... 416 19.3. Audit Configuration.............................................................. 417 19.4. Working with Audit Trails........................................................ 421 20. Storage............................................................................. 425 20.1. Synopsis........................................................................ 425 20.2. Adding Disks.................................................................... 425 20.3. Resizing and Growing Disks...................................................... 426 20.4. USB Storage Devices............................................................. 429 20.5. Creating and Using CD Media..................................................... 432 20.6. Creating and Using DVD Media................................................... 438 20.7. Creating and Using Floppy Disks.................................................. 443 20.8. Using NTFS Disks................................................................ 444 20.9. Backup Basics................................................................... 445 20.10. Memory Disks.................................................................. 450 20.11. File System Snapshots.......................................................... 452 20.12. Disk Quotas.................................................................... 453 20.13. Encrypting Disk Partitions...................................................... 456 20.14. Encrypting Swap............................................................... 462 20.15. Highly Available Storage (HAST)................................................. 464 21. GEOM: Modular Disk Transformation Framework...................................... 472 21.1. Synopsis........................................................................ 472 21.2. RAID0 - Striping................................................................. 472 21.3. RAID1 - Mirroring............................................................... 474 21.4. RAID3 - Byte-level Striping with Dedicated Parity................................... 484 21.5. Software RAID Devices........................................................... 485 21.6. GEOM Gate Network............................................................. 490 21.7. Labeling Disk Devices............................................................ 490 21.8. UFS Journaling Through GEOM................................................... 493 22. The Z File System (ZFS).............................................................. 495 22.1. What Makes ZFS Different........................................................ 495 22.2. Quick Start Guide................................................................ 495 22.3. zpool Administration............................................................ 502 22.4. zfs Administration.............................................................. 520 22.5. Delegated Administration........................................................ 541 22.6. Advanced Topics................................................................ 542 6 22.7. Further Resources............................................................... 545 22.8. ZFS Features and Terminology.................................................... 545 23. Other File Systems................................................................... 553 23.1. Synopsis........................................................................ 553 23.2. Linux® File Systems............................................................. 553 24. Virtualization....................................................................... 555 24.1. Synopsis........................................................................ 555 24.2. FreeBSD as a Guest on Parallels Desktop for macOS®............................... 555 24.3. FreeBSD as a Guest on VMware Fusion for macOS®................................ 562 24.4. FreeBSD as a Guest on VirtualBox™............................................... 574 24.5. FreeBSD as a Host with VirtualBox™.............................................. 575 24.6. Virtualization with QEMU on FreeBSD............................................. 578 24.7. FreeBSD as a Host with bhyve.................................................... 603 24.8. FreeBSD as a Xen™-Host......................................................... 619 25. Localization - i18n/L10n Usage and Setup.............................................. 626 25.1. Synopsis........................................................................ 626 25.2. Using Localization............................................................... 626 25.3. Finding i18n Applications........................................................ 633 25.4. Locale Configuration for Specific Languages....................................... 633 26. Updating and Upgrading FreeBSD..................................................... 636 26.1. Synopsis........................................................................ 636 26.2. FreeBSD Update................................................................. 636 26.3. Updating Bootcode.............................................................. 644 26.4. Updating the Documentation Set.................................................. 644 26.5. Tracking a Development Branch.................................................. 645 26.6. Updating FreeBSD from Source................................................... 648 26.7. Tracking for Multiple Machines................................................... 655 26.8. Building on non-FreeBSD Hosts................................................... 656 27. DTrace............................................................................. 657 27.1. Synopsis........................................................................ 657 27.2. Implementation Differences...................................................... 657 27.3. Enabling DTrace Support......................................................... 658 27.4. Enabling DTrace in Out-of-Kernel Modules......................................... 659 27.5. Using DTrace.................................................................... 659 28. USB Device Mode / USB OTG.......................................................... 662 28.1. Synopsis........................................................................ 662 28.2. USB Virtual Serial Ports.......................................................... 662 28.3. USB Device Mode Network Interfaces............................................. 664 28.4. USB Virtual Storage Device....................................................... 665 IV: Network Communication............................................................... 667 29. Serial Communications.............................................................. 668 7 29.1. Synopsis........................................................................ 668 29.2. Serial Terminology and Hardware................................................ 668 29.3. Terminals....................................................................... 672 29.4. Dial-in Service................................................................... 676 29.5. Dial-out Service................................................................. 679 29.6. Setting Up the Serial Console..................................................... 683 30. PPP................................................................................ 688 30.1. Synopsis........................................................................ 688 30.2. Configuring PPP................................................................. 688 30.3. Troubleshooting PPP Connections................................................. 696 30.4. Using PPP over Ethernet (PPPoE).................................................. 699 30.5. Using PPP over ATM (PPPoA)..................................................... 701 31. Electronic Mail...................................................................... 704 31.1. Synopsis........................................................................ 704 31.2. Mail Components................................................................ 704 31.3. DragonFly Mail Agent (DMA)..................................................... 705 31.4. Sendmail....................................................................... 706 31.5. Changing the Mail Transfer Agent................................................. 709 31.6. Mail User Agents................................................................ 711 31.7. Advanced Topics................................................................ 719 32. Network Servers.................................................................... 725 32.1. Synopsis........................................................................ 725 32.2. The inetd Super-Server........................................................... 725 32.3. Network File System (NFS)....................................................... 729 32.4. Network Information System (NIS)................................................ 733 32.5. Lightweight Directory Access Protocol (LDAP)...................................... 747 32.6. Dynamic Host Configuration Protocol (DHCP)...................................... 755 32.7. Domain Name System (DNS)...................................................... 759 32.8. Zero-configuration networking (mDNS/DNS-SD).................................... 762 32.9. Apache HTTP Server............................................................. 762 32.10. File Transfer Protocol (FTP)..................................................... 769 32.11. File and Print Services for Microsoft® Windows® Clients (Samba).................. 770 32.12. Clock Synchronization with NTP................................................. 773 32.13. iSCSI Initiator and Target Configuration.......................................... 776 33. Firewalls........................................................................... 782 33.1. Synopsis........................................................................ 782 33.2. Firewall Concepts............................................................... 783 33.3. PF.............................................................................. 784 33.4. IPFW........................................................................... 800 33.5. IPFILTER (IPF)................................................................... 816 33.6. Blacklistd....................................................................... 828 8 34. Advanced Networking............................................................... 833 34.1. Synopsis........................................................................ 833 34.2. Gateways and Routes............................................................ 833 34.3. Virtual Hosts.................................................................... 839 34.4. Wireless Advanced Authentication................................................ 840 34.5. Wireless Ad-hoc Mode........................................................... 844 34.6. USB Tethering................................................................... 848 34.7. Bluetooth....................................................................... 849 34.8. Bridging........................................................................ 858 34.9. Link Aggregation and Failover.................................................... 864 34.10. Diskless Operation with PXE..................................................... 870 34.11. Common Address Redundancy Protocol (CARP)................................... 875 34.12. VLANs......................................................................... 877 V: Appendices............................................................................ 879 Appendix A: Obtaining FreeBSD......................................................... 880 A.1. Mirrors.......................................................................... 880 A.2. Using Git........................................................................ 883 A.3. Using Subversion................................................................. 885 A.4. Disc Copies...................................................................... 888 Appendix B: Bibliography............................................................... 889 B.1. FreeBSD Bibliography............................................................. 889 B.2. Security Reference............................................................... 889 B.3. UNIX® History................................................................... 889 B.4. Periodicals, Journals, and Magazines............................................... 890 Appendix C: Resources on the Internet................................................... 891 C.1. Websites......................................................................... 891 C.2. Mailing Lists..................................................................... 891 C.3. Usenet Newsgroups............................................................... 894 Appendix D: OpenPGP Keys............................................................. 895 D.1. Officers.......................................................................... 895 FreeBSD Glossary....................................................................... 902 Colophon.............................................................................. 922 9 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 Bibliography. Fourth Edition The current version of the Handbook represents the cumulative effort of a working group that has been reviewing and updating all Handbook content. These are the major updates since the fourth edition of the Handbook. The Handbook has been converted from Docbook to Hugo and AsciiDoctor The FreeBSD Documentation Portal has been created. Wayland has been added with information about installing and configuring Wayland under FreeBSD. The Bibliography has been extensively updated. 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: WINE has been added with information about how to run Windows® applications on FreeBSD. DTrace has been added with information about the powerful DTrace performance analysis tool. Other File Systems have been added with information about non-native file systems in FreeBSD, such as ZFS from Sun™. Security Event Auditing has been added to cover the new auditing capabilities in FreeBSD and explain its use. Virtualization has been added with information about installing FreeBSD on virtualization software. Installing FreeBSD has been added to cover installation of FreeBSD using the new installation utility, bsdinstall. 10 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: 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. Security has been expanded with new information about virtual private networks (VPNs), file system access control lists (ACLs), and security advisories. Mandatory Access Control is a new chapter with this edition. It explains what MAC is and how this mechanism can be used to secure a FreeBSD system. 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 PPP. Electronic Mail has been expanded with new information about using alternative transport agents, SMTP authentication, UUCP, fetchmail, procmail, and other advanced topics. 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 Advanced Networking were moved here to improve the presentation. 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. 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". FreeBSD Basics has been expanded to contain additional information about processes, daemons, and signals. 11 Installing Applications: Packages and Ports has been expanded to contain additional information about binary package management. 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. The FreeBSD Booting Process has been expanded. 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. Serial Communications has been completely reorganized and updated for FreeBSD 4.X/5.X. PPP has been substantially updated. Many new sections have been added to Advanced Networking. Electronic Mail has been expanded to include more information about configuring sendmail. Linux® Binary Compatibility has been expanded to include information about installing Oracle® and SAP® R/3®. The following new topics are covered in this second edition: ◦ Configuration and Tuning. ◦ Multimedia. 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. Introduction Introduces FreeBSD to a new user. It describes the history of the FreeBSD Project, its goals and development model. Installing FreeBSD Walks a user through the entire installation process of FreeBSD 9.x and later using bsdinstall. FreeBSD 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. Installing Applications: Packages and Ports Covers the installation of third-party software with both FreeBSD’s innovative "Ports Collection" 12 and standard binary packages. 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. Wayland Describes the Wayland display server in general and using Wayland on FreeBSD in particular. Also describes common compositors such as Wayfire, Hikari and Sway. Desktop Applications Lists some common desktop applications, such as web browsers and productivity suites, and describes how to install them on FreeBSD. Multimedia Shows how to set up sound and video playback support for your system. Also describes some sample audio and video applications. 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. Printing Describes managing printers on FreeBSD, including information about banner pages, printer accounting, and initial setup. 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®. WINE Describes WINE and provides detailed installation instructions. Also describes how WINE operates, how to install a GUI helper, how to run Windows® applications on FreeBSD, and offers other tips and solutions. 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. The FreeBSD Booting Process Describes the FreeBSD boot process and explains how to control this process with configuration options. Security Describes many different tools available to help keep your FreeBSD system secure, including Kerberos, IPsec and OpenSSH. 13 Jails Describes the jails framework, and the improvements of jails over the traditional chroot support of FreeBSD. Mandatory Access Control Explains what Mandatory Access Control (MAC) is and how this mechanism can be used to secure a FreeBSD system. Security Event Auditing Describes what FreeBSD Event Auditing is, how it can be installed, configured, and how audit trails can be inspected or monitored. 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. GEOM: Modular Disk Transformation Framework Describes what the GEOM framework in FreeBSD is and how to configure various supported RAID levels. The OpenZFS storage platform Describes the OpenZFS storage platform and provides a quick-start guide and information about advanced topics running OpenZFS under FreeBSD. Other File Systems Examines support for non-native file systems under FreeBSD like ext2, ext3 and ext4. Virtualization Describes what virtualization systems offer, and how they can be used with FreeBSD. Localization - i18n/L10n Usage and Setup Describes how to use FreeBSD in languages other than English. Covers both system and application level localization. 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. DTrace Describes how to configure and use the DTrace tool from Sun™ on FreeBSD. Dynamic tracing can help locate performance issues, by performing real time system analysis. USB Device Mode / USB OTG Explains the use of USB Device Mode and USB On The Go (USB OTG) on FreeBSD. PPP Describes how to use PPP to connect to remote systems in FreeBSD. 14 Electronic Mail Explains the different components of an email server and dives into simple configuration topics for the most popular mail server software: sendmail. 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. Firewalls Explains the philosophy behind software-based firewalls and provides detailed information about the configuration of the different firewalls available for FreeBSD. 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. 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. 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. Resources on the Internet Describes the many forums available for FreeBSD users to post questions and engage in technical conversations about FreeBSD. OpenPGP 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. 15 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 C:\> indicate a MS-DOS® command. Unless otherwise noted, these commands may be executed from a "Command Prompt" window in a modern Microsoft® Windows® environment. C:\> 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 16 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. The third printed edition has been split into two volumes. Both volumes have been published as The FreeBSD Handbook 3rd Edition Volume 1: User Guide (ISBN 1-57176-327-9) and The FreeBSD Handbook 3rd Edition Volume 2: Administrators Guide (ISBN 1-57176-328-7). 17 Part I: Getting Started This part of the handbook is for users and administrators who are new to FreeBSD. These chapters: Introduce FreeBSD. Guide readers through the installation process. Teach UNIX® basics and fundamentals. Show how to install the wealth of third party applications available for FreeBSD. Introduce X, the UNIX® windowing system, and detail how to configure a desktop environment that makes users more productive. Introduce Wayland, a new display server for UNIX®. The number of forward references in the text have been kept to a minimum so that this section can be read from front to back with minimal page flipping. 18 Chapter 1. Introduction 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 an Open Source, standards-compliant Unix-like operating system for x86 (both 32 and 64 bit), ARM, AArch64, RISC-V, POWER, and PowerPC computers. It provides all the features that are nowadays taken for granted, such as preemptive multitasking, memory protection, virtual memory, multi-user facilities, SMP support, all the Open Source development tools for different languages and frameworks, and desktop features centered around X Window System, KDE, or GNOME. Its particular strengths are: Liberal Open Source license, which grants you rights to freely modify and extend its source code and incorporate it in both Open Source projects and closed products without imposing restrictions typical to copyleft licenses, as well as avoiding potential license incompatibility problems. Strong TCP/IP networking - FreeBSD implements industry standard protocols with ever increasing performance and scalability. This makes it a good match in both server, and routing/firewalling roles - and indeed many companies and vendors use it precisely for that purpose. Fully integrated OpenZFS support, including root-on-ZFS, ZFS Boot Environments, fault management, administrative delegation, support for jails, FreeBSD specific documentation, and system installer support. Extensive security features, from the Mandatory Access Control framework to Capsicum capability and sandbox mechanisms. Over 30 thousand prebuilt packages for all supported architectures, and the Ports Collection which makes it easy to build your own, customized ones. Documentation - in addition to the Handbook and books from different authors that cover topics ranging from system administration to kernel internals, there are also the man(1) pages, not only for userspace daemons, utilities, and configuration files, but also for kernel driver APIs (section 9) and individual drivers (section 4). 19 Simple and consistent repository structure and build system - FreeBSD uses a single repository for all of its components, both kernel and userspace. This, along with a unified and easy to customize build system and a well thought-out development process makes it easy to integrate FreeBSD with build infrastructure for your own product. Staying true to Unix philosophy, preferring composability instead of monolithic "all in one" daemons with hardcoded behavior. Binary compatibility with Linux, which makes it possible to run many Linux binaries without the need for virtualisation. 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 man-hours into extending the functionality and fine-tuning the system for maximum performance and reliability in real-life load situations. FreeBSD offers performance and reliability on par with other Open Source and commercial offerings, combined with cutting-edge features not available anywhere else. 1.2.1. What Can FreeBSD Do? 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 antenna; 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. Because the source code for FreeBSD itself is freely 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: ◦ Web servers ◦ IPv4 and IPv6 routing ◦ Firewalls and NAT ("IP masquerading") gateways ◦ FTP servers ◦ Email servers ◦ Storage servers ◦ Virtualization servers ◦ And more… 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 20 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 PC sitting in the corner into an advanced router with sophisticated packet-filtering capabilities. Embedded: FreeBSD makes an excellent platform to build embedded systems upon. With support for the ARM, AArch64 and PowerPC platforms, coupled with a robust network stack, cutting edge features, and the permissive BSD license, FreeBSD makes an excellent foundation for building embedded routers, firewalls, and other devices. Desktop: FreeBSD makes a fine choice for an inexpensive desktop solution using the freely available X11 server and Wayland display server. FreeBSD offers a choice from many open- source desktop environments, including the standard GNOME and KDE graphical user interfaces. FreeBSD can even boot "diskless" from a central server, making individual workstations even cheaper and easier to administer. Software Development: The basic FreeBSD system comes with a full suite of development tools including a full C/C++ compiler and debugger suite. Support for many other languages are also available through the ports and packages collection. FreeBSD is available to download free of charge, or can be obtained on either CD-ROM or DVD. Please see Obtaining FreeBSD for more information about obtaining FreeBSD. 1.2.2. Who Uses FreeBSD? FreeBSD has been known for its web serving capabilities. A list of testimonials from companies basing their products and services on FreeBSD can be found at the FreeBSD Foundation website. Wikipedia also maintains a list of products based on FreeBSD. 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 the brainchild of the Unofficial 386BSDPatchkit’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 that the patchkit mechanism was just not capable of solving. The early working title for the project was 386BSD 0.5 or 386BSD Interim in reference to that fact. 21 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 three files of Net/2 were "encumbered" code and had to be removed as they were 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. Although only three files having to do with System V shared memory and semaphores were removed, many other changes and bug fixes had been made to the BSD distribution, so it was a huge task to merge all the FreeBSD developments into 4.4BSD- Lite. It took the project until November of 1994 to make this transition, and in December it released FreeBSD 2.0 to the world. 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 15.0-CURRENT (main) branch, and snapshot releases of 15.0 are continually made available from the snapshot server as work progresses. 22 1.3.2. FreeBSD Project Goals 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, we 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 license when it is a reasonable option to do so. 1.3.3. The FreeBSD Development Model The development of FreeBSD is a very open and flexible process, being literally built from the contributions of thousands of people around the world, as can be seen from our list of contributors. FreeBSD’s development infrastructure allows these thousands of contributors to collaborate over the Internet. We are constantly on the lookout for new volunteers, and those interested in becoming more closely involved should consult the article on Contributing to FreeBSD. Useful things to know about the FreeBSD Project and its development process, whether working independently or in close cooperation: The Git repositories For several years, the central source tree for FreeBSD was maintained by CVS (Concurrent Versions System), a freely available source code control tool. 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. In December 2020, the Project migrated Source and Documentation repositories to Git, with Ports following suit in April 2021. Please refer to the Obtaining the Source 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 push access to the Git repository, and are authorized to make modifications to the FreeBSD source (the term "committer" comes from commit, the source control command which is used to bring new changes into the repository). Anyone can submit a bug to the Bug Database. Before submitting a bug report, the FreeBSD mailing lists, IRC channels, or forums can be used to help verify that an issue is actually a bug. 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 23 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 May and June 2024. Elections are held every 2 years. Like most developers, most members of the core team are also 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! The FreeBSD Foundation The FreeBSD Foundation is a 501(c)(3), US-based, non-profit organization dedicated to supporting and promoting the FreeBSD Project and community worldwide. The Foundation funds software development via project grants and provides staff to immediately respond to urgent problems and implement new features and functionality. The Foundation purchases hardware to improve and maintain FreeBSD infrastructure, and funds staffing to improve test coverage, continuous integration and automation. The Foundation advocates for FreeBSD by promoting FreeBSD at technical conferences and events around the world. The Foundation also provides workshops, educational material, and presentations to recruit more users and contributors to FreeBSD. The Foundation also represents the FreeBSD Project in executing contracts, license agreements, and other legal arrangements that require a recognized legal entity. 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 the development of the FreeBSD base system is to subscribe to the FreeBSD technical discussions mailing list where such things are discussed. For porting third party applications, it would be the FreeBSD ports mailing list. For documentation - FreeBSD documentation project mailing list. See 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! 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! 24 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. The list of ports ranges from HTTP servers to games, languages, editors, and almost everything in between. There are about 36000 ports; the entire Ports Collection requires approximately 3 GB. 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 install) by those who do not wish to compile their own ports from source. More information on packages and ports can be found in Installing Applications: Packages and Ports. 1.3.5. Additional Documentation All supported FreeBSD versions provide an option in the installer to install additional documentation under /usr/local/share/doc/freebsd during the initial system setup. Documentation may also be installed later using packages: # pkg install en-freebsd-doc For localized versions replace the "en" with the language prefix of choice. Be aware that some of the localised versions might be out of date and might contain information that is no longer correct or relevant. You may view the locally installed manuals with a web browser using the following URLs: The FreeBSD Handbook /usr/local/share/doc/freebsd/en/books/handbook/handbook_en.pdf The FreeBSD FAQ /usr/local/share/doc/freebsd/en/books/faq/faq_en.pdf You can always find up to date documentation at The Documentation Portal. All trademarks are the property of their respective owners. 25 Chapter 2. Installing FreeBSD 2.1. Synopsis FreeBSD supports different architectures including amd64, ARM®, RISC-V®, and PowerPC®. Depending on the architecture and platform, different images can be downloaded to install or directly run FreeBSD. The image types are: Virtual Machine disk images, such as qcow2, vmdk, vhd, and raw device images. These are not installation images, but images that have FreeBSD preinstalled and ready for post-installation tasks. Virtual machine images are also commonly used in cloud environments. SD card images, for embedded systems such as Raspberry Pi. These files must be uncompressed and written as a raw image to an SD card, from which the board will boot. Installation images to boot from an ISO or USB device to install FreeBSD on a drive for the usual desktop, laptop, or server system. The rest of this chapter describes the third case, explaining how to install FreeBSD using the text- based installation program named bsdinstall. There may be minor differences between the installer and what is shown here, so use this chapter as a general guide rather than as a set of literal instructions. After reading this chapter, you will know: How to obtain FreeBSD images and create FreeBSD installation media. How to start bsdinstall. The questions bsdinstall will ask, what they mean, and how to answer them. How to troubleshoot a failed installation. How to access a live version of FreeBSD before committing to an installation. 2.2. Minimum Hardware Requirements The hardware requirements to install FreeBSD vary by architecture and version. Hardware architectures and devices supported by a FreeBSD release are listed on the FreeBSD Release Information page. The FreeBSD download page also has recommendations for choosing the correct image for different architectures. 2.3. Pre-Installation Tasks Once it has been determined that the system meets the minimum hardware requirements for installing FreeBSD, the installation file should be downloaded and the installation media prepared. Consider using virtualization if you want to use FreeBSD on a system that already  26 has another operating system installed. Before moving on to the installation, check that the system is ready by verifying the items in this checklist: 1. Back Up Important Data Before installing any operating system, always backup all important data first. Do not store the backup on the system being installed. Instead, save the data to a removable disk such as a USB drive, another system on the network, or an online backup service. Test the backup before starting the installation to make sure it contains all of the needed files. Once the installer formats the system’s disk, all data stored on that disk will be lost. 2. Decide Where to Install FreeBSD If FreeBSD will be the only operating system installed, this step can be skipped. But if FreeBSD will share the disk with another operating system, decide which disk or partition will be used for FreeBSD. In the i386 and amd64 architectures, disks can be divided into multiple partitions using one of two partitioning schemes. A traditional Master Boot Record (MBR) holds a partition table defining up to four primary partitions. For historical reasons, FreeBSD calls these primary partition slices. One of these primary partitions can be made into an extended partition containing multiple logical partitions. The GUID Partition Table (GPT) is a newer and simpler method of partitioning a disk. Common GPT implementations allow up to 128 partitions per disk, eliminating the need for logical partitions. The FreeBSD boot loader requires either a primary or GPT partition. If all of the primary or GPT partitions are already in use, one must be freed for FreeBSD. To create a partition without deleting existing data, use a partition resizing tool to shrink an existing partition and create a new partition using the freed space. An alternative to modifying the system’s existing disk partitions is to use virtualization, which allows multiple operating systems to run at the same time without having to alter partitions. A variety of free and commercial partition resizing tools are listed at List of disk partitioning software wikipedia entry. GParted Live is a free live CD which includes the GParted partition editor. When used properly, disk shrinking utilities can safely create space for creating a new partition. Since the possibility of selecting the wrong  partition exists, always backup any important data and verify the integrity of the backup before modifying disk partitions. Disk partitions containing different operating systems make it possible to install multiple operating systems on one computer. 3. Collect Network Information 27 Some FreeBSD installation methods require a network connection in order to download the installation files. After any installation, the installer will offer to setup the system’s network interfaces. If the network has a DHCP server, it can be used to provide automatic network configuration. If DHCP is not available, the following network information for the system must be obtained from the local network administrator or Internet service provider: Required Network Information a. IP address b. Subnet mask c. IP address of default gateway d. Domain name of the network e. IP addresses of the network’s DNS servers 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 page of each version. 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 FreeBSD Release Information page. 2.3.1. Prepare the Installation Media The FreeBSD installer is not an application that can be run from within another operating system. Instead, download a FreeBSD installation file, burn it to the media associated with its file type and size (CD, DVD, or USB), and boot the system to install from the inserted media. FreeBSD installation files are available at the FreeBSD download page. Each installation file’s name includes the release version of FreeBSD, the architecture, and the type of file. Installation files are available in several formats, compressed with xz(1) or uncompressed. The formats vary depending on computer architecture and media type. Installation file types: -bootonly.iso: This is the smallest installation file as it only contains the installer. A working Internet connection is required during installation as the installer will download the files it needs to complete the FreeBSD installation. This file should be burned to optical media. -disc1.iso: This file contains all of the files needed to install FreeBSD, its source, and the Ports Collection. This file should be burned to optical media. -dvd1.iso: This file contains all of the files needed to install FreeBSD, its source, and the Ports 28 Collection. It also contains a set of popular binary packages for installing a window manager and some applications so that a complete system can be installed from media without requiring a connection to the Internet. This file should be burned to optical media. -memstick.img: This file contains all of the files needed to install FreeBSD, its source, and the Ports Collection. Write this file to a USB stick as shown in Writing an Image File to USB. -mini-memstick.img: Like -bootonly.iso, does not include installation files, but downloads them as needed. A working internet connection is required during installation. It should be written to a USB stick as shown in Writing an Image File to USB. After downloading the image file, download at least one checksum file from the same directory. There are two checksum files available, named after the release number and the architecture name. For example: CHECKSUM.SHA256-FreeBSD-13.1-RELEASE-amd64 and CHECKSUM.SHA512-FreeBSD-13.1- RELEASE-amd64. After downloading one of the files (or both), calculate the checksum for the image file and compare it with the one shown in the checksum file. Note that you need to compare the calculated checksum against the correct file, as they correspond to two different algorithms: SHA256 and SHA512. FreeBSD provides sha256(1) and sha512(1) that can be used for calculating the checksum. Other operating systems have similar programs. Verifying the checksum in FreeBSD can be done automatically using sha256sum(1) (and sha512sum(1)) by executing: % sha256sum -c CHECKSUM.SHA256-FreeBSD-13.1-RELEASE-amd64 FreeBSD-13.1-RELEASE-amd64- dvd1.iso FreeBSD-13.1-RELEASE-amd64-dvd1.iso: OK The checksums must match exactly. If the checksums do not match, the image file is corrupt and must be downloaded again. 2.3.1.1. Writing an Image File to USB The *memstick.img file is an image of the complete contents of a memory stick. It cannot be copied to the target device as a file. Several applications are available for writing the *.img to a USB stick. This section describes two of these utilities. Before proceeding, back up any important data on the USB stick. This procedure  will erase the existing data on the stick. Procedure. Using dd to write the image This example uses /dev/da0 as the target device where the image will be  written. Be very careful that the correct device is used as this command will destroy the existing data on the specified target device. 1. The command-line utility is available on BSD, Linux®, and Mac OS® systems. To burn the 29 image using dd, insert the USB stick and determine its device name. Then, specify the name of the downloaded installation file and the device name for the USB stick. This example burns the amd64 installation image to the first USB device on an existing FreeBSD system. # dd if=FreeBSD-13.1-RELEASE-amd64-memstick.img of=/dev/da0 bs=1M conv=sync If this command fails, verify that the USB stick is not mounted and that the device name is for the disk, not a partition. Some operating systems might require this command to be run with sudo(8). The dd(1) syntax varies slightly across different platforms; for example, Mac OS® requires a lower- case bs=1m. Systems like Linux® might buffer writes. To force all writes to complete, use sync(8). Procedure. Using Windows® to Write the Image Be sure to give the correct drive letter as the existing data on the specified  drive will be overwritten and destroyed. 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 win32diskimager home page 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. 2.4. Starting the Installation By default, the installation will not make any changes to the disk(s) before 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. If there is a concern 30 that something is incorrectly configured, just turn the computer off before this point and no changes will be made to the system’s disks. This section describes how to boot the system from the installation media which was prepared using the instructions in Prepare the Installation Media. When using a bootable USB stick, plug in the USB stick before turning on the computer. When booting from CD or DVD, turn on the computer and insert the media at the first opportunity. How to configure the system to boot from the inserted media depends upon the architecture. 2.4.1. FreeBSD Boot Loader Menu Once the system boots from the installation media, a menu similar to the following will be displayed: Figure 1. FreeBSD Boot Loader Menu By default, the menu will wait ten seconds for user input before booting into the FreeBSD installer or, if FreeBSD is already installed, before booting into FreeBSD. To pause the boot timer in order to review the selections, press Space. To select an option, press its highlighted number, character, or key. The following options are available. Boot Multi User: This will continue the FreeBSD boot process. If the boot timer has been paused, press 1 , upper- or lower-case B , or Enter. Boot Single User: This mode can be used to fix an existing FreeBSD installation as described in 31 “Single-User Mode”. Press 2 or the upper- or lower-case S to enter this mode. Escape to loader prompt: This will boot the system into a repair prompt that contains a limited number of low-level commands. This prompt is described in “Stage Three”. Press 3 or Esc to boot into this prompt. Reboot: Reboots the system. Cons: Allow to continue the installation by video, serial, Dual (serial primary) or Dual (Video primary) Kernel: Loads a different kernel. Boot Options: Opens the menu shown in, and described under, FreeBSD Boot Options Menu. Figure 2. FreeBSD Boot Options Menu The boot options menu is divided into two sections. The first section can be used to either return to the main boot menu or to reset any toggled options back to their defaults. The next section is used to toggle the available options to On or Off by pressing the option’s highlighted number or character. The system will always boot using the settings for these options until they are modified. Several options can be toggled using this menu: ACPI Support: If the system hangs during boot, try toggling this option to Off. This option is only present when ACPI support is available but not required. Safe Mode: If the system still hangs during boot even with ACPI Support set to Off, try setting this 32 option to On. Single User: Toggle this option to On to fix an existing FreeBSD installation as described in “Single-User Mode”. Once the problem is fixed, set it back to Off. Verbose: Toggle this option to On to see more detailed messages during the boot process. This can be useful when troubleshooting a piece of hardware. After making the needed selections, press 1 or Backspace to return to the main boot menu, then press Enter to continue booting into FreeBSD. A series of boot messages will appear as FreeBSD carries out its hardware device probes and loads the installation program. Once the boot is complete, the welcome menu shown in Welcome Menu will be displayed. Figure 3. Welcome Menu Press Enter to select the default of [ Install ] to enter the installer. The rest of this chapter describes how to use this installer. Otherwise, use the right or left arrows or the colorized letter to select the desired menu item. The [ Shell ] can be used to access a FreeBSD shell in order to use command line utilities to prepare the disks before installation. The [ Live CD ] option can be used to try out FreeBSD before installing it. The live version is described in Using the Live CD. To review the boot messages, including the hardware device probe, press the upper- or lower-case S and then Enter to access a shell. At the shell prompt, type  more /var/run/dmesg.boot and use the space bar to scroll through the messages. When finished, type exit to return to the welcome menu. 33 2.5. Using bsdinstall This section shows the order of the bsdinstall menus and the type of information that will be asked before the system is installed. Use the arrow keys to highlight a menu option, then Space to select or deselect that menu item. When finished, press Enter to save the selection and move onto the next screen. 2.5.1. Selecting the Keymap Menu Before starting the process, bsdinstall will load the keymap files as shown in Keymap Loading. Figure 4. Keymap Loading After the keymaps have been loaded, bsdinstall displays the menu shown in Keymap Selection Menu. Use the up and down arrows to select the keymap that most closely represents the mapping of the keyboard attached to the system. Press Enter to save the selection. 34 Figure 5. Keymap Selection Menu Pressing Esc will exit this menu and use the default keymap. If the choice of  keymap is not clear, United States of America ISO-8859-1 is also a safe option. In addition, when selecting a different keymap, the user can try the keymap and ensure it is correct before proceeding, as shown in Keymap Testing Menu. 35 Figure 6. Keymap Testing Menu 2.5.2. Setting the Hostname The next bsdinstall menu is used to set the hostname for the newly installed system. 36 Figure 7. Setting the Hostname Type in a hostname that is unique for the network. It 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. 37 Figure 8. 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 known as the base system, are always installed. Depending on the architecture, some of these components may not appear: base-dbg - Base tools like cat and ls, among many others, with debug symbols activated. kernel-dbg - Kernel and modules with debug symbols activated. lib32-dbg - Compatibility libraries for running 32-bit applications on a 64-bit version of FreeBSD with debug symbols activated. lib32 - Compatibility libraries for running 32-bit applications on a 64-bit version of FreeBSD. ports - The FreeBSD Ports Collection is a collection of files which automates the downloading, compiling and installation of third-party software packages. Installing Applications: Packages and Ports discusses how to use the Ports Collection. The installation program does not check for adequate disk space. Select this  option only if sufficient hard disk space is available. The FreeBSD Ports Collection takes up about 3 GB of disk space. src - The complete FreeBSD source code for both the kernel and the userland. Although not required for the majority of applications, it may be required to build device drivers, kernel modules, or some applications from the Ports Collection. It is also used for developing FreeBSD 38 itself. The full source tree requires 1 GB of disk space and recompiling the entire FreeBSD system requires an additional 5 GB of space. tests - FreeBSD Test Suite. 2.5.4. Installing from the Network The menu shown in Installing from the Network only appears when installing from a -bootonly.iso or -mini-memstick.img, as this installation media does not hold copies of the installation files. Since the installation files must be retrieved over a network connection, this menu indicates that the network interface must be configured first. If this menu is shown in any step of the process, remember to follow the instructions in Configuring Network Interfaces. Figure 9. Installing from the Network 2.6. Allocating Disk Space The next menu is used to determine the method for allocating disk space. 39 Figure 10. Partitioning Choices bsdinstall gives the user four methods for allocating disk space: Auto (ZFS) partitioning creates a root-on-ZFS system with optional GELI encryption support for boot environments. Auto (UFS) partitioning automatically sets up the disk partitions using the UFS file system. Manual partitioning allows advanced users to create customized partitions from menu options. Shell opens a shell prompt where advanced users can create customized partitions using command-line utilities like gpart(8), fdisk(8), and bsdlabel(8). This section describes what to consider when laying out the disk partitions. It then demonstrates how to use the different partitioning methods. 2.6.1. Designing the Partition Layout The default partition layout for file systems includes one file system for the entire system. When using UFS it may be worth considering the use of multiple file systems if you have sufficient disk space or multiple disks. When laying out file systems, remember that hard drives transfer data faster from the outer tracks to the inner. Thus, smaller and heavier-accessed file systems should be closer to the outside of the drive, while larger partitions like /usr should be placed toward the inner parts of the disk. It is a good idea to create partitions in an order similar to: /, swap, /var, and /usr. The size of the /var partition reflects the intended machine’s usage. This partition is used to hold 40 mailboxes, log files, and printer spools. Mailboxes and log files can grow to unexpected sizes depending on the number of users and how long log files are kept. On average, most users rarely need more than about a gigabyte of free disk space in /var. Sometimes, a lot of disk space is required in /var/tmp. When new software is installed, the packaging tools extract a temporary copy of the packages under  /var/tmp. Large software packages, like Firefox or LibreOffice may be tricky to install if there is not enough disk space under /var/tmp. The /usr partition holds many of the files which support the system, including the FreeBSD Ports Collection and system source code. At least 2 gigabytes of space is recommended for this partition. Also, note that home directories for users are placed in /usr/home by default, but can be placed on another partition. By default, /home is a symbolic link to /usr/home. When selecting partition sizes, keep the space requirements in mind. Running out of space in one partition while barely using another can be a hassle. As a rule of thumb, the swap partition should be about double the size of physical memory (RAM). Systems with minimal RAM (less for larger-memory configurations) may perform better with more swap. Configuring too little swap can lead to inefficiencies in the VM page scanning code and might create issues later if more memory is added. On larger systems with multiple SCSI disks or multiple IDE disks operating on different controllers, it is recommended that swap be configured on each drive, up to four drives. The swap partitions should be approximately the same size. The kernel can handle arbitrary sizes, but internal data structures scale to 4 times the largest swap partition. Keeping the swap partitions near the same size will allow the kernel to optimally stripe swap space across disks. Large swap sizes may elicit a kernel warning message about the total configured swap. The limit is raised by increasing the amount of memory allowed for keeping track of swap allocations, as instructed by the warning message. It might be easier to recover from a runaway program before being forced to reboot. By properly partitioning a system, fragmentation introduced in the smaller write-heavy partitions will not bleed over into the mostly read partitions. Keeping the write-loaded partitions closer to the disk’s edge will increase I/O performance in the partitions where it occurs the most. While I/O performance in the larger partitions may be needed, shifting them more toward the edge of the disk will not lead to a significant performance improvement over moving /var to the edge. 2.6.2. Guided Partitioning Using UFS When this method is selected, a menu will display the available disk(s). If multiple disks are connected, choose the one where FreeBSD is to be installed. 41 Figure 11. Selecting from Multiple Disks Once the disk is selected, the next menu prompts to install to either the entire disk or to create a partition using free space. If [ Entire Disk ] is chosen, a general partition layout filling the whole disk is automatically created. Selecting [ Partition ] creates a partition layout from the unused space on the disk. 42 Figure 12. Selecting Entire Disk or Partition After the [ Entire Disk ] option is chosen, bsdinstall displays a dialog indicating that the disk will be erased. 43 Figure 13. Confirmation The next menu shows a list with the available partition scheme types. GPT is usually the most appropriate choice for amd64 computers. Older computers that are not compatible with GPT should use MBR. The other partition schemes are generally used for uncommon or older computers. More information is available in Partitioning Schemes. 44 Figure 14. Select Partition Scheme After the partition layout has been created, review it to ensure it meets the needs of the installation. Selecting [ Revert ] will reset the partitions to their original values. Pressing [ Auto ] will recreate the automatic FreeBSD partitions. Partitions can also be manually created, modified, or deleted. When the partitioning is correct, select [ Finish ] to continue with the installation. 45 Figure 15. Review Created Partitions Once the disks are configured, the next menu provides the last chance to make changes before the selected drives are formatted. If changes need to be made, select [ Back ] to return to the main partitioning menu. [ Revert & Exit ] exits the installer without making any changes to the drive. Otherwise, select [ Commit ] to start the installation process. 46 Figure 16. Final Confirmation To continue with the installation process, go to Fetching Distribution Files. 2.6.3. Manual Partitioning Selecting this method opens the partition editor: 47 Figure 17. Manually Create Partitions Highlight the installation drive (ada0 in this example) and select [ Create ] to display a menu of available partition schemes: 48 Figure 18. Manually Create Partitions GPT is usually the most appropriate choice for amd64 computers. Older computers that are not compatible with GPT should use MBR. The other partition schemes are generally used for uncommon or older computers. Table 1. Partitioning Schemes Abbreviation Description APM Apple Partition Map, used by PowerPC®. BSD BSD label without an MBR, sometimes called dangerously dedicated mode as non-BSD disk utilities may not recognize it. GPT GUID Partition Table. MBR Master Boot Record. After the partitioning scheme has been selected and created, select [ Create ] again to create the partitions. The Tab key is used to give focus to the fields (after cycling through [ ], [ ], and [ ]). 49 Figure 19. Manually Create P

Use Quizgecko on...
Browser
Browser