Appendix B. Installing without sysinst

Table of Contents
B.1. Theory of partitioning and installation process
B.2. Installation in practice

This appendix has been contributed by Wojciech Puchar

This appendix is intended to help installing NetBSD version 1.5.2 without it's sysinst utility. You may ask why not to use this tool. Here are some possible reasons:

This appendix covers only i386 machines on which NetBSD will be the only OS on drive. I just haven't enough almost on other cases to write about. However I tried to mark every i386-specific fragments and any contribution are welcome (including fixes to my poor english) by mail to

Basic Unix knowlege (about what is cd, ls, cp, tar) is required.

B.1. Theory of partitioning and installation process

The installation process consist of 5 parts:

  1. partitioning target disk

  2. making filesystem(s)

  3. installing the bootloader (platform-specific, no-op on sparcs, shark etc..)

  4. decompressing the distibution files to the target partition.

  5. final configuration (making /dev nodes, /etc/fstab, setting hostname etc..)

B.1.1. Partitioning

Partitioning could be done in many complex ways. This document is not intended for discussion about what partitioning scheme is the best or the worst, and discuss classic Unix partitioning with a small root partition, a swap partition and an /usr partition for everything else.

In this document and in many NetBSD manuals you will often see the word "label" or "disk label". Disk labels are just NetBSD (or general BSD) way of storing partitions info. So creating disklabel means partitioning.

B.1.2. Swap partition size

Only if your system is overloaded with memory and you are absolutely sure it will not ever need swapping you may omit this part. However on today's huge drives it's not a problem to leave some space for swapping, giving you a comfort of starting lot of programs at once.

There is no "magic rule" about swap partition size. The only true rule is that it's better to have too much than not enough as going out of swap means killing not the last program you started but any working process that just needed to allocate memory. It may be even /sbin/init which will crash your system. If you have one of these huge >10GB drives just leave 500MB or even more for swap. The only problem is that allocating swap means static allocation of physical RAM in amount of 16 bytes per one i386 page (4kB) which is megabyte of memory per 256MB of swap. so - if you have 128 meg system allocating 512MB of swap means 2 megs of memory locked. It's not bad but with a 16MB machine it may be a problem. To sum it up - if you have large drive just allocate lot of swap. if not - think about how much memory will use all the apps you need to run on that machine.

B.1.3. Swap partition placement

One may think there is no difference where swap partition is placed. With very old drives (like MFM ones) it would make no difference. In modern drives ("modern" = 80-120MB or more) in outer tracks more data is written than in inner track due to it's length. That means faster I/O to data in outer tracks - which are on logical beginning of drives (please correct me if there are exceptions). So - putting swap on beginning of drive will make it faster than in the end.

B.1.4. Filesystems

NetBSD generally uses a filesystem called "ffs" or "ufs" (Fast File System or Unix File System). While "fast" is not "the fastest in the world" it is good for general use, and has mechanisms that protect its consistency on crashes. While just using the "newfs" command without special parameters will do the job, it's really worth to optimize it. Here is short description of the parameters worth modyfying:

-m (percentage)

sets how many percents of space are reserved. default 10% is quite large, you could use 5% without problems, but try not to use less as filling ffs filesystem so much makes it slower.

-b (block size)

sets how many bytes one block consist of. For large disks use 8192 (8 kilobytes), for really small ones (<500MB) use 4096 to save some space. Using larger blocks doesn't give much speedup but wastes more space. Anyway it makes sense if you will mostly store large files like mp3's.

-f (fragment size)

sets size of fragment. One block can be divided into up to 8 fragments and there is no reason to not use it. So use a fragment size equal 1/8 of your block size: 512 for 4096 bytes/blocks and 1024 for 8192 bytes/blocks. This is the minimal allocation unit for files (like clusters in Windows.)

-i (bytes of data/inode)

inodes are data structures used to store file info. You need at least one inode per file and preferably some more to allow ffs store file data near files itself. The default 4096 is far too much for large drives, as it means 5 millions of files on 20GB device. Rough estimation is to use -i 16384 for >2GB drives and -i 32768 for >8GB drives. Using larger values doesn't save much space as one inode takes 128 bytes.

