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.

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.

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

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.

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

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.

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.

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.

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

You will see prompt:

partition>

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:

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.

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.

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

Now record other packages 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 :)

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.