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:
possibility to use nonstandard labeling and fs options
because it's easy (yes it is!)
because there are people who like to have full control of their system and to exactly know what up (like me)
one may prepare their own install floppies without sysinst, and make use of reclaimed space for other usable tools
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 wojtek@3miasto.net.
Basic Unix knowlege (about what is cd, ls, cp, tar) is required.
The installation process consist of 5 parts:
partitioning target disk
making filesystem(s)
installing the bootloader (platform-specific, no-op on sparcs, shark etc..)
decompressing the distibution files to the target partition.
final configuration (making /dev nodes, /etc/fstab, setting hostname etc..)
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 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.
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:
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.
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.
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.)
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.
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.
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.
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.
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.
# 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:
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:
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!
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
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:
CDROM |
FTP |
NFS |
# 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.
Activate your network. For example, if your IP is 192.168.3.7 and your network mask is 255.255.255.0 (24 bits) type:
# ifconfig ex0 192.168.3.7/24 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 192.168.3.1
then ftp to server containing NetBSD files. You must use IP's not names now.
# cd /mnt/usr # ftp 192.168.3.13
Log in, change directory to where distribution files are, ls and fetch all needed files with the get command. Then logout.
Activate your network as in 3.e.2. then
# mount IP-of-your-nfs-server:/directory /mnt2
for example:
# mount 192.168.3.13:/public/ /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
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 :)
Load tape in drive and do:
# mt rewind # mt setblk 0 # cd /mnt/usr # tar -b64 -xvf /dev/nrst0
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!
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
rc_configured=YESin /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.