Chapter 3. Installation

Table of Contents
3.1. Documentation
3.2. The layout of a NetBSD installation
3.3. Installation
3.4. Installation example

3.1. Documentation

The documentation of NetBSD is mostly in the format for manual pages and makes up an excellent technical reference to the system. I won't deny that it is unsuited as a tutorial (not to mention the fact that you can't read it until you install NetBSD); these are the reasons for the existence of this guide.

After installation you will find some BSD guides in the /usr/share/doc directory. They are divided in three main sections, psd (UNIX Programmer's Supplementary Documents), smm (UNIX System Manager's Manual) and usd (UNIX User's Supplementary Documents). You can read the text on the terminal with, for example:

$ cd /usr/share/doc/smm/09.sendmail
$ nroff -me 09.sendmail/intro.me | more
      
or you can generate Postscript output using the makefiles.

It's undeniable that there is a lack of HOWTOs and for this reason you should make the most of the existing ones; the NetBSD release contains some documents in text format and on the NetBSD web site you can find further information and FAQ's.

Original documentation: the NetBSD site contains several pages with documentation and HOWTOs both generic and platform specific. This information is well written and usually easy to understand; for example you can find:

  • how to access a DOS/Windows partition from NetBSD

  • how to start NetBSD from the Windows NT boot loader

  • ...

All the versions of NetBSD contain the following files:

INSTALL

installation notes. This is the most important document and you should read (and reread it) carefully; it contains a description of the NetBSD system, a list of the supported hardware and, most notably, the installation instructions.

README.first

you should also read this.

release.man

describes the structure of the NetBSD release you are installing. It is a text file in man layout: it is preformatted and you can read it with any editor.

On the NetBSD web site you can find, amongst the others, the following guides:

NetBSD FAQ

general information and pointers to other FAQ.

NetBSD/i386 FAQ

NetBSD/i386 specific FAQ.

Basic NetBSD Networking

Guide to network and PPP configuration.

3.2. The layout of a NetBSD installation

The layout of the files of a NetBSD installation is described in the aforementioned INSTALL file. For example, for the i386 platform the system binaries are in the i386/binary/sets directory and the sources are in the source/sets directory. The source/patches directory contains patches to the base release which usually fix bugs or security related problems discovered after the release.

3.3. Installation

The first thing to do before installing NetBSD is to read the release information and installation notes in the INSTALL file: this is the official description of the installation procedure. Next you should decide the installation media that you will use; you can choose between:

ftp
nfs
CDROM
floppy
filesystem
local directory

3.3.3. Partitions (and booting)

In this section we'll try to explains what partitions are (from the standpoint of the BIOS and of NetBSD), how a PC boots and how NetBSD gains control.

When a PC is turned on the BIOS is called, which performs the Power On Self Test (POST) and determines which device should be used for booting (this is usually configurable in the BIOS settings); in this example it will be the first IDE hard disk (identified with wd0 by NetBSD). The BIOS loads in memory the "boot loader", a small program which resides in the Master Boot Record (MBR) of the hard disk and executes it (i.e. jumps to the first instruction).

The Master Boot Record is the sector at cylinder 0, head 0, sector 1 of the hard disk and, besides the already mentioned boot loader, contains the BIOS partition table, which indicates how the disk is partitioned.

Partitioning a hard disk means subdividing its physical surface in logical units (the BIOS partitions); the partitioning scheme is recorded in the partition table of the MBR. When you partition a disk you have several benefits, for example you can install more than one operating system on the same disk, each in its own partition. Using more than one partition for the same OS can minimize the risk of loosing data in case of a malfunction.

Supposing you have partitioned the hard disk and installed more than one OS, how can the MBR loader decide which one to start at boot? The answer is easy: the partition table contains a flag which indicates which partition is "active" and should be booted. The loader identifies the active partition, loads a second program from the first sector of the active partition and executes it; this program is responsible for booting the OS residing in the partition (NetBSD calls this program "boot" and the associated data "bootblocks": "boot" loads and executes the NetBSD kernel.)

According to the previous descriptions it looks like when you turn on a PC the same OS is always booted (the one in the active partition), which is true if you use standard MBR. To solve this problem you must use a program called "boot selector" which lets you choose which OS to boot; this program replaces the standard loader in the MBR.

NetBSD has a custom boot selector which can be written in the MBR by the installation program if the user requests it. This program is simple and yet very effective. By now it should be clear that you need a boot selector only if you have more than one operating system installed.

NetBSD installs in one of the four primary BIOS partitions (the partitions defined in the hard disk partition table).

We have described the BIOS and its partitions; NetBSD can read and understand the partitions in the MBR but it doesn't use this scheme internally. Instead it uses its own partition table which is called "disklabel" and resides at the beginning of the NetBSD BIOS partition. Note that this table is managed only by NetBSD: the BIOS is unaware of its existance.

The NetBSD partitions in the disklabel 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 3-1 there are two primary BIOS partitions, one used by DOS and the other by NetBSD. NetBSD describes the disk layout through the disklabel.

3.4. Installation example

The remaining part of this chapter deals with a real installation example for a common case: installation from CD-ROM. The concepts are the same for all types of installation (eg. ftp); the only difference is in the way the binary sets are found by sysinst. Please note that some details of the installation differ depending on the NetBSD release: this example was created with release 1.5.

For the sake of teaching, in the following example the most "difficult" options will always be chosen.

This set of choices gives the impression that the installation is very complicated and requires a lot of work: remember that if you accept the defaults everything is much simpler. On the other hand, a tutorial which explains only the "easy" parts is not very useful (except from the marketing point of view...)

3.4.3. Last preparatory steps

Everything is now ready for the installation but, before beginning, it is better to gather some information on the hardware of the PC.

The most important thing to check is the type of hard disk (IDE, SCSI) and its geometry. You can find this information on the hard disk manual or using a diagnostic program. Some hard disks have a label on which this data is written. Another option is to connect to the web site of the producer of your disk and look for the product info.

If you install via ftp or NFS remember to check your network card settings: if the installation kernel expects your card to be on an IRQ but the card's settings are different you won't be able to install. For example, the install kernel can recognize an NE2000 compatible network card with one of the following two settings:

ne0     at isa? port 0x280 irq 9        # NE[12]000 ethernet cards
ne1     at isa? port 0x300 irq 10	
If your NE2000 network card has different settings it will not be detected. (After the installation you will be able to compile a customized kernel with your own settings.)

While you are at it you should check some other hardware details like, for example, the number of serial and parallel ports, etc.; this is not required for installation but it can turn out useful later. Check your settings (IRQ, I/O ports, ...) against the ones written in the INSTALL file.

Note: you can install even if you don't know the hard disk geometry as well as any of the other details. In this case you must trust sysinst, which automatically determines the geometry and (usually) gets it right.

3.4.4. Beginning the installation

Insert the newly created installation floppy in drive A: and reboot the computer (or boot from CD-ROM). The kernel on the floppy 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: the kernel on the floppy tries to detect almost all the hardware supported by NetBSD; you probably (!) don't have all these devices in your machine.

When the boot procedure is over you will find yourself in the main menu of the installation program, shown in Figure 3-2. Don't be deceived by the spartan look of sysinst: it is a rather powerful and flexible program. From here on you should follow the instructions displayed on the screen, using the INSTALL document as a reference. 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. Choosing the Install option ("a") brings you to the next screen (Figure 3-3) where you confirm the operation.

After choosing to continue with option "b", it is time to select on which hard disk you want to install NetBSD. If more than one disk is available, sysinst displays a list of disks from which you can pick one. In this example there is only one hard disk and the installation program only displays an informational message, shown in Figure 3-4.

Note: the information in this screen will be different depending on the type and number of hard disks installed on the system.

Next (Figure 3-5) sysinst displays the BIOS geometry for the chosen disk; you can confirm that it is correct or, if the installation program got it wrong, you can modify it by entering new values manually.

3.4.5. Partitions

The first important step of the installation has come: the partitioning of the hard disk. First you must specify if NetBSD will use a partition (suggested choice) or the whole disk ("dangerous" choice). In the former case it is still possible to create a partition that uses the whole hard disk (Figure 3-6) so I recommend to select this option which, if I understand correctly, keeps the BIOS partition table in a format compatible with other operating systems.

In the this example we will use a disk with the following "real" geometry, corresponding to the BIOS geometry of Figure 3-5.

6232 cyl, 16 heads, 63 sec  (6232 x 16 x 63 = 6281856 total sectors)
1 sector = 512 bytes
1 track = 63 sectors = 63 * 512 bytes = 32 K
1 cylinder = 16 * 63 * 512 bytes = 504 K      

The next step, depicted in Figure 3-7, is the selection of a unit of measure to be used for hard disk partitioning: sectors give the most flexibility and precision (note that it is usually better to align partition on cylinder boundaries for performance reasons, at least on older hard disks.) Megabytes are easier to use because they don't require manual calculations and are more "intuitive".

This tutorial will use sectors because they are more useful for teaching purposes. Chosing option "c" you are taken to the fdisk interface screen.

Figure 3-8 shows the current situation of the hard disk before the installation of NetBSD; there are four primary partitions: one is used by DOS/Windows and two by GNU/Linux; the last one is unused. There is no free space on the disk: the End(sec) column of partition 2 shows that the 6281856 sectors of the hard disk are all occupied.

Note: in the fdisk screen the following formula holds:

Start(sec) + Size(sec) = End(sec)      
This means that the End(sec) column of a partition is equal to the Start(sec) column of the following partition, which is not very intuitive because the sector in the End(sec) column of a partition actually belongs to the following one. Disklabel will use a different (and more logical) convention.

To make room the two Debian GNU/Linux partitions will have to sacrificed, starting with the last one. Sysinst displays a screen that can be used to modify the existing data for a partition and Figure 3-9 shows the current data for partition 2.

To delete the partition, select type unused using option "a" and than choose option "b" leaving the fields "Start" and "Size" empty (press Enter leaving the fields blank). Finally, confirm everything with option "d" and you are back in the main fdisk screen, where partition 3 is now empty. Use the same method to delete partitions 2 and 1, leaving only partition 0 on the disk (Figure 3-10.)

Only the DOS/Windows partition is left, using 2088516 sectors which are equal to 1029 MB (about 1 GB). The free space is calculated as the difference between the already calculated total number of sectors and the end sector of the DOS partition (the number in the End(sec) column.)

6281856 - 2088579 = 4193277 sectors = 2047 MB free on disk      

Now, using option "b", a new partition for NetBSD will be created, starting at the end of the DOS partition. To create a new partition the following information must be supplied:

Choose the partition type "NetBSD" for the new partition (option "a: Kind") and input the data that we have calculated: start = 2088579 and size = 4193277 using option "b". Check that everything is correct and confirm the creation with option "d", which brings you back to the main fdisk menu. The result is shown in Figure 3-11 which displays the final layout of the partition table. Now, selecting option "x" you proceed to the next menu.

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 (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 warns you and asks if you want to proceed anyway. This could lead to problems on older PC's: the PC used in the example received this warning but boots perfectly. It is not possible to give a general rule (it is BIOS dependent); if the PC is not very old I suggest to ignore the warning and continue.

If the data is correct and sysinst detects that you have more than one operating system on your hard disk, it will offer to install a boot selector on the hard disk. Using the installation program you can both install the boot selector and configure it; you can specify what strings will be displayed on the boot menu for each operating system, which partition is booted by default and the timeout used when the user does not select anything. This screen is shown in Figure 3-12.

Note: if the arrow keys don't work you can scroll the menu options using the < and > keys.

Select the partitions that will appear in the boot manager menu and define a menu item string for each one using the options from "a" to "d". In the "Menu entry" column you should see an entry for each bootable partition, as shown in Figure 3-13.

Option "e" enables you to choose a timeout for the boot menu: once the timeout is elapsed without a choice from the user, the default partition (defined with option "f") is booted. You can specify one of the following as default:

After finishing the boot manager configuration, the first part of the installation, namely disk partitioning, is over.

The BIOS partitions, also called slices by BSD, have been created; there are now two slices: DOS and NetBSD. It's time to define the BSD partitions.

3.4.7. Creating a disklabel

First, let the installation program automatically create a disklabel. Choosing option "b" from Figure 3-14 we are taken to Figure 3-15.

Having done this you could just confirm everything (with option "b") and your work would be over. Instead, let's see what you need to do to modify the size of the swap partition to make it smaller and increase the size of the /usr partition. To change the size of the swap partition, choose option "a": in the new screen we change the unit of measure to sectors. The result is shown in Figure 3-16.

The sequence of partition identifiers is standard: some letters are reserved for predefined uses.

You normally don't want to modify partitions b and c. You are free to change the size and mount point of the remaining partitions and to create new ones (with a maximum of 8, using the letters from e to h.)

To modify the swap partition you need to modify partition b. You will also need to modify partition "e", so that it begins right after the end of "b". Partitions "c" and "d" will be left unchanged.

You will now create a 150 MB (307200 sectors) swap partition; this means that "b" will start at sector 2524032 and end at sector 2831231 (2524032+307200-1).

id:      Size    Offset       End FStype Bsize Fsize Mount point
---      ----    ------       --- ------ ----- ----- -----------
 a:    435453   2088579   2524031 4.2BSD  8192  1024 /
 b:    307200   2524032   2831231   swap
 ...      

The newly freed space will be assigned to partition "e", which will have: start = 2831232, size = 3450624 and end = 6281855. These values have been calculated as follows: "start" is the sector immediately following the end sector of partition "b"; "end" is equal to the last sector of the NetBSD partition; "size" is given by: End - Offset + 1.

id:      Size    Offset       End FStype Bsize Fsize Mount point
---      ----    ------       --- ------ ----- ----- -----------
 a:    435453   2088579   2524031 4.2BSD  8192  1024 /
 b:    307200   2524032   2831231   swap
 ...
 e:   3450624   2831232   6281855 4.2BSD  8192  1024 /usr      

The preceding example shows the disklabel that you want. With option "b" and "e" you can input the data that you have calculated.

This is depicted in Figure 3-17.

Figure 3-18 shows the modified disklabel.

When you are happy with the result, you can select option "x" to save and exit. You are now back in Figure 3-15 where you can choose option "b".

3.4.9. Choosing the installation media

You have finished the first and most difficult part of the installation. In the next step you will choose the type of installation, which can be full, which installs all the sets, or custom, which enables you to choose the sets to be installed. If you don't have a shortage of space on the hard disk I suggest to choose the former option. In this example option custom will be used only to show what it looks like. This brings you to Figure 3-19.

The first three sets are mandatory: without them the system can't work. You can toggle the installation of the remaining sets using the menu options. Initially all sets are selected for installation, which is the same as the aforementioned full option. Leave all the sets on and proceed to the next step with option "x: Exit".

sysinst then asks if you want to see filenames during the extraction from the sets.

Now sysinst needs to find the NetBSD sets (the .tgz files) and you must supply this information. The menu offers several choiches:

The options are explained in detail in the INSTALL document. It is also possible to install from an unmounted filesystem (provided that it is of a type recognised by the install kernel): this means that, for example, it is possible to copy all the sets to an existing MS-DOS partition and install from there.

Selecting "cdrom", sysinst asks the name of the device (for example cd0) and mounts it automatically. You should also input the pathname to the installation sets on the CD-ROM if it is different from the default value. If, for example, the NetBSD distribution is in the NetBSD-1.5 directory you must modify the pathname, using option "b", like this:

/NetBSD-1.5/i386/binary/sets      

The CD-ROM device name: if you don't know the name of the CD-ROM device, you can find it in the following way:

  1. Press Ctrl-Z to pause sysinst and go to the shell prompt (that's a nice feature!)

  2. Type the command:

    # cat /kern/msgbuf      
    This will show the kernel startup messages, including the name of the CD-ROM device (for example cd0).

  3. If the display scrolls too quickly, you can also use the ed editor.

    # ed /kern/msgbuf      

  4. Go back to the installation program with the command:

    # fg      

At the end of the installation sysinst displays a message saying that everything went well. Selecting option "a: ok" the device files are created.

The installation is over. Sysinst can now do some system configuration before rebooting. First you can configure the timezone and, in the following screen, you can choose a password for root. Now it's tiem to reboot. Select "a: ok" and go back to the main menu, then remove the floppy from the drive and select option "d: Reboot the computer".