Chapter 4. The first boot

Table of Contents
4.1. If something went wrong
4.2. Login
4.3. Changing the keyboard layout
4.4. The man command
4.5. Changing the root password
4.6. Changing the shell
4.7. System time
4.8. Basic configuration /etc/rc.conf
4.9. Setting the host name
4.10. Rebooting the system

After installing the computer will reboot 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 this approach is not inconvenient but, instead, gives you a lot of flexibility. You'll see how to quickly configure everyhing and, in the meantime, you'll learn how the system works; in the future, in case of trouble you'll know where to look.

4.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]]:
help|?
quit
> boot wd0a:netbsd
    

The system should now boot from the hard disk instead of the foppy. 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 20.4 for a detailed description.

4.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 write 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
password
...
We recommend creating a non-root account and using su(1) for root access.
#
    

4.3. Changing the keyboard layout

The keyboard has still 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    

A full list of keyboard mappings is in /sys/dev/wscons/wsksymdef.h (look for KB_ENCTAB) but some of the more common maps are:

de
dk
fr
it
jp
sv
uk
us
no
es

This setting will last until the next reboot. To make it permanent, add the following line to the file /etc/wscons.conf:

encoding it    

You can also customize the keyboard layout; for example to add the brackets, braces and tilde character to the italian keyboard, create the file /etc/itmap.it containing the following lines:

keycode 12 = apostrophe question grave
keycode 13 = igrave asciicircum asciitilde
keycode 8 = 7 slash braceleft
keycode 9 = 8 parenleft bracketleft
keycode 10 = 9 parenright bracketright
keycode 11 = 0 equal braceright    

and add this line to the /etc/wscons.conf file:

mapfile /etc/itmap.it    

More details in the wscons.conf(5) man page.

There is also a different approach to the keyboard layout problem: you can compile a new kernel which uses your preferred layout by default. This will be described in Chapter 7.

4.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 in nine sections, containing not only basic infomations 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 man page describing its content. For example, try:

# man 8 intro    

Example 4-1. Manual sections

  1. general commands (tools and utilities)

  2. system calls and error numbers

  3. C libraries

  4. special files and hardware support

  5. file formats

  6. games

  7. miscellaneous information pages

  8. system maintenance and operation commands

  9. kernel internals

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 -a time    

4.5. Changing the root password

If you haven't defined a password for root during installation (which was not possible on pre 1.5 systems) now it's time to do it, using the passwd command.

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

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

4.6. Changing the shell

The default shell for root is csh; if this doesn't mean anything to you, you should begin studying csh with (man csh): 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.

Note: to modify the current setting chsh launches the editor specified by the environment variable EDITOR (or vi if the variable is not defined.)

The shells available on NetBSD after installation are:

csh
sh
ksh

The new shell will come into effect the next time you login.

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).

This is a good time to create the shell's initialization files (.chsrc, .login, ... depending on the shell you have chosen.)

4.7. System time

NetBSD, like all UNIX systems, uses a system clock based on Greewich time (UTC) 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 rtc_offset system variable. You can edit the kernel configuration file and recompile the kernel or you can patch directly the existing kernel (the new time will be effective only after rebooting): this is easier than you think. For example:

# gdb --write /netbsd
GNU gdb 4.17
Copyright 1998 Free Software Foundation, Inc.
...
This GDB was configured as "i386--netbsd"...(no debugging symbols found)...
(gdb) set rtc_offset=-60
(gdb) quit
    

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

To display the current setting of the 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 UTC system time but you must still configure the system for your local time zone (which you will find in /usr/share/zoneinfo/.) 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    

4.8. Basic configuration /etc/rc.conf

NetBSD usese 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.

Starting from version 1.5 of NetBSD the administration of rc.conf has changed. In prior versions all the default values were stored in /etc/rc.conf and the user was supposed to modify directly this file; version 1.5 introduced the /etc/defaults/rc.conf file, which contains the default values. To modify a default value the user must write the new value in /etc/rc.conf: this definition overrides the one in /etc/defaults/rc.conf (which stays unchanged.)

Understanding this file is very important. The manual page contains a detailed description of all the options.

# man rc.conf    

The installation program, sysinst, already does the basic configuration. Check that the following lines are present:

rc_configured=YES
wscons=YES    

If "rc_configured" is not YES, the operating system boots in single user mode instead of multiuser. The "wscons" directive configures the console driver. If you want to print, add the following statement to the file, which activates the print spooler.

lpd=YES    

4.9. Setting the host name

It's time to tell to the system the name of the host; there are two simple ways to do this. If the host belongs to a network, you can ask the network and the host name to the system administrator; if it is a standalone machine (such as a home machine) you have freedom of choice. In this example the FQDN will be ape.insetti.net. Read Chapter 9 for further details.

The first method to set the host name is to add the following line to the /etc/rc.conf file.

hostname=ape.insetti.net    

Another way to set the hostname is to put it in the /etc/myname file. For example:

# echo ape.insetti.net > /etc/myname     

4.10. Rebooting the system

In this first session you have

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

# reboot