The NetBSD Guide

The NetBSD Developers

All brand and product names used in this guide are or may be trademarks or registered trademarks of their respective owners.

NetBSD® is a registered trademark of The NetBSD Foundation, Inc.

Published: 2008/02/19 18:52:52

$NetBSD: netbsd.html,v 1.32 2008/08/18 22:01:20 hubertf Exp $


Table of Contents

Purpose of this guide
I. About NetBSD
1. What is NetBSD?
1.1. The story of NetBSD
1.2. NetBSD features
1.3. Supported platforms
1.4. NetBSD's target users
1.5. Applications for NetBSD
1.6. The philosophy of NetBSD
1.7. How to get NetBSD
II. System installation and related issues
2. Installing NetBSD: Preliminary considerations and preparations
2.1. Preliminary considerations
2.1.1. Dual booting
2.1.2. NetBSD on emulation and virtualization
2.2. Install preparations
2.2.1. The INSTALL* document
2.2.2. Hard disk geometries
2.2.3. Partitions
2.2.4. Hard disk space requirements
2.2.5. Network settings
2.2.6. Backup your data and operating systems!
2.2.7. Preparing the installation media
2.3. Checklist
3. Example installation
3.1. Introduction
3.2. The installation process
3.3. Keyboard layout
3.4. Starting the installation
3.5. MBR partitions
3.6. Disklabel partitions
3.7. Setting the disk name
3.8. Last chance!
3.9. The disk preparation process
3.10. Choosing the installation media
3.10.1. Installing from CD-ROM or DVD
3.10.2. Installing from an unmounted file system
3.10.3. Installing via FTP
3.10.4. Installing via NFS
3.11. Extracting sets
3.12. System configuration
3.13. Finishing the installation
4. Upgrading NetBSD
4.1. Overview
4.2. The INSTALL* document
4.3. Performing the upgrade
III. System configuration, administration and tuning
5. The first steps on NetBSD
5.1. Troubleshooting
5.1.1. Boot problems
5.1.2. Misconfiguration of /etc/rc.conf
5.2. The man command
5.3. Editing the configuration files
5.4. Login
5.5. Changing the root password
5.6. Adding users
5.7. Shadow passwords
5.8. Changing the keyboard layout
5.9. System time
5.10. Secure Shell (ssh(1))
5.11. Basic configuration in /etc/rc.conf
5.12. Basic network settings
5.13. Mounting a CD-ROM
5.14. Mounting a floppy
5.15. Installing additional software
5.16. Security alerts
5.17. Stopping and rebooting the system
6. Editing
6.1. Introducing vi
6.1.1. The vi interface
6.1.2. Switching to Edit Mode
6.1.3. Switching Modes & Saving Buffers to Files
6.1.4. Yanking and Putting
6.1.5. Navigation in the Buffer
6.1.6. Searching a File, the Alternate Navigational Aid
6.1.7. A Sample Session
6.2. Configuring vi
6.2.1. Extensions to .exrc
6.2.2. Documentation
6.3. Using tags with vi
7. rc.d System
7.1. The rc.d Configuration
7.2. The rc.d Scripts
7.3. The Role of rcorder and rc Scripts
7.4. Additional Reading
8. Console drivers
8.1. wscons
8.1.1. wsdisplay
8.1.2. wskbd
8.1.3. wsmouse
8.2. pccons
9. X
9.1. What is X?
9.2. Configuration
9.3. The mouse
9.4. The keyboard
9.5. The monitor
9.6. The video card
9.6.1. XFree 3.x
9.6.2. XFree86 4.x
9.7. Starting X
9.8. Customizing X
9.9. Other window managers
9.10. Graphical login with xdm
10. Linux emulation
10.1. Emulation setup
10.1.1. Configuring the kernel
10.1.2. Installing the Linux libraries
10.1.3. Installing Acrobat Reader
10.2. Directory structure
10.3. Emulating /proc
10.4. Using Linux browser plugins
10.5. Further reading
11. Audio
11.1. Basic hardware elements
11.2. BIOS settings
11.3. Configuring the audio device
11.4. Configuring the kernel audio devices
11.5. Advanced commands
11.5.1. audioctl(1)
11.5.2. mixerctl(1)
11.5.3. audioplay(1)
11.5.4. audiorecord(1)
12. Printing
12.1. Enabling the printer daemon
12.2. Configuring /etc/printcap
12.3. Configuring Ghostscript
12.4. Printer management commands
12.5. Remote printing
13. Using removable media
13.1. Initializing and using floppy disks
13.2. How to use a ZIP disk
13.3. Reading data CDs with NetBSD
13.4. Reading multi-session CDs with NetBSD
13.5. Allowing normal users to access CDs
13.6. Mounting an ISO image
13.7. Using video CDs with NetBSD
13.8. Using audio CDs with NetBSD
13.9. Creating an MP3 (MPEG layer 3) file from an audio CD
13.10. Using a CD-R writer with data CDs
13.11. Using a CD-R writer to create audio CDs
13.12. Creating an audio CD from MP3s
13.13. Copying an audio CD
13.14. Copying a data CD with two drives
13.15. Using CD-RW rewritables
13.16. DVD support
13.17. Creating ISO images from a CD
13.18. Getting volume information from CDs and ISO images
14. The cryptographic device driver (CGD)
14.1. Overview
14.1.1. Why use disk encryption?
14.1.2. Logical Disk Drivers
14.1.3. Availability
14.2. Components of the Crypto-Graphic Disk system
14.2.1. Kernel driver pseudo-device
14.2.2. Ciphers
14.2.3. Verification Methods
14.3. Example: encrypting your disk
14.3.1. Preparing the disk
14.3.2. Scrubbing the disk
14.3.3. Creating the cgd
14.3.4. Modifying configuration files
14.3.5. Restoring data
14.4. Example: encrypted CDs/DVDs
14.4.1. Introduction
14.4.2. Creating an encrypted CD/DVD
14.4.3. Using an encrypted CD/DVD
14.5. Suggestions and Warnings
14.5.1. Using a random-key cgd for swap
14.5.2. Warnings
14.6. Further Reading
15. Concatenated Disk Device (CCD) configuration
15.1. Install physical media
15.2. Configure Kernel Support
15.3. Disklabel each volume member of the CCD
15.4. Configure the CCD
15.5. Initialize the CCD device
15.6. Create a 4.2BSD/UFS filesystem on the new CCD device
15.7. Mount the filesystem
16. NetBSD RAIDframe
16.1. RAIDframe Introduction
16.1.1. About RAIDframe
16.1.2. A warning about Data Integrity, Backups, and High Availability
16.1.3. Getting Help
16.2. Setup RAIDframe Support
16.2.1. Kernel Support
16.2.2. Power Redundancy and Disk Caching
16.3. Example: RAID-1 Root Disk
16.3.1. Pseudo-Process Outline
16.3.2. Hardware Review
16.3.3. Initial Install on Disk0/wd0
16.3.4. Preparing Disk1/wd1
16.3.5. Initializing the RAID Device
16.3.6. Setting up Filesystems
16.3.7. Setting up kernel dumps
16.3.8. Migrating System to RAID
16.3.9. The first boot with RAID
16.3.10. Adding Disk0/wd0 to RAID
16.3.11. Testing Boot Blocks
16.4. Testing kernel dumps
17. Pluggable Authentication Modules (PAM)
17.1. About
17.2. Introduction
17.3. Terms and conventions
17.3.1. Definitions
17.3.2. Usage examples
17.4. PAM Essentials
17.4.1. Facilities and primitives
17.4.2. Modules
17.4.3. Chains and policies
17.4.4. Transactions
17.5. PAM Configuration
17.5.1. PAM policy files
17.5.2. Breakdown of a configuration line
17.5.3. Policies
17.6. PAM modules
17.6.1. Common Modules
17.6.2. FreeBSD-specific PAM Modules
17.6.3. NetBSD-specific PAM Modules
17.7. PAM Application Programming
17.8. PAM Module Programming
17.9. Sample PAM Application
17.10. Sample PAM Module
17.11. Sample PAM Conversation Function
17.12. Further Reading
18. Tuning NetBSD
18.1. Introduction
18.1.1. Overview
18.2. Tuning Considerations
18.2.1. General System Configuration
18.2.2. System Services
18.2.3. The NetBSD Kernel
18.3. Visual Monitoring Tools
18.3.1. The top Process Monitor
18.3.2. The sysstat utility
18.4. Monitoring Tools
18.4.1. fstat
18.4.2. iostat
18.4.3. ps
18.4.4. vmstat
18.5. Network Tools
18.5.1. ping
18.5.2. traceroute
18.5.3. netstat
18.5.4. tcpdump
18.6. Accounting
18.6.1. Accounting
18.6.2. Reading Accounting Information
18.6.3. How to Put Accounting to Use
18.7. Kernel Profiling
18.7.1. Getting Started
18.7.2. Interpretation of kgmon Output
18.7.3. Putting it to Use
18.7.4. Summary
18.8. System Tuning
18.8.1. Using sysctl
18.8.2. memfs & softdeps
18.8.3. LFS
18.9. Kernel Tuning
18.9.1. Preparing to Recompile a Kernel
18.9.2. Configuring the Kernel
18.9.3. Building the New Kernel
18.9.4. Shrinking the NetBSD kernel
19. NetBSD Veriexec subsystem
19.1. How it works
19.2. Signatures file
19.3. Generating fingerprints
19.4. Strict levels
19.5. Veriexec and layered file systems
19.6. Kernel configuration
20. Bluetooth on NetBSD
20.1. Introduction
20.2. Supported Hardware
20.3. System Configuration
20.4. Human Interface Devices
20.4.1. Mice
20.4.2. Keyboards
20.5. Personal Area Networking
20.5.1. Personal Area Networking User
20.6. Serial Connections
20.7. Audio
20.7.1. SCO Audio Headsets
20.7.2. SCO Audio Handsfree
20.8. Object Exchange
20.9. Troubleshooting
21. Miscellaneous operations
21.1. Installing the boot manager
21.2. Deleting the disklabel
21.3. Speaker
21.4. Forgot root password?
21.5. Adding a new hard disk
21.6. Password file is busy?
21.7. How to rebuild the devices in /dev
IV. Networking and related issues
22. Introduction to TCP/IP Networking
22.1. Audience
22.2. Supported Networking Protocols
22.3. Supported Media
22.3.1. Serial Line
22.3.2. Ethernet
22.4. TCP/IP Address Format
22.5. Subnetting and Routing
22.6. Name Service Concepts
22.6.1. /etc/hosts
22.6.2. Domain Name Service (DNS)
22.6.3. Network Information Service (NIS/YP)
22.6.4. Other
22.7. Next generation Internet protocol - IPv6
22.7.1. The Future of the Internet
22.7.2. What good is IPv6?
22.7.3. Changes to IPv4
23. Setting up TCP/IP on NetBSD in practice
23.1. A walk through the kernel configuration
23.2. Overview of the network configuration files
23.3. Connecting to the Internet with a modem
23.3.1. Getting the connection information
23.3.2. resolv.conf and nsswitch.conf
23.3.3. Creating the directories for pppd
23.3.4. Connection script and chat file
23.3.5. Authentication
23.3.6. pppd options
23.3.7. Testing the modem
23.3.8. Activating the link
23.3.9. Using a script for connection and disconnection
23.3.10. Running commands after dialin
23.4. Creating a small home network
23.5. Setting up an Internet gateway with IPNAT
23.5.1. Configuring the gateway/firewall
23.5.2. Configuring the clients
23.5.3. Some useful commands
23.6. Setting up a network bridge device
23.6.1. Bridge example
23.7. A common LAN setup
23.8. Connecting two PCs through a serial line
23.8.1. Connecting NetBSD with BSD or Linux
23.8.2. Connecting NetBSD and Windows NT
23.8.3. Connecting NetBSD and Windows 95
23.9. IPv6 Connectivity & Transition via 6to4
23.9.1. Getting 6to4 IPv6 up & running
23.9.2. Obtaining IPv6 Address Space for 6to4
23.9.3. How to get connected
23.9.4. Security Considerations
23.9.5. Data Needed for 6to4 Setup
23.9.6. Kernel Preparation
23.9.7. 6to4 Setup
23.9.8. Quickstart using pkgsrc/net/hf6to4
23.9.9. Known 6to4 Relay Routers
23.9.10. Tunneling 6to4 through an IPFilter firewall
23.9.11. Conclusion & Further Reading
24. The Internet Super Server inetd
24.1. Overview
24.2. What is inetd?
24.3. Configuring inetd - /etc/inetd.conf
24.4. Services - /etc/services
24.5. Protocols - /etc/protocols
24.6. Remote Procedure Calls (RPC) - /etc/rpc
24.7. Allowing and denying hosts - /etc/hosts.{allow,deny}
24.8. Adding a Service
24.9. When to use or not to use inetd
24.10. Other Resources
25. The Domain Name System
25.1. DNS Background and Concepts
25.1.1. Naming Services
25.1.2. The DNS namespace
25.1.3. Resource Records
25.1.4. Delegation
25.1.5. Delegation to multiple servers
25.1.6. Secondaries, Caching, and the SOA record
25.1.7. Name Resolution
25.1.8. Reverse Resolution
25.2. The DNS Files
25.2.1. /etc/namedb/named.conf
25.2.2. /etc/namedb/localhost
25.2.3. /etc/namedb/zone.127.0.0
25.2.4. /etc/namedb/diverge.org
25.2.5. /etc/namedb/1.168.192
25.2.6. /etc/namedb/root.cache
25.3. Using DNS
25.4. Setting up a caching only name server
25.4.1. Testing the server
26. Mail and news
26.1. postfix
26.1.1. Configuration of generic mapping
26.1.2. Testing the configuration
26.1.3. Using an alternative MTA
26.2. fetchmail
26.3. Reading and writing mail with mutt
26.4. Strategy for receiving mail
26.5. Strategy for sending mail
26.6. Advanced mail tools
26.7. News with tin
27. Introduction to the Common Address Redundancy Protocol (CARP)
27.1. CARP Operation
27.2. Configuring CARP
27.3. Enabling CARP Support
27.4. CARP Example
27.5. Advanced CARP configuration
27.6. Forcing Failover of the Master
28. Network services
28.1. The Network File System (NFS)
28.1.1. NFS setup example
28.1.2. Setting up NFS automounting for /net with amd(8)
28.2. The Network Time Protocol (NTP)
V. Building the system
29. Obtaining the sources
29.1. Preparing directories
29.2. Terminology
29.3. Downloading tarballs
29.3.1. Downloading sources for a NetBSD release
29.3.2. Downloading sources for a NetBSD stable branch
29.3.3. Downloading sources for a NetBSD-current development branch
29.4. Fetching by CVS
29.4.1. Fetching a NetBSD release
29.4.2. Fetching a NetBSD stable branch
29.4.3. Fetching the NetBSD-current development branch
29.4.4. Saving some cvs(1) options
29.5. Sources on CD (ISO)
30. Crosscompiling NetBSD with build.sh
30.1. Building the crosscompiler
30.2. Configuring the kernel manually
30.3. Crosscompiling the kernel manually
30.4. Crosscompiling the kernel with build.sh
30.5. Crosscompiling the userland
30.6. Crosscompiling the X Window System
30.7. Changing build behaviour
30.7.1. Changing the Destination Directory
30.7.2. Static Builds
30.7.3. Using build.sh options
30.7.4. make(1) variables used during build
31. Compiling the kernel
31.1. Requirements and procedure
31.2. Installing the kernel sources
31.3. Creating the kernel configuration file
31.4. Building the kernel manually
31.4.1. Configuring the kernel manually
31.4.2. Generating dependencies and recompiling manually
31.5. Building the kernel using build.sh
31.6. Installing the new kernel
31.7. If something went wrong
32. Updating an existing system from sources
32.1. The updating procedure
32.1.1. Building a new userland
32.1.2. Building a new kernel
32.1.3. Installing the kernel and userland
32.1.4. Updating the system configuration files
32.1.5. Summary
32.1.6. Alternative: using sysinst
32.2. More details about the updating of configuration and startup files
32.2.1. Using etcupdate with source files
32.2.2. Using etcupdate with binary distribution sets
32.2.3. Using etcmanage instead of etcupdate
33. Building NetBSD installation media
33.1. Creating custom install or boot floppies for your architecture e.g. i386
33.2. Creating a custom install or boot CD with build.sh
A. Information
A.1. Where to get this document
A.2. Guide history
B. Contributing to the NetBSD guide
B.1. Translating the guide
B.1.1. What you need to start a translation
B.1.2. Writing XML/DocBook
B.2. Sending contributions
B.3. XML/DocBook template
C. Getting started with XML/DocBook
C.1. What is XML/DocBook
C.2. Installing the necessary tools
C.3. Using the tools
C.4. Language-specific notes
C.4.1. Enabling hyphenation for the Italian language
C.5. Links
D. Acknowledgements
D.1. Original acknowledgements
D.2. Current acknowledgements
D.3. Licenses
D.3.1. Federico Lupi's original license of this guide
D.3.2. Networks Associates Technology's license on the PAM article
D.3.3. Joel Knight's license on the CARP article
E. Bibliography
Bibliography