The options that I use for >10GB partition are

newfs -m 5 -b 8192 -f 1024 -i 32768 /dev/{partition_name}

Please do read manual of newfs sometime.

B.1.5. Installing bootloader

During the boot process, the kernel image (usually named /netbsd) must be fetched from disk to memory. As PC-BIOS (and other firmware code on other architectures) don't know such abstractions like filesystem, it can only load first disk sector and execute it's code. This code determines where the bootloader is located on your drive and load it. The bootloader itself knows about filesystems and can finally load the kernel from disk. As the boot sector must be recorded with placement data you cannot just copy bootloader (/boot file) to the target partition. The following command:

# /usr/mdec/installboot -v /usr/mdec/biosboot.sym /dev/rwd0a

will do this job for you. Unlike Linux, it must be done only once.

Decompressing the distribution tarballs and the final system configuration do not need much theory, so read the following section.

B.2. Installation in practice

In every example I assume your disk drive is named wd0 in NetBSD, your CD drive (if present) cd0 and your ethernet card ep0 (if you have.) If the actual names are different just replace them in the examples.

B.2.1. Boot

Boot the installation floppy or CD. When the sysinst menu appears select "x - exit to shell". Type command dmesg | more to see/check what are names of your hardware. For example if you see:

wd0 at pciide0 channel 0 drive 0: <ST320423A>
wd0: drive supports 32-sector pio transfers, lba addressing
wd0: 19536 MB, 16383 cyl, 16 head, 63 sec, 512 bytes/sect x 40011300 sectors
wd0: 32-bit data port
wd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 4

It means that the drive showing itself as "ST320423A" (ST usually means Seagate) is connected as master to first channel of your IDE controller and consists of 40011300 sectors of 512 bytes which gives about 19GB of space. If the reported size is little (5-8%) smaller than what manufacturer reports it's normal. Manufacturers often use word "gigabyte" as billion (1000000000) and not 2^30 which is what "giga" mean in computers. As 2^30=1073741824 it's this 7.4% of difference.

If you see:

ep0 at pci0 dev 10 function 0: 3Com 3c590 Ethernet
ep0: interrupting at irq 9
ep0: address 00:20:af:f7:cd:71, 32KB byte-wide FIFO, 1:1 Rx:Tx split
ep0: 10baseT, 10baseT-FDX, 10base5, 10base2 (default 10baseT)

It means your ethernet card got name ep0. Most messages are self explanatory and are really worth of reading even by beginners.

B.2.2. Initializing the disk

As we want a NetBSD only system, we can wipe all partitions that were made on the disk before, with the command:

# dd if=/dev/zero of=/dev/rwd0d bs=1m count=1

which will wipe first megabyte of drive with 0's.

/dev/rwd0d means: raw partition d of disk wd0. The d partition is on i386 a pseudopartition that always maps to whole drive. "Raw" means that no buffering is done by the system which is not needed here.

B.2.3. Using disklabel to create partitions

# disklabel -I -i wd0

This will begin partitioning/labeling on clean drive. Don't type -I if you want to modify existing labels.

You will see prompt:


Ready for your commands. The most important commands are ? (help), I (setting general disk information) and lowercase a to h (setting partition info for partition a, b, c, ..., h).

Begin with I. You will be asked for disk type (accept the default), disk name (same), and label name. In label name type whatever you want, but writing your name is useful. If someone steals your drive and will be found you can show it's yours. DOS/Windows fdisk won't wipe this.

Number of partitions: select 8 or more if you really need more. Leave defaults for the other options as all geometry infos are fake for modern drives.

Now you have to create partitions. begin with partitions d and c pointing to whole drive:

partition> d
Filesystem type [?] [unused]: 
Start offset [0c, 0s, 0M]: 0s
Partition size ('$' for all remaining) [39693.8c, 40011300s, 19536.8M]: $
partition> c
Filesystem type [?] [unused]: 
Start offset [0c, 0s, 0M]: 0s
Partition size ('$' for all remaining) [39693.8c, 40011300s, 19536.8M]: $

