Introduction to NetBSD

Introduction

This mini-article aims to show how easy is to download, install and (basically) configure a NetBSD operating system.

NetBSD is an open operating system (under the NetBSD license) which runs perfectly on 48 architectures and on a few others as experimental. NetBSD is very fast and secure, being a very versatile system, both as server and workstation.

After the reading of this document, the reader should have a NetBSD 3.0 installed, and all the basic details configured to start to work without problems. All this in only a pair of reboots.

Downloading and installing

NetBSD can be easily downloaded from its own web site, in ISO format for CD-ROM, from this address: ftp.netbsd.org.

As of writing this article, the stable version was 3.0. Usually, although we want to use a developer version (-current), we have to start by installing the latest stable version and, afterwards, we can download the source code via CVS and so build with our own optimizations.

When we got the ISO image, we just need to burn it on a CD and then boot with the CD inside the computer to start the installation process. This is the first screen we see:

netbsd01.jpg
Start screen of the NetBSD installer

I chose the English language for the installation, but you can choose between the available languages. After this screen and after choosing the language, we can configure our keyboard too:

netbsd02.jpg
Keyboard choice screen of NetBSD

The next step is to begin with the installation. NetBSD offers us another menu and we choose the option "Install NetBSD on the hard disk". This is the screen:

netbsd03.jpg
Main menu of the NetBSD installer

Now the installer will ask if we are sure and we say "yes" on the following screen:

netbsd04.jpg
Installation confirmation of NetBSD

NetBSD detects now the available hard disks for the installation and we can choose the one where to install the system. In this case, we only have one disk and, therefore, we just can accept to continue:

netbsd05.jpg
Hard disk choice for the NetBSD installation (1)

After this, the installation of NetBSD asks if we want this process to be automated or rather if we want it to be in custom mode (choose the components). It is always better to choose only the components we need, making the installation faster. Attention to the following screens:

netbsd06.jpg
Hard disk choice for the NetBSD installation (2)

netbsd07.jpg
Hard disk choice for the NetBSD installation (3)

In the screens above, we tell NetBSD to choose the components by ourselves and, afterwards, we'll deselect the X11 components, because we only want to install the basic components. As you can see on the list above, there are some kernel from where we can install the one we need. Here you are the description of each type (more or less):

GENERIC Normal kernel with lot of drivers
MP Kernel with multiprocessor support
MPACPI Multiprocessor and ACPI support
TINY Light kernel (with few drivers)

Now, the installer will ask if the disk has the current geometry (normally it is right) and we'll accept on that screen to continue the installation:

netbsd08.jpg
Disk geometry confirmation

In the next step, we'll be asked for the partition table configuration (the option "Edit MBR") or if we'll use the full disk. I chose to edit the MBR because I had to install more systems after this one:

netbsd09.jpg
Chance of editing the partition table

netbsd10.jpg
Partition table configuration

netbsd11.jpg
Set up a partition to install NetBSD

The next question is pretty important. We are asked if we want to install the NetBSD bootloader or not. When we boot our computer, if we have several operating systems, we need a loader to boot one system or another. I chose "no" because I use the "grub" loader from Linux, but if we don't have any other system than our NetBSD, we can safely say "yes" to use the NetBSD bootloader:

/files/nbsd/netbsd12.jpg
Choosing a bootloader

Now we have to choose a size to the internal partitions of the NetBSD slice (swap and others). Moreover, we'll have to choose the block size, the filesystem type and mount options. I usually choose everything by default (but for the filesystem where I choose UFS2 with 64bits support):

netbsd14.jpg
NetBSD partitions' configuration

netbsd15.jpg
Confirmation to make NetBSD format and install everything

After this, NetBSD has formated the disk and set the partition ready to be installed. Now we have to choose s "use BIOS console" (we don't need this if we're using a serial console) and we step to the installation. Attetion to the following screens:

netbsd17.jpg
We choose "progress bar" to see the installation progress

netbsd18.jpg
We choose "install from CD-ROM" since we have it

netbsd19.jpg
We accept on "continue" to install everything

netbsd20.jpg
NetBSD is installing all the basic components

netbsd21.jpg
NetBSD is already installed

Now we'll need to configure some basis before restarting our NetBSD and using it. In the following screens, we can see how to set up some final stuff like the time zone, the root password and the default shell:

netbsd22.jpg
Time zone configuration in NetBSD (1)

netbsd23.jpg
Time zone configuration in NetBSD (2)

netbsd24.jpg
Password crypting configuration (Blowfish is the best)

/files/nbsd/netbsd25.jpg
We say "yes" to configure now the root's password

/files/nbsd/netbsd26.jpg
Enter the root's password

/files/nbsd/netbsd27.jpg
Pick a shell (ksh is the best, it includes completion)

So NetBSD is now installed and everything ready to be used, now we'll reboot the system and go:

netbsd28.jpg
NetBSD installation finalization

netbsd29.jpg
Rebooting the system

Basic configuration

Before starting, for NetBSD versions higher than 3.99.20, we must use the NetBSD loader after our favourite loader because the new kernel uses a new technology called Multiboot. This is my grub configuration from Linux to be able to use NetBSD:

title NetBSD
rootnoverify (hd0,2,a)
chainloader +1