List of Figures

2.1. Partitions
3.1. Selecting the language
3.2. Selecting a keyboard type
3.3. The sysinst main menu
3.4. Confirming to install NetBSD
3.5. Choosing a hard disk
3.6. Full or custom installation
3.7. Selecting distribution sets
3.8. Choosing the partitioning scheme
3.9. fdisk
3.10. Partition options
3.11. Installing the boot selector
3.12. Editing partitions?
3.13. Setting partition sizes
3.14. The disklabel editor
3.15. Disklabel partition editing
3.16. Naming the NetBSD disk
3.17. Last chance to abort
3.18. Selecting a bootblock
3.19. Choosing the verbosity of the extraction process
3.20. Installation media
3.21. CD-ROM/DVD installation
3.22. Mounting a file system
3.23. Mounting a partition
3.24. Accessing a MSDOS file system
3.25. Which network interface to configure
3.26. Using DHCP for network configuration
3.27. Entering and configuring network data
3.28. Confirming network parameters
3.29. Defining the FTP settings
3.30. Saving the network settings
3.31. NFS install screen
3.32. NFS example
3.33. Extraction of sets completed
3.34. Selecting the system's time zone
3.35. Selecting a password encryption scheme
3.36. Setting root password?
3.37. Setting root password
3.38. Choosing a shell
3.39. Installation completed
3.40. Reboot to finish installation
4.1. Starting the upgrade
4.2. Continuing the upgrade
4.3. Choosing the hard drive
4.4. Choosing the distribution filesets
4.5. Upgrade process - verbosity level
4.6. File system check
4.7. Choosing bootblocks
4.8. Install medium
4.9. Upgrade completed
16.1. RAID-1 Disk Logical Layout
16.2. Perform generic install onto Disk0/wd0
16.3. Setup RAID Set
16.4. Reboot using Disk1/wd1 of RAID
16.5. Mirror Disk1/wd1 back to Disk0/wd0
16.6. Award BIOS i386 Boot Disk1/wd1
16.7. Award BIOS i386 Boot Disk0/wd0
22.1. IPv4-addresses are divided into more significant network- and less significant hostbits
22.2. Our demo-network
22.3. Attaching one subnet to another one
22.4. IPv6-addresses are divided into more significant network- and less significant hostbits, too
22.5. IPv6-addresses have a similar structure to class B addresses
22.6. Several interfaces attached to a link result in only one scope ID for the link
23.1. Network with gateway
23.2. A frequently used method for transition is tunneling IPv6 in IPv4 packets
23.3. 6to4 derives an IPv6 from an IPv4 address
23.4. Request and reply can be routed via different gateways in 6to4
23.5. Enabling packet forwarding is needed for a 6to4 router
26.1. Structure of the mail system