Note: in the i386 port, partition d covers the whole disk and partition c covers the NetBSD part of the disk. In this example NetBSD uses all the disk and the c and d partitions are equal.

Then create the partition you want to place at the beginning of the disk. In the classic Unix partitioning it will be partition "a" for about 50MB. Make it larger if you intend to have lots of mail in spool or other things in /tmp or /home and you don't make a separate /var or /home partition.

partition> a
Filesystem type [?] [unused]: 4.2BSD
Start offset [0c, 0s, 0M]: 0s
Partition size ('$' for all remaining) [0c, 0s, 0M]: 100000s

100000 sectors will be about 50MB (a little less.)

Then second (swap) of about 585MB:

partition> a
Filesystem type [?] [unused]: swap
Start offset [0c, 0s, 0M]: 100000s
Partition size ('$' for all remaining) [0c, 0s, 0M]: 1200000s

and then the partition for /usr (e) till the end of drive:

partition> e
Filesystem type [?] [unused]: 4.2BSD
Start offset [0c, 0s, 0M]: 1300000s
Partition size ('$' for all remaining) [0c, 0s, 0M]: $

Now use P to check you did everything right:

partition> P
8 partitions:
#        size   offset     fstype   [fsize bsize cpg/sgs]
  a:   100000        0     4.2BSD        0     0    0   # (Cyl.    0 - 99*)
  b:  1200000   100000       swap                       # (Cyl.   99*- 1289*)
  c: 40011300        0     unused        0     0        # (Cyl.    0 - 39693*)
  d: 40011300        0     unused        0     0        # (Cyl.    0 - 39693*)
  e: 38711300  1300000     4.2BSD        0     0    0   # (Cyl. 1289*- 39693*)

Note: You must be absolutely sure that partitions (excluding c and d) don't overlap! Check it twice.

Now type:

partition> W
Label disk [n]? y
Label written
partition> Q

to finally write your disklabel. Congratulations - the most difficult part is over!

B.2.4. Creating the filesystems and installing the bootloader

For a small root partition use:

# newfs -m 5 -b 4096 -f 512 /dev/rwd0a

For large partitions:

# newfs -m 5 -b 8192 -f 1024 -i 32768 /dev/rwd0<partition name>

Please read the theory in the previous sections first and don't blindly retype the command.

Now install the bootloader:

# /usr/mdec/installboot -v /usr/mdec/biosboot.sym /dev/rwd0a

B.2.5. Decompressing the installation files

Mount your partitions at /mnt:

# mount -o async,noatime /dev/wd0a /mnt
# mkdir /mnt/usr
# mount -o async,noatime /dev/wd0e /mnt/usr
maybe more if you created more

Options async and noatime aren't mandatory. They just favor the speed of the filesystem over safety. Crash protection isn't important now as you can wipe it again in case of crash.

The following sections describe some common installation methods:


B.2.5.1. Installing from CDROM

# mount_cd9660 /dev/cd0a /mnt2
# cd /mnt2/where_distribution_files_are

It's often i386/binary/sets. Use cd step by step and ls if you are not sure.

ls and cp files you need to /mnt/usr. At a minimum you should install base.tgz, etc.tgz and kern.tgz. For large drives simply copy everything except most kern*.tgz files as you need only one kernel.

Now cd / and umount /mnt2 you may remove your CD now.

B.2.5.2. Installing from FTP server

Activate your network. For example, if your IP is and your network mask is (24 bits) type:

# ifconfig ex0 up

Adding "media 10base2" or "media 10baseT" or "media 100baseT" may be needed if your card can't autodetect it or does it wrong. Refer to the ifconfig manual page for more info.

If your FTP server is not on the local network (preferred), add a default route:

# route add default

then ftp to server containing NetBSD files. You must use IP's not names now.

# cd /mnt/usr
# ftp

Log in, change directory to where distribution files are, ls and fetch all needed files with the get command. Then logout.

B.2.5.3. Copying through NFS

Activate your network as in 3.e.2. then

# mount IP-of-your-nfs-server:/directory /mnt2

for example:

# mount /mnt2

then proceed like installing from CD. For example:

# cd /mnt2/NetBSD-1.5.2/i386/binary/sets
# ls

and copy all needed files. Then

# cd /
# umount /mnt2

B.2.5.4. Copying from tape

While desktop machines usually have no tape drives, servers usually do, and may not contain a CDROM drive just to waste space. Installing from tape is very easy; unfortunately PCs cannot boot from tape so you must boot from floppies.

To prepare your install tape you need to do this on another machine with a tape drive.

Rewind tape:

# mt rewind

set unlimited block size for SCSI tapes

# mt setblk 0

This will change the default very small block size to any size. we will use large blocks to make things fast. It's useful for DAT/DDS drives.

!!!WARNING!!! Please correct me if this won't work for other tape types.

Now turn off compression, as different target drives may be unable to read a compressed stream. Compressing already compressed files will give no improvement anyway, or even negative compression rates (up to -15% for HP DDS drives!):

# mt compression 0

then record distribution files:

# cd /where_are_distribution_files
# tar -b64 -cvf /dev/nrst0 *.tgz

The last command will write all tgz files to tape with a block size of 64*512 bytes=32 kB. This is a well tested block size for every DAT.

As you use /dev/nrst0 (non-rewinding first SCSI tape drive) you can now record another archive with, for example, some basic packages like editors.

# cd /where_are_packages/All
# tar -b64 -cvf /dev/nrst0 joe*.tgz screen*.tgz

This will record only the joe text editor and the screen program. Don't put too many things on this file.

Now record other packeges you will install after having system working multiuser.

# tar -b64 -cvf /dev/nrst0 all_packages_you_will_need

or maybe even

# tar -b64 -cvf /dev/nrst0 *.tgz

Now rewind and unload tape:

# mt rewoffl

Your install tape is ready! As DDS drives are backward compatible it may be handy to buy some used DDS-1 or DDS-2 tape drive cheaply for your home machine. You will be able to prepare such tapes, and of course to backup your home computer. It's really nice thing - worth $30 for me :)

B. Installing from tape

Load tape in drive and do:

# mt rewind
# mt setblk 0
# cd /mnt/usr
# tar -b64 -xvf /dev/nrst0

B.2.6. Uncompressing the distribution sets

It is not bad idea to copy some small extra packages now especially editors different that vi (like joe, jed) if you don't like vi. Copy the packages to /mnt, not /mnt/usr! Of course you can choose any method to transfer the files, NFS, tape drives and even floppies.

Now uncompress the tarballs:

# cd /mnt
# for x in usr/*.tgz;do tar xzpvf $x;done
# rm usr/*.tgz

or, if you prefer, one by one

# tar xzpvf /usr/base.tgz

It's not bad idea to move and link /tmp /var and /home to /usr if you created one large /usr partition.

# cd /mnt
# tar cvf - var home tmp|(cd usr;tar xpvf -)
# rm -rf var home tmp
# ln -s usr/var .
# ln -s usr/home .
# ln -s usr/tmp .

This sequence will move var and home to usr, and create links.

Don't uncompress extra packages yet!

B.2.7. Finalizing your installation

This will create all /dev nodes (takes a while on 486 !):

# cd /mnt/dev
# ./MAKEDEV all

Now cd /mnt/etc and create fstab. You can use vi but if you don't like it or don't know it, simply do:

# cat > fstab
# /dev/wd0a / ffs rw,softdep,noatime 1 1
# /dev/wd0b none swap sw 0 0
# /dev/wd0e /usr ffs rw,softdep,noatime 1 1
# ^D (control-D)

Now check that all is correct:

# cat fstab

If yes, remove CD/floppies, type reboot and wait until the system boots single user!

Get to shell and type

# /sbin/mount -a

to mount all filesystem read-write. If you have some packages like editors, install them with the pkg_add. Then remove the tarballs with rm.

Now you have to edit /etc/rc.conf, /etc/defaults/rc.conf and other files. Read the standard INSTALL document on how/what to do it. Generally setting

in /etc/rc.conf and setting hostname in /etc/defaults/rc.conf is enough to make system running.

Type ^D (Control-D) to allow multiuser boot. Your system is successfully installed.