This way, when we choose NetBSD in grub, it will load the NetBSD loader (which automatically will load in 5 seconds), in which we can enter some advanced options before booting our NetBSD.

The first we have to do now is to log in and begin to configure the basis of the system. We enter as root and we create an user account like this:

~$ useradd -s /bin/ksh -m guest1
~$ passwd guest1

With this, we have created the user guest1 and we have assigned him a password. Now let's edit the configuration files under /etc.

I use many terminals, so I add 4 more consoles in text mode. We edit /etc/wscons.conf and after "screen 4 - -", we delete this line and leave the file like this:

screen 0 - vt100
screen 1 - vt100
screen 2 - vt100
screen 3 - vt100
screen 4 - vt100
screen 5 - vt100
screen 6 - vt100
screen 7 - vt100

This way, we'll get 8 consoles in the next reboot. Now, down the file, we configure the keyboard layout and also the repetition speed:

encoding es.metaesc
setvar repeat.del1=400
setvar repeat.deln=40

In the first line, we configure the keyboard to use Spanish and make some special keys work. With the two last lines, we make that the delay between pressing a key and it starts to write is 400 milliseconds, whereas 40 is the delay in milliseconds between shown characters. All this is just an example and it is totally customizable for each user.

For more information execute: man wscons.conf or rather download my own configuration file: /etc/wscons.conf

Now we keep the changes and edit /etc/ttys. There, after the line which says "console ....", edit the first lines till get the following aspect:

ttyE0 "/usr/libexec/getty Pc" wsvt25 on secure
ttyE1 "/usr/libexec/getty Pc" wsvt25 on secure
ttyE2 "/usr/libexec/getty Pc" wsvt25 on secure
ttyE3 "/usr/libexec/getty Pc" wsvt25 on secure
ttyE4 "/usr/libexec/getty Pc" wsvt25 on secure
ttyE5 "/usr/libexec/getty Pc" wsvt25 on secure
ttyE6 "/usr/libexec/getty Pc" wsvt25 on secure
ttyE7 "/usr/libexec/getty Pc" wsvt25 on secure

With this, we have configured 8 terminals (in text mode) and moreover we have changed the terminal type, because "vt220" is very old, and "wsvt25" is better when working with colour and other escape sequences.

Now let's configure the file /etc/mk.conf to enter our own optimizations for later compilations. Have in mind that these lines are an example and you can set it up as you really desire:

CPUFLAGS += -march=pentium-m -mtune=pentium-m -mfpmath=sse
CFLAGS += -O2 -pipe -march=pentium-m -mtune=pentium-m -fomit-frame-pointer -mfpmath=sse
COPTFLAGS += -O2 -pipe -march=pentium-m -mtune=pentium-m -fomit-frame-pointer -mfpmath=sse
CXXFLAGS += -O2 -pipe -march=pentium-m -mtune=pentium-m -fomit-frame-pointer -mfpmath=sse

MKPROFILE = no
MKUPDATE = yes
NOCLEANDIR = yes

MKX11 = no
X11_TYPE = xorg

This file is used by the make program to optimize the new programs which we build and install.

For more information execute: man mk.conf or rather download my own configuration file: /etc/mk.conf

Now let's configure the file /etc/syslog.conf to set up the system messages. I personally change the first and two last lines of the file like this:

*.err;kern.*;auth.notice;authpriv.none;mail.crit /root/system.log
*.emerg /root/system.log
*.notice /root/system.log

NOTE: If we have a laptop, it worths to send all messages to the symbolic file /dev/null, making the log daemon not to touch the hard disk.

For more information execute: man syslog.conf or rather download my own configuration file: /etc/syslog.conf

The next step, before the last step and the second reboot, will be to configure a temporal file system using the main memory (tmpfs or mfs). I use mfs because tmpfs isn't stable yet (when this article is being written). To use mfs we can write the following on our /etc/fstab:

/dev/wd0i /tmp mfs rw,-s=512m 0 0

/dev/wd0i may be another partition, I mean, any letter we want, but always having in mind that it can't be used by another partition. If the partition i exist and is using it, we can use j, k or even z. Its size is also our choice, but it is suggested to use a tmpfs with the same size as the available memory.

For more information execute: man fstab or rather download my own configuration file: /etc/fstab

Finally, before rebooting the system the second time, let's configure the boot services. This is using a very important file in all *BSD, under /etc/rc.conf. When NetBSD boots, it reads this file and starts to load services by calling another available scripts under the directory /etc.

This is a very personal file and you must configure the services which you really use under NetBSD. I activate nothing by default, making the system go faster.

For more information execute: man rc.conf or rather download my own configuration file: /etc/rc.conf

Conclusions

After these steps, we should have a (very basic) NetBSD installed and working without problems. But, from this point, we would like to compile our own kernel (with our optimizations) and, in addition, install third-party software by using binary packages or by downloading the source code and building it (to optimize it even more).

We'll see how to do this in future articles which I'll write, because writing everything in a single article could be too much and, therefore, so tedious. So continue playing with your NetBSD and be patient, because soon I'll write an article about how to configure our own kernel step by step and also start to install packages with third-party software. May any problem arise, please contact me.

www.claudiocamacho.org
Updated on Tuesday, 19 August 2008 16:59