List of Tables

17.1. PAM chain execution summary
19.1. Veriexec fingerprints tools
19.2. Veriexec access type aliases

List of Examples

12.1. /etc/printcap
12.2. /usr/local/libexec/lpfilter
12.3. /etc/printcap
12.4. /usr/local/libexec/lpfilter-ps
23.1. resolv.conf
23.2. nsswitch.conf
23.3. Connection script
23.4. Chat file
23.5. Chat file with login
23.6. /etc/ppp/options
23.7. ppp-start
23.8. ppp-stop
23.9. /etc/hosts
25.1. strider's /etc/hosts file
25.2. localhost
29.1. .cvsrc

Purpose of this guide

This guide describes the installation and the configuration of the NetBSD operating system as well as setup and administration of some of its subsystems. It addresses mainly people coming from other operating systems in hope of being useful for the solution of the many small problems found when one starts using a new tool.

This guide is not a Unix tutorial: a basic knowledge of some concepts and tools is required to understand it. You should know, for example, what a file and a directory are and how to use an editor. There are plenty of books explaining these things so, if you don't know them, I suggest that you buy an introductory text. I think that it is better to choose a general book and avoid titles like “Learning Unix-XYZ, version 1.2.3.4 in 10 days”, but this is a matter of personal taste. If you install a BSD system, sooner or later you will be confronted with the vi editor: without some documentation this could be an insurmountable obstacle. When you finish installing your system, you will be able to install whatever editor and programs you like.

