<< Back to man.ChinaUnix.net

Chapter 5. The first boot

Table of Contents

5.1. If something went wrong
5.2. Login
5.3. Changing the keyboard layout
5.4. The man command
5.5. Changing the root password
5.6. Changing the shell
5.7. System time
5.8. Basic configuration in /etc/rc.conf
5.9. Enabling FFS soft-dependencies
5.10. Rebooting the system

After installing and rebooting, the computer will boot from the hard disk: if everything went well you'll be looking at the login prompt within a few seconds (or minutes, depending on your hardware). The system is not yet configured but don't worry: configuration is very easy and the approach offered by NetBSD gives you a lot of flexibility. You'll see how to quickly configure everything and, in the meantime, you'll learn how the system works; in the future, in case of trouble you'll know where to look.

5.1. If something went wrong

If the system doesn't boot it could be that the boot manager was not installed correctly or that there is a problem with the MBR (Master Boot Record). Reboot the machine from the boot floppy and when you see the prompt:

booting fd0a:netbsd - starting in ...

press the space bar during the 5 second countdown; the boot stops and a prompt is displayed. You can have a basic help with the “?” key or with the “help” command.

type "?" or "help" for help.
> ?
commands are:
boot [xdNx:][filename] [-adrs]
     (ex. "sd0a:netbsd.old -s")
ls [path]
dev xd[N[x]]:
> boot wd0a:netbsd

The system should now boot from the hard disk instead of the floppy. If NetBSD boots correctly from the hard disk, there is probably a Master Boot Record problem: you can install the boot manager or modify its configuration with the fdisk -B command. See Section 19.3, “Installing the boot manager” for a detailed description.

5.2. Login

For the first login you will use the root superuser, which is the only user defined at the end of the installation. At the password prompt type the password for root that you have defined during the installation. If you haven't defined a password, just press Enter.

NetBSD/i386 (Amnesiac) (ttyE0)
login: root
We recommend creating a non-root account and using su(1) for root access.

5.3. Changing the keyboard layout

The keyboard still has the US layout; if you have a different keyboard it's better to change its layout now, before starting to configure the system. For example, to use the italian keyboard, give the following command:

# wsconsctl -k -w encoding=it
encoding -> it

See Section 29.1.3, “Keyboard mappings” for a list of keymaps available as well as how to make these settings permanent.

5.4. The man command

If you have never used a Unix(-like) operating system before, your best friend is now the man command, which displays a manual page: the NetBSD manual pages are amongst the best and most detailed you can find, although they are very technical.

man name shows the man page of the “name” command and man -k name shows a list of man pages dealing with “name” (you can also use the apropos command).

To learn the basics of the man command, type:

# man man

The manual is divided into nine sections, containing not only basic information on commands but also the descriptions of some NetBSD features and structures. For example, take a look at the hier(7) man page, which describes in detail the layout of the filesystem used by NetBSD.

# man hier

Other similar pages are release(7) and packages(7). Each section of the manual has an intro(8) man page describing its content. For example, try:

# man 8 intro

Manual pages are divided in several sections, depending on what they document:

  1. general commands (tools and utilities), see intro(1)

  2. system calls and error numbers, see intro(2)

  3. C libraries, see intro(3)

  4. special files and hardware support, see intro(4)

  5. file formats, see intro(5)

  6. games, see intro(6)

  7. miscellaneous information pages, see intro(7)

  8. system maintenance and operation commands, see intro(8)

  9. kernel internals, see intro(9)

A subject may appear in more than one section of the manual; to view a specific page, supply the section number as an argument to the man command. For example, time appears in section 1 (the time user command), in section 3 (the time function of the C library) and in section 9 (the time system variable). To see the man page for the time C function, write:

# man 3 time

To see all the available pages:

# man -w time
# man -a time

5.5. Changing the root password

If you haven't defined a password for root during installation, you should use the passwd command to do so now.

# passwd
Changing local password for root.
New password:
Retype new password:

Passwords are not displayed on the screen while you type. Later we will see how to add other accounts on the system.

5.6. Changing the shell

The default shell for root can be chosen during system installation time, and it usually is csh; if this doesn't mean anything to you, you should begin studying csh with csh(1): it's a good interactive shell although it lacks history editing (have a look at tcsh, bash or even the NetBSD /bin/sh for this). If you want to change your shell, use the chsh(1) command. The shells available on NetBSD after installation are:

  • csh

  • sh

  • ksh