Still a lot of work is required to finish this introduction to NetBSD: some chapters are not finished (some are not even started) and some subjects still need testing (yes, a guide must also be tested). I'll try to work on it and improve it in my spare time but if you want to help, you're welcome: you can write new chapters (or parts of) or send corrections for existing subjects.

This guide is currently maintained by the NetBSD www team (). Corrections and suggestions should be sent to that address. See also Appendix B, Contributing to the NetBSD guide.

Part I. About NetBSD

Chapter 1. What is NetBSD?

NetBSD is a free, secure, highly portable Unix-like operating system available for many platforms, from 64bit Opteron servers and desktop systems to handheld and embedded devices. Its clean design and advanced features make it excellent in both production and research environments and it is user-supported with complete source. Many applications are easily available through the NetBSD Packages Collection.

1.1. The story of NetBSD

The first version of NetBSD (0.8) dates back to 1993 and springs from the 4.3BSD Lite operating system, a version of Unix developed at the University of California, Berkeley (BSD = Berkeley Software Distribution), and from the 386BSD system, the first BSD port to the Intel 386 CPU. In the following years, the modifications from the 4.4BSD Lite release (the last release of the Berkeley group) have been integrated in the system. The BSD branch of Unix has had a great importance and influence in the history of this operating system, to which it has contributed many tools, ideas and improvements which are now standard in all Unix environments: the vi editor, the C shell, job control, the Berkeley fast file system, reliable signals, support for virtual memory and TCP/IP, just to name a few. This tradition of research and development survives today in the BSD systems (free and commercial) and, in particular, in NetBSD.

1.2. NetBSD features

NetBSD operates on a vast range of hardware platforms and is very portable, probably the most portable operating system in the world. The full source to the NetBSD kernel and userland is available for all the supported platforms; please see the details on the official site of the NetBSD Project.

A detailed list of NetBSD features can be found at: http://www.NetBSD.org/about/features.html.

The basic features of NetBSD are:

  • Portability (more than 50 platforms are supported)

  • Security can be taken for granted

  • Code quality and correctness

  • Adherence to industry standards

  • Research and innovation

These characteristics bring also indirect advantages. For example, if you work on just one platform you could think that you're not interested in portability. But portability is tied to code quality; without a well written and well organized code base it would be impossible to support that many platforms. And code quality is the base of any good and solid software systems, though surprisingly few people seem to understand it. The attention to architectural and quality issues is rewarded with the great potentiality of NetBSD's code and the quality of its drivers.

One of the key characteristics of NetBSD is not to be satisfied with partial implementations. Some systems seem to have the philosophy of “If it works, it's right”. In that light NetBSD could be described as “It doesn't work unless it's right”. Think about how many overgrown programs are nowadays sadly collapsing under their own weight and “features” and you'll understand why NetBSD wants to avoid this situation at all costs.

1.3. Supported platforms

NetBSD supports over 50 platforms, including the popular PC platform (i386), Opteron system, SPARC and UltraSPARC, Alpha, Amiga, Atari, m68k and PowerPC based Apple Macintosh platforms. Technical details for all of them can be found on the NetBSD site.

1.4. NetBSD's target users

The NetBSD site states that: “The NetBSD Project provides a freely available and redistributable system that professionals, hobbyists, and researchers can use in whatever manner they wish”. I would add that NetBSD is also an ideal system if you want to learn Unix, mainly because of its adherence to standards (one of the project goals) and because it works equally well on the latest PC hardware as well as on hardware which is considered obsolete by most other operating systems; we could say “to learn and use Unix you don't need to buy expensive hardware; you can reuse the old PC or Mac that you have in your attic”, still NetBSD will of course rock even more on modern hardware! Also, if you need a Unix system which runs consistently on a variety of platforms, NetBSD is probably your best (only) choice.

1.5. Applications for NetBSD