The new shell will come into effect the next time you login. In the meantime, you can issue the following command if you use csh:

# set filec

which enables filename completion on the command line (with the ESC key; use Ctrl+D for a list of possible completions.)

You can also install other shells on the system, if you want to: tcsh, bash, zsh and other shells are available in the package collection (which we shall examine later).

If you're familiar with the shell you chose, this is a good time to create the shell's initialization files (.chsrc, .login, ...)

5.7. System time

NetBSD, like all Unix systems, uses a system clock based on Greenwich time (GMT) and this is what you should set your system clock to. If you want to keep the system clock set to the local time (because, for example, you have a dual boot system with Windows installed), you must notify NetBSD, modifying the kern.rtc_offset sysctl-variable:

# echo kern.rtc_offset=-60 >>/etc/sysctl.conf
# sh /etc/rc.d/sysctl restart

The value supplied (-60) is the number of minutes west of GMT.

To display the current setting of the kern.rtc_offset variable:

# sysctl kern.rtc_offset
kern.rtc_offset = -60

Now the kernel knows how to convert the time of the PC clock in the GMT system time but you must still configure the system for your local time zone (which you will find in the /usr/share/zoneinfo directory). If you have already done this during the installation you can skip this step (although it is better to check that the setting is correct.) For example, for Italy:

# rm -f /etc/localtime
# ln -s /usr/share/zoneinfo/Europe/Rome /etc/localtime

Once everything is set up correctly, you can change the time with the following command:

# date [[[[[cc]yy]mm]dd]hh]mm

5.8. Basic configuration in /etc/rc.conf

NetBSD uses the /etc/rc.conf for system configuration at startup: this file determines what will be executed when the system boots. Understanding this file is very important.

The /etc/defaults/rc.conf file contains the default values for a lot of settings, and to override a default value, the new value must be put into /etc/rc.conf: the definitions there override the one in /etc/defaults/rc.conf (which should stay unchanged).

Understanding the /etc/rc.conf file is very important. The rc.conf(5) manual page contains a detailed description of all the options.

# man rc.conf

The first modifications are:

  • Set “rc_configured=yes” (this modification might already have been done by the installation software.)

  • Set “dhclient=yes” to configure your system's network using DHCP.

  • Set “sshd=yes” to start the Secure Shell server daemon upon system start.

  • Define a hostname for your machine (use a fully qualified hostname, i.e. one including domain). If you have a standalone machine you can use any name (for example, woody.toys.net). If your machine is connected to a network, you should supply the correct network name.


    Make sure that the hostname is resolvable, either using DNS or /etc/hosts; some programs do not work with an unresolvable hostname.

5.9. Enabling FFS soft-dependencies

This might be a good point to enable soft-dependencies for FFS filesystems. By default NetBSD writes FFS meta-data synchronously, which means that meta-data is written to disk immediately. Soft-dependencies is a mechanism which does not write meta-data immediately, but it is written in an ordered fashion, which keeps the filesystem consistent. This provides performance comparable to asynchronous mounts, without the same risks. Soft-dependencies can be enabled by adding softdep to the filesystem options in /etc/fstab. Let's look at an example of /etc/fstab:

/dev/wd0a / ffs rw 1 1
/dev/wd0b none swap sw 0 0
/dev/wd0e /var ffs rw 1 2
/dev/wd0f /tmp ffs rw 1 2
/dev/wd0g /usr ffs rw 1 2

Suppose we want to enable soft-dependencies for all filesystems, except for the / partition. We would change it to (changes are emphasized):

/dev/wd0a / ffs rw 1 1
/dev/wd0b none swap sw 0 0
/dev/wd0e /var ffs rw,softdep 1 2
/dev/wd0f /tmp ffs rw,softdep 1 2
/dev/wd0g /usr ffs rw,softdep 1 2

These are some references for more information about filesystems and soft-dependencies:

5.10. Rebooting the system

In this first session you have:

  • Configured the keyboard

  • Changed the root password (optional)

  • Changed root's shell (optional)

  • Changed the system time and the RTC offset

  • Defined the local time

  • Configured /etc/rc.conf

Now it's time to reboot the system, with the following command:

# reboot