When you install NetBSD you have a rich set of programs and applications that you can install on your system. Besides having all the standard Unix productivity tools, editors, formatters, C/C++ compilers and debuggers and so on, there is a huge (and constantly growing, currently over 5,000) number of packages that can be installed both from source and in pre-compiled form. All the packages that you expect to find on a well configured system are available for NetBSD for free and there is also a number of commercial applications. In addition, NetBSD provides binary emulation for various other *nix operating systems, thusly allowing you to run non-native applications. Linux emulation is probably the most relevant example, lots of efforts have gone into it and it is used by almost all NetBSD users; you can run the Linux version of

  • Netscape

  • Acrobat Reader

  • Doom, Quake

  • Adobe FrameMaker

  • many other programs

NetBSD is also capable of emulating FreeBSD, BSDI, Solaris and other systems' binaries.

1.6. The philosophy of NetBSD

Differently from many contemporary operating systems, the NetBSD installation is rich in features, but not huge in size, because it strives to produce a stable and complete base system without being redundant. After the installation you get a fully working base system which can be tuned for various applications then, for example GNOME or KDE and a web browser and other productivity tools for a desktop machine, Apache for a webserver, PostgreSQL or MySQL for a database server, etc. - you have the freedom to decide which programs to install on your machine and the installation of new programs is very easy with the pkgsrc system.

Another advantage of this approach is that the base system will work without these applications; if you decide to upgrade your version of Perl you needn't be afraid to break some parts of your system. When you install NetBSD you don't find huge pre-packaged collections of applications; you may now see this as a disadvantage but when you start understanding the philosophy behind this you will find that it gives you freedom. When you install these software collections (which someone else has decided for you) you fill your hard disk with tons of programs, most of which will stay unused (and unknown) and only waste space (and possibly make the system less stable); this is something which the typical BSD user doesn't want to do.

Even when you start knowing NetBSD, there is always something that will continue to amaze you, the extreme consistency and logic of the system and the attention to the details; nothing appears the result of chance and everything is well thought out. Yes, that's what quality is about and, in my opinion, this is the most distinguishing feature of NetBSD.

We could spend days arguing on the relative merits of operating systems (and some people like to do it) but if you don't try something seriously you can't really judge. I am convinced, because I saw it many times in the mailing lists, that if you try NetBSD you'll be conquered by the perfect balance between complexity and effectiveness; all problems have more than one solution; NetBSD is not happy with a solution but always tries to find the easiest and most elegant one. NetBSD is a tool that enables you to do your work without getting in your way. In this light it is an optimal tool; it's like using a pen; you work hard to learn how to use it but once you've learned you can write or draw and completely forget about the pen.

1.7. How to get NetBSD

NetBSD is an Open Source operating system, and as such it's freely available for download from ftp.NetBSD.org and its mirrors.

There is no “official” supplier of NetBSD CD-ROMs but there are various resellers. You can find the most up to date list on the relevant page on the NetBSD site.

Part II. System installation and related issues

Chapter 2. Installing NetBSD: Preliminary considerations and preparations

2.1. Preliminary considerations

2.1.1. Dual booting

It is possible to install NetBSD together with other operating systems on one hard disk.

If there is already something on the hard disk, think how you can free some space for NetBSD; if NetBSD will share the disk with other operating systems you will probably need to create a new partition (which you will do with sysinst) and, maybe, to resize an existing one.

It is not possible to resize an existing partition with sysinst, but there are some commercial products (like Partition Magic) and some free tools (FIPS, pfdisk) available for this.

You can also install NetBSD on a separate hard disk.

Advise

We recommend to install NetBSD on its own, separate hard disk! This will avoid the risk to damage the existing operating system. Setting up a dual- or multi-boot system is a task for experienced users.

2.1.2. NetBSD on emulation and virtualization

With modern and powerful hardware it is possible to install and run NetBSD on top of other operating systems - without the cumbersomeness of dual booting. Emulators or virtualization environments provide a fast and secure way to try out NetBSD. The host operating system stays unchanged, and the risk to damage important data is limited.

This requires the correct setup of an emulation software or virtualization technology on the hosting operating system. That given, it is just at matter of creating a file-based image and using an install CD image to start with NetBSD.

Information about NetBSD as a Xen host and guest system is available on the NetBSD/xen web page

The NetBSD on emulated hardware web page provides detailed information about various emulators and the supported NetBSD platforms

2.2. Install preparations

2.2.1. The INSTALL* document

The first thing to do before installing NetBSD is to read the release information and installation notes in one of the INSTALL.* files: this is the official description of the installation procedure, with platform specific information and important details. It can be found in the root directory of the NetBSD release (on the install CD or on the FTP server):

  • ftp://ftp.NetBSD.org/pub/NetBSD/NetBSD-4.x/platform/INSTALL.html

It is advisable to print the INSTALL.* document out. It is available in various formats, usually .txt, .ps, .more and .html

2.2.2. Hard disk geometries

Note

You can do the install even if you don't know the hard disk geometry. In this case you have to trust sysinst, which automatically determines the geometry and (usually) gets it right.

It is sensible to be aware of geometry issues that may arise in relation to the used hard disk. First of all, you should know about sector size. You can count on this to be 512 bytes; other sizes are rare (and currently not supported). Of particular interest are the number of sectors per track, the number of tracks per cylinder (also known as the number of heads), and the number of cylinders. Together they describe the disk geometry.

The BIOS has a limit of 1024 cylinders and 63 sectors per track for doing BIOS I/O. This is because of the old programming interface to the BIOS that restricts these values. Most of the big disks currently being used have more than 1024 real cylinders. Some have more than 63 sectors per track. Therefore, the BIOS can be instructed to use a fake geometry that accesses most of the disk and the fake geometry has less than or equal to 1024 cylinders and less than or equal to 63 sectors. This is possible because the disks can be addressed in a way that is not restricted to these values, and the BIOS can internally perform a translation. This can be activated in most modern BIOSes by using Large or LBA mode for the disk.

NetBSD does not have the mentioned limitations with regard to the geometry. However, since the BIOS has to be used during startup, it is important to know about the geometry the BIOS uses. The NetBSD kernel should be on a part of the disk where it can be loaded using the BIOS, within the limitations of the BIOS geometry. The install program will check this for you, and will give you a chance to correct this if this is not the case.

If you have not yet installed any other systems on the hard disk that you plan to install NetBSD on, or if you plan to use the disk entirely for NetBSD, you may wish to check your BIOS settings for the `Large' or `LBA' modes, and activate them for the hard disk in question. While they are not needed by NetBSD as such, doing so will remove the limitations mentioned above, and will avoid hassle should you wish to share the disk with other systems. Do not change these settings if you already have data on the disk that you want to preserve!

In any case, it is wise to check the BIOS settings for the hard disk geometry before beginning the installation, and write them down. While this should usually not be needed, it enables you to verify that the install program determines these values correctly.

The geometry that the BIOS uses will be referred to as the BIOS geometry, the geometry that NetBSD uses is the real geometry.

sysinst, the NetBSD installation program, will try to discover both the real geometry and BIOS geometry.

It is important that sysinst know the proper BIOS geometry to be able to get NetBSD to boot, regardless of where on your disk you put it. It is less of a concern if the disk is going to be used entirely for NetBSD. If you intend to have several OSes on your disk, this becomes a much larger issue.

The installation program mentions two types of hard disk geometries:

  • real geometry

  • BIOS geometry

real geometry is the real geometry of the hard disk, detected by the system. BIOS geometry is the geometry used by the BIOS and it could be different from the real one (for example, BIOS could remap the disk using LBA).

The disk used in the installation example is an IDE disk with the following geometries:

real:  6232 cyl,   16 heads,  63 sec
BIOS:   779 cyl,  128 heads,  63 sec   (LBA)

As you can see the BIOS remaps the disk using LBA, effectively reducing the number of cylinders and increasing the number of tracks (but the result is the same: 6232 * 16 = 779 * 128 = 99712). A sector contains 512 bytes, which means that the disk size is 6232 * 16 * 63 * 512 = 3 GB. NetBSD does not need to remap the disk geometry (and in fact won't do it). During the installation it is possible to change manually the geometry if sysinst got it wrong.

2.2.3. Partitions

The terminology used by NetBSD for partitioning is different from the typical DOS/Windows terminology; in fact, there are two partitioning schemes. NetBSD installs in one of the four primary BIOS partitions (the partitions defined in the hard disk partition table).

Within a BIOS partition (also called slice) NetBSD defines its BSD partitions using a disklabel: these partitions can be seen only by NetBSD and are identified by lowercase letters (starting with “a”). For example, wd0a refers to the “a” partition of the first IDE disk (wd0) and sd0a refers to the “a” partition of the first SCSI disk. In Figure 2.1, “Partitions” there are two primary BIOS partitions, one used by DOS and the other by NetBSD. NetBSD describes the disk layout through the disklabel.

Figure 2.1. Partitions

Partitions

Note

The meaning of partitions “c” and “d” is typical of the i386 port. Other ports use different conventions (e.g. “c” represents the whole disk.)

Note

If NetBSD shares the hard disk with another operating system (like in the previous example) you will probably need to install a boot manager, i.e. a program which enables you to choose the OS to start at boot time. sysinst can do this for you and install and configure a simple but effective boot manager.

2.2.4. Hard disk space requirements

A fresh installed NetBSD system will take about 360 MB of disk space. Additional disk space will be needed for a swap partition, applications and for the users data.

2.2.5. Network settings

Write down the basic network settings. Especially if you plan to install over network via FTP or NFS you will need:

  • a free IP address for the network interface (for example: 192.168.1.11)

  • the Netmask (for example: 255.255.255.0)

  • the IP address of your default gateway (for example: 192.168.1.1)

  • and the IP address of the DNS server you use (for example: 145.253.2.75)

2.2.6. Backup your data and operating systems!

Before you begin the installation, make sure that you have a reliable backup of any operating systems and data on the used hard disk. Mistakes in partitioning your hard disk may lead to data loss. Already installed operating systems may become unbootable. "Reliable backup" means that the backup and restore procedure is tested to work faultless!

2.2.7. Preparing the installation media

The NetBSD installsystem consists of two parts. The first part is the installation kernel. This kernel contains the NetBSD install program sysinst and it needs to get booted from a CD (or DVD), Memory card, USB flash drive or from a floppy disk. The sysinst program will prepare the disk: it separates the disk space into partitions, makes the disk bootable and creates the necessary file systems.

The second part of the install system are the binary distribution sets, the files of the NetBSD operating system. The installer needs to have access to the distribution sets. sysinst can reach them via network (NFS server), internet (FTP server), on CDs/DVDs or on disks (with file systems that are supported by the installation kernel).

On big disks like CDs or memory cards, the install kernel and distribution sets can be stored together. The NetBSD Project provides those complete install media for every supported hardware architecture. They are available as bootable CD images (*.iso and *.iso.torrent files):

  • ftp://ftp.NetBSD.org/pub/NetBSD/iso/3.x

  • ftp://ftp.NetBSD.org/pub/NetBSD/iso/4.x

Note

Please see the mirrors list and choose a local server near you for downloads

2.2.7.1. Booting the install system from CD

To use a bootable NetBSD install CD download the *.iso file for your hardware architecture. Use the CD or DVD burning software on your actual operating system to create a bootable CD. Enable “Boot from CD-ROM” (or similar) in your BIOS settings, insert the CD and reboot the computer.

Refer to to the NetBSD Bootable CD ROM HOWTO, for all the details about the creation of installation CDs

2.2.7.2. Booting the install system from floppy

If you need to create installation floppies, you need to copy floppy images to a diskette. The floppy images are available on the NetBSD FTP servers or on a NetBSD install CD. To perform this operation in DOS you can use the rawrite program in the i386/installation/misc directory, for Windows there's a version in rawr32.zip. The image files are i386/installation/floppy/boot1.fs and i386/installation/floppy/boot2.fs for installation of a “normal” PC, and i386/installation/floppy/bootlap1.fs and i386/installation/floppy/bootlap2.fs for a laptop. A number of other floppies are available that are described in more detail in the INSTALL.* document.

Note

Before you create the installation disks on floppies, you should always check that the floppies are good: this simple step is often overlooked but it can save you a lot of trouble!

The procedure to write floppies is:

  1. Format the floppy.

  2. Go to the I386\INSTALLATION\FLOPPY directory of the CD-ROM.

  3. Run the ..\MISC\RAWRITE program (or extract ..\MISC\RAWR32.ZIP if you're on a Windows system, and run the RAWRITE32 program in that file). The “Source file”s are BOOT1.FS and BOOT2.FS (etc., see above) and the “Destination drive” is A:

To create the boot floppy in an Unix environment, the dd command can be used: For example:

# cd i386/installation/floppy
      # dd if=boot.fs of=/dev/fd0a bs=36b

dd copies blocks of 512 bytes: the bs=36b option copies 36 blocks at a time, effectively making the operation faster.

Note

A 1440K floppy contains 1474560 bytes and is made up of 80 cylinders, 2 tracks, 18 sectors and 512 bytes per sector, i.e. 80 * 2 * 18 = 2880 blocks. Thus bs=36b copies one cylinder (18 * 2 blocks) at a time and repeats the operation 80 times instead of 2880.

2.2.7.3. Booting the NetBSD install system via boot loader

An alternative to the creation of install CDs or floppies is the use of a boot loader, which is capable to boot NetBSD kernels. One example is the GNU GRUB boot loader. Any bootable disk with GRUB already installed will work: a hard disk with a Linux system, an USB flash drive, etc.

Apart from a disk with GRUB boot loader, some space is needed to store the NetBSD install kernel. The install kernel can be downloaded from one of the FTP mirrors:

  • ftp://ftp.NetBSD.org/pub/NetBSD/NetBSD-3.x/port/binary/kernel/netbsd-INSTALL.gz

  • ftp://ftp.NetBSD.org/pub/NetBSD/NetBSD-4.x/port/binary/kernel/netbsd-INSTALL.gz

The kernel file (netbsd-INSTALL.gz) needs to be un-zipped and saved into a directory. The distribution sets can also be stored into the directory, but this is optional as the sets can also be downloaded later via the sysinst installer. The (optional!) distribution sets are available in the sets directory:

  • ftp.NetBSD.org/pub/NetBSD/NetBSD-3.x/port/binary/sets/...

  • ftp.NetBSD.org/pub/NetBSD/NetBSD-4.x/port/binary/sets/...

In the following example, the install kernel is in the /data directory on the first partition of the second disk. The file system type on the drive is MSDOS FAT.The next step is to boot GRUB. When the boot menu appears, the “e” key needs to be pressed to get to the GRUB command line:

grub>
grub> find /data/netbsd-INSTALL
    (hd1,0)

The find command above is used to locate the install kernel: It is on the first partition (“0”) of the second disk (“hd1”). GRUB gets now instructed to boot the NetBSD kernel on disk “hd1,0”:

grub> root (hd1,0)
      Filesystem type is fat, partition type 0xb

grub> kernel --type=netbsd /data/netbsd-INSTALL

grub> boot
...

This will boot the NetBSD installation system.

2.3. Checklist

This is the checklist about the things that should be clear and on-hand now:

  • Geometry of the hard disk

  • Available disk space

  • Bootable medium with the install system

  • Disk or server with the distribution sets

  • A free IP address and the netmask

  • IP address of the default gateway

  • IP address of the DNS server

  • A working backup

  • Printout of the INSTALL.* document

Chapter 3. Example installation

3.1. Introduction

This chapter will guide through the installation procedure with sysinst, the NetBSD installation program. It describes the installation from CD-ROM, from an unmounted file system, and over the network via FTP or NFS. The concepts are the same for all types of installation; the only difference is in the way the binary sets are found by sysinst. Some details of the installation differ depending on the NetBSD release: The examples from this chapter were created with NetBSD 4.0.

Note

The data from the following install screens are just exemplary values. Do not simply copy them, as your hardware and configuration details may be different!

3.2. The installation process

The installation process is divided logically in two steps. In the first part you create a partition for NetBSD and you write the disklabel for that partition. In the second part you decide which distribution sets you want to install and extract the files in the newly created partitions. The distribution sets are the operating system.

At the end of the first part nothing has yet been written to the hard disk and you are prompted to confirm the installation. If you confirm, the installation goes on, else you are brought back to the main menu and the hard disk remains unchanged.

3.3. Keyboard layout

The NetBSD install program sysinst allows you to change the keyboard layout during the installation. If for some reason this does not work for you, you can use the map in the following table.

US IT DE FR
- ' ß )
/ - - !
= ì ' -
: ç Ö M
; ò ö m
# £ § 3
" ° Ä %
* ( ( 8
( ) ) 9
) = = 0
' à ä ù
` \ ^ @
\ ù # `

3.4. Starting the installation

To start the installation of NetBSD insert the newly created installation floppy and reboot the computer, or boot from a prepared CD, memory card, USB flash drive, (etc.). The kernel on the installation medium is booted and starts displaying a lot of messages on the screen, most of which say something about hardware not being found or not being configured. This is normal as the default install kernel tries to detect almost all the hardware supported by NetBSD; you probably don't have all these devices in your machine.

Figure 3.1. Selecting the language

Selecting the language

When the boot procedure is over you will find yourself in the NetBSD installation program, sysinst, shown in Figure 3.1, “Selecting the language”. From here on you should follow the instructions displayed on the screen, using the INSTALL.* document as a reference. You will find the INSTALL.* document in various formats in the root directory of the NetBSD release. The sysinst screens all have more or less the same layout: the upper part of the screen shows a short description of the current operation or a short help message; the central part of the screen shows the current settings as detected by NetBSD; the bottom part displays a menu of available choices. To make a choice, either use the cursor keys, the “Ctrl+N” (next) and “Ctrl+P” (previous) keys, or press one of the letters displayed left of each choice, and confirm your choice by pressing the Return key.

Start with the selection of the language you prefer for the installation procedure.

The next screen Figure 3.2, “Selecting a keyboard type” will allow you to select a suitable keyboard type.

Figure 3.2. Selecting a keyboard type

Selecting a keyboard type

This will bring you to the main menu of the installation program (Figure 3.3, “The sysinst main menu”).

Figure 3.3. The sysinst main menu

The sysinst main menu

Choosing the “Install NetBSD to hard disk” option brings you to the next screen (Figure 3.4, “Confirming to install NetBSD”), where you need to confirm to continue the installation.

Figure 3.4. Confirming to install NetBSD

Confirming to install NetBSD

After choosing to continue with “Yes”, you select on which hard disk NetBSD shall be installed. If more than one disk is available, sysinst displays a list of disks from which you need to choose one. In the example given in Figure 3.5, “Choosing a hard disk”, there are two disks, and NetBSD will be installed on “wd0”, the first IDE disk found. If you use SCSI or external USB disks, the first will be named “sd0”, the second “sd1” and so on.

Figure 3.5. Choosing a hard disk

Choosing a hard disk

Sysinst will then ask whether you want to do a full, minimal or custom installation. NetBSD is broken into a collection of distributions sets. “Full installation” is the default and will install all sets; “Minimal installation” will only install a small core set, the minimum of what is needed for a working system. If you choose “Custom installation” you can choose which sets you would like to have installed. This step is shown in Figure 3.6, “Full or custom installation”.

Figure 3.6. Full or custom installation

Full or custom installation

If you chose to do a custom installation, sysinst allows you to choose which distribution sets to install, as shown in Figure 3.7, “Selecting distribution sets”. You will at least need a “Kernel” “Base” and “System (/etc)” for a functional installation.

Figure 3.7. Selecting distribution sets

Selecting distribution sets

3.5. MBR partitions

The first important step of the installation has come: the partitioning of the hard disk. First, you need to specify if NetBSD will use a partition (suggested choice) or the whole disk. In the former case it is still possible to create a partition that uses the whole hard disk (Figure 3.8, “Choosing the partitioning scheme”) so we recommend to select this option as it keeps the BIOS partition table in a format which is compatible with other operating systems.

Figure 3.8. Choosing the partitioning scheme

Choosing the partitioning scheme

Figure 3.9, “fdisk”The next step shows the current state of the MBR partition table on the hard disk before the installation of NetBSD: There are four primary partitions and as you can see this disk is currently empty. If you do have other partitions you can leave them around and install NetBSD on a partition that is currently unused, or you can wipe out a partition to use it for NetBSD.

Figure 3.9. fdisk

fdisk

Deleting a partition is simple: after selecting the partition a menu with options for that partition will appear (Figure 3.10, “Partition options”), change the partition kind to “Delete partition” to remove the partition. Of course, if you want to use the partition for NetBSD you can set the partition kind to “NetBSD” right-away.

You can create a partition for NetBSD by selecting the partition you want to install NetBSD to. The partition names “a” to “d” correspond to the four primary partitions on other operating systems. After selecting a partition, a menu with options for that partition will appear, as shown in Figure 3.10, “Partition options”.

Figure 3.10. Partition options

Partition options

To create a new partition the following information must be supplied:

  • the type (kind) of the new partition

  • the first (start) sector of the new partition

  • the size of the new partition

Choose the partition type “NetBSD” for the new partition (using the “type” option). The installation program will automatically try to guess option “start”, by starting after the end of the preceding partition. Change this if necessary. The same thing applies to the “size” option; the installation program will try to fill in the space that is available till the next partition or the end of the disk (depending on which comes first). You can change this value if it is incorrect, or if you do not want NetBSD to use the suggested space.

After you have set up the partition type, start and size, it is a good idea to set the name that should be used in the boot menu. You can do this by selecting the “bootmenu” option, and filling in how NetBSD should appear in the bootmenu, e.g. “NetBSD”. It is a good idea to repeat this step for other bootable partitions: so you can boot both NetBSD and a Windows system (or other operating systems) using the NetBSD bootselector. If you are satisfied with the partition options, you confirm your choice by selecting “Partition OK”. You choose the same option in the fdisk interface to finish the partitioning of the disk.

If you have made an error in partitioning (for example you have created overlapping partitions) sysinst will display a message and suggest to go back to the fdisk menu (but you are also allowed to continue). If the data is correct but the NetBSD partition lies outside the range of sectors which is bootable by the BIOS, sysinst will warn you and ask if you want to proceed anyway. This may eventually lead to problems on older PCs.

Note

This is not a limitation of NetBSD: some old BIOSes cannot boot a partition which lies outside the first 1024 cylinders. To fully understand the problem you should study the different type of BIOSes and the many addressing schemes that they use (physical CHS, logical CHS, LBA, ...). These topics can not be described in this guide.

With the most recent BIOS, supporting int13 extensions, it is possible to install NetBSD in partitions that live outside the first 8 GB of the hard disk, provided that the NetBSD boot selector is installed.

If the data is correct, sysinst will offer to install a boot selector on the hard disk. This screen is shown in Figure 3.11, “Installing the boot selector”.

Figure 3.11. Installing the boot selector

Installing the boot selector

At this point, the first part of the installation, the disk partitioning, is over.

The BIOS partitions (called slices on BSD systems) have been created. They are also called PC BIOS partitions, MBR partitions or fdisk partitions.

Note

Do not confuse the slices or BIOS partitions with the BSD partitions, which are different things.

3.6. Disklabel partitions

Some platforms, like PC systems (i386), use (DOS-style) MBR partitions to separate file systems. The MBR partition you created earlier in the installation process is necessary to make sure that other operating systems do not overwrite the diskspace that you allocated to NetBSD.

NetBSD uses its own partition scheme, named a disklabel, which is stored at the start of the MBR partition. In the next few steps you will create a disklabel(5) and set the sizes of the NetBSD partitions, or use existing partition sizes, as shown in Figure 3.12, “Editing partitions?”.

Figure 3.12. Editing partitions?

Editing partitions?

When you choose to set the sizes of the NetBSD partitions you can predefine what partitions you would like to create. The installation program will generate a disklabel based on these settings. This installation screen is shown in Figure 3.13, “Setting partition sizes”.

Figure 3.13. Setting partition sizes

Setting partition sizes

The default partition scheme of just using a big / (root) file system (plus swap) works fine with NetBSD, and there is little need to change this. Figure 3.13, “Setting partition sizes” shows how to change the size of the swap partition to 600 MB. Changing /tmp to reside on a RAM disk (mfs(8)) for extra speed may be a good idea. Other partition schemes may use separate partitions for /var, /usr and/or /home, but you may use your own experience to decide if you need this.

The next step is to create the disklabel and edit its partitions - if necessary - , using the disklabel editor Figure 3.14, “The disklabel editor”. If you have predefined the partition sizes in the previous step, the resulting disklabel will probably fit your wishes. In these case you can complete the process immediately by selecting “Partition sizes ok”.

Figure 3.14. The disklabel editor

The disklabel editor

There are two reserved partitions, “c”, representing the NetBSD partition, and “d”, representing the whole disk. You can edit all other partitions by using the cursor keys and pressing the return key. You can add a partition by selecting an unused slot, and setting parameters for that partition. The partition editing screen is shown in