NetBSD 1.3.2 on SIMH
on an emulated VAX

Doc Version 0.01

GUIDES:
  1. 4.3BSD on SIMH
  2. NetBSD 1.3.2 (vax) on SIMH

See the Gunkies guide for NetBSD 1.2 here. NetBSD 1.3 isn't much easier. It was a tough install to figure out, and uses a lot of CPU when running. 1.4 and later are a lot easier. I'll do them next.

So, why 1.3? The networking portion is a pretty clean 4.4BSD Lite-2 codebase, which means it's a great place to study TCP/IP Illustrated, volume II by Richard Stevens.

Official Install Directions: read this for any questions about the process, or if you get stuck.

I'm doing this on my main desktop, running Debian 8.9. The default simh packages don't have networking, so grab 3.9 or 4.0 and compile it, along with libpcap-dev. I'll assume it's already built with pcap-based tap support. Get the install files:


cd ~/emulators/netbsd-1.3.2
while read a; do curl -O $a; done << EOF
https://ftp.netbsd.org/pub/NetBSD/NetBSD-archive/NetBSD-1.3.2/vax/installation/tapeimage/tk50-file1-132
https://ftp.netbsd.org/pub/NetBSD/NetBSD-archive/NetBSD-1.3.2/vax/installation/tapeimage/tk50-file2-132
https://ftp.netbsd.org/pub/NetBSD/NetBSD-archive/NetBSD-1.3.2/vax/binary/sets/base.tgz
https://ftp.netbsd.org/pub/NetBSD/NetBSD-archive/NetBSD-1.3.2/vax/binary/sets/etc.tgz
https://ftp.netbsd.org/pub/NetBSD/NetBSD-archive/NetBSD-1.3.2/vax/binary/sets/comp.tgz
https://ftp.netbsd.org/pub/NetBSD/NetBSD-archive/NetBSD-1.3.2/vax/binary/sets/man.tgz
https://ftp.netbsd.org/pub/NetBSD/NetBSD-archive/NetBSD-1.3.2/vax/binary/sets/misc.tgz
https://ftp.netbsd.org/pub/NetBSD/NetBSD-archive/NetBSD-1.3.2/vax/binary/sets/text.tgz
https://ftp.netbsd.org/pub/NetBSD/NetBSD-archive/NetBSD-1.3.2/vax/binary/sets/games.tgz
https://ftp.netbsd.org/pub/NetBSD/NetBSD-archive/NetBSD-1.3.2/vax/binary/kernel/gennetbsd.gz
https://ftp.netbsd.org/pub/NetBSD/NetBSD-archive/NetBSD-1.3.2/vax/installation/netboot/boot
EOF
gzip -d *gz
mv gennetbsd netbsd
tar cvf kernel.tar netbsd boot

Let's create a "thin-provisioned" (sparse) 1.5GB RA92 drive:
truncate -s 1500M rq0-ra92.dsk
Now let's create the configuration file. The OUI 08002b is actually from original DEQNA cards. You can use that or any other unicast. The physical address can be something random, but I like to embed some info in there for my reference. The second octet I use for the network, and the third for the VM on that network in order of installs.

cat > netbsd-boot.conf << EOF
load ka655x.bin

; CPU config
set CPU 128M
set CPU conhalt
set CPU IDLE=NETBSD

; NVRAM
attach NVR nvram.bin

; Disk drives
set RQ0 ra82
attach RQ0 rq0-ra92.dsk
set RQ1 dis
set RQ2 dis
set RQ3 dis

; printer
attach LPT printer-output.txt

; Tape
set TQ tk50
attach tq0 netbsd-132.tape
set TQ1 dis
set TQ2 dis
set TQ3 dis

; Disable unused peripherals
set CR dis
set RL dis
set TS dis

; Network config   : XQ:
set XQ enable
set XQ type=deqna
set XQ MAC=08-00-2b-00-02-03
attach XQ tap:tap14

set XQB enable
set XQB type=deqna
set XQB MAC=08-00-2b-00-03-03
attach XQB tap:tap15

; configure console to 7-bit only
set TTO 7b
set TTI 7b

; behavior on break
dep bdr 1

boot CPU
EOF
And add simple start script:
cat > start.sh << EOF
~/emulators/bin/simh-4.0-vax netbsd-boot.conf
EOF
chmod +x start.sh
Now, let's create the tape. I disliked the mkdisttap.pl so I wrote my own. Download mk-dist-tape.py.

mk-dist-tape.py tk50-file1-132:512 tk50-file2-132:512 *.tar > netbsd-132.tape

Now start it:

$ ./start.sh 

MicroVAX 3900 simulator V4.0-0 Beta        git commit id: 35bfe17f
netbsd-boot.conf-4> attach NVR nvram.bin
NVR: buffering file in memory
libpcap version 1.6.2
Eth: opened OS device tap14
Eth: opened OS device tap15


KA655X-B V5.3, VMB 2.7
Performing normal system tests.
40..39..38..37..36..35..34..33..32..31..30..29..28..27..26..25..
24..23..22..21..20..19..18..17..16..15..14..13..12..11..10..09..
08..07..06..05..04..03..
Tests completed.
Loading system software.
No default boot device has been specified.

Available devices.
-DUA0 (RA82)
-MUA0 (TK50)
-XQA0 (08-00-2B-00-01-02)
-XQB0 (08-00-2B-00-02-01)

Device? [XQA0]: wombat

(BOOT/R5:0 WOMBAT



  2..
?41 DEVASSIGN, WOMBAT
?06 HLT INST
        PC = 00000C1A
Failure.
>>>
Anyone know how to make it not go to the boot device prompt if an ethernet NIC is present? How do I send a console break? Anyway, continuing:

>>>boot /3 mua0

(BOOT/R5:3 MUA0



  2..
-MUA0
  1..0..


howto 0x3, bdev 0x12, booting...done. (31448+22260)

>> NetBSD/vax boot [980530 13:32] <<
: edlabel
32372+1340+30624 start 0x0
With this program you can modify everything in the on-disk
disklabel. To do something useful you must know the exact
geometry of your disk, and have ideas about how you want
your partitions to be placed on disk. Some hints:
The a partition should be at least ~20000 blocks, the
b (swap) is depending on your use of the machine but it
should almost never be less than ~32000 blocks.

Disk geometry for most DEC disks can be found in the disktab
file, and disknames is listed in the installation notes.

Remember that disk names is given as disk(adapt, ctrl, disk, part)
when using the installation tools.

Label which disk? ra(0,0,0)
getdisklabel: no disk label
ra: no disk label
(E)dit, (S)how, (D)efaults, (W)rite, (Q)uit) : e

First set disk type. Valid types are:
0  unknown
1  SMD
2  MSCP
3  old DEC
4  SCSI
5  ESDI
6  ST506
7  HP-IB
8  HP-FL
9  type 9
10  floppy
11  ccd
12  vnd

Numeric disk type? [0] 2
Disk name? [] ra92
badsectoring? [n] 
ecc? [n] 
removable? [n] 
Interleave? [0] 1
rpm? [0] 3600
trackskew? [0] 
cylinderskew? [0] 
headswitch? [0] 
track-to-track? [0] 
drivedata 0? [0] 
drivedata 1? [0] 
drivedata 2? [0] 
drivedata 3? [0] 
drivedata 4? [0] 

bytes/sector? [512] 
sectors/track? [0] 69
tracks/cylinder? [0] 13
sectors/cylinder? [897] 897
cylinders? [0] 3279
a partition: offset? [0] 
             size? [0] 200000
b partition: offset? [0] 200000
             size? [0] 128000
c partition: offset? [0] 
             size? [0] 2941263
d partition: offset? [0] 328000
             size? [0] 572000
e partition: offset? [0] 900000
             size? [0] 2041263
f partition: offset? [0] 
             size? [0] 
g partition: offset? [0] 
             size? [0] 
h partition: offset? [0] 
             size? [0] 
(E)dit, (S)how, (D)efaults, (W)rite, (Q)uit) : s


disk type 2 (MSCP),  ra92: 
interleave 1, rpm 3600, trackskew 0, cylinderskew 0
headswitch 0, track-to-track 0, drivedata: 0 0 0 0 0

bytes/sector: 512
sectors/track: 69
tracks/cylinder: 13
sectors/cylinder: 897
cylinders: 3279

8 partitions:
     size   offset
a:   50000,    0
b:   131072,    50001
c:   2941263,    0
d:   50000,    181074
e:   2710188,    231075
f:   0,    0
g:   0,    0
h:   0,    0
Where'd these values come from? From /etc/disktab. But I cheated and wrote out a quickie script to parse those. Get it here: parse-disktab.py, along with a disktab for the vax. Here's a good one: https://github.com/sergev/4.4BSD-Lite2/blob/master/usr/src/etc/etc.vax/disktab.

Then run it like:

$ ./parse-disktab.py ~/disktab ra92
 === DEC RA92 Winchester ===
Numeric disk type? [0] 2
Disk name? [] ra92
badsectoring [n]
removable? [n]
Interleave? [0] 1
rpm? [0] 3600
trackskew? [0]
cylinderskew? [0]
headswitch? [0]
track-to-track? [0]
drivedata 0? [0]
drivedata 1? [0]
drivedata 2? [0]
drivedata 3? [0]
drivedata 4? [0]

bytes/sector? [0] 512
sectors/track? [0] 69
tracks/cylinder? [0] 13
sectors/cylinder? [0] 897
cylinders? [0] 3279
META INFO: 
    total blocks: 2941263
    size in KB: 1470631
    size in kibibytes: 1505926

Notes on partitioning: 
slice a is usually /
slice b is usually swap
slice c is always the full disk, with 0 offset, and the total sectors for the size
Now it's time to reboot an partition. I'm going to set the following partitions up:
SLICE (mountpoint)Blocks (MB)
Slice a (/) 200,000 (100M)
Slice b (SWAP) 128,000 (64M)
Slice c (WHOLE DISK)2941263 (1.4G)
Slice d (/usr)572,000 (236M)
Slice e (/home)2563263 (remainder, 800M)
Hit ctrl-D when it asks to label the next disk.
(E)dit, (S)how, (D)efaults, (W)rite, (Q)uit) : q
Label which disk? 

?06 HLT INST
        PC = 50492079
Restarting system software.
Failure.

Loading system software.

(BOOT/R5:0 WOMBAT



  2..
?41 DEVASSIGN, WOMBAT
?06 HLT INST
        PC = 00000C1A
Failure.
>>>boot /3 mua0

(BOOT/R5:3 MUA0



  2..
-MUA0
  1..0..


howto 0x3, bdev 0x12, booting...done. (31448+22260)

>> NetBSD/vax boot [980530 13:32] <<
: copy
31080+1148+22292 start 0x0

copy: 
This program will read miniroot from tape/floppy/disk 
and install this miniroot onto disk.


Specify the device to read from as xx(N,?), where
xx is the device-name, ? is file/partition number
and N is the unit-number, e.g.
"mt(0,1)" for the first TMSCP-tape (TK50),
"ra(2,0)" for the third MSCP-disk/floppy (RX33/RX50)

device to read from ? mt(0,1)

Specify number of blocks to transfer. Usually this is
sizeof(miniroot) / 512.
It's safe to transfer more blocks than just the miniroot.

number of blocks ? 4096

If your miniroot is split into volumes, then you must
specify the number of blocks per volume.
(e.g. 800 blocks per RX50, 2400 blocks per RX33)

number of blocks per volume ? [4096] 

Make sure unit mt(0,1) is online and holds the proper volume.
Then type 'g' to Go or 'a' to Abort.

OK to go on ? [g/a] g
Reading ... Reading of miniroot done. (4096 blocks read)


Now specify the device to write miniroot to as xx(N,1)
where xx is the drive type and N is the drive number.
For example: ra(0,1) refers to MSCP drive #0, b partition

Root disk ? : ra(0,0,1)
Initializing partition ... done.
(4096 blocks written.)

Halt the machine and reboot from distribution media,
giving second partition as part to mount as root. Ex:
: ra(0,1) for ra disk 0, hp(2,1) for massbuss disk 2

Halt/Reboot the machine NOW.

Infinite loop, PC: 00100488 (BRB 100488)
sim> 
Why did we use ra(0,0,1)? That's slice b, which will later be the swap partition. It won't be needed until a full boot, so it's a handy place for the miniroot.

>>>>boot /3 mua0

(BOOT/R5:3 MUA0



  2..
-MUA0
  1..0..


howto 0x3, bdev 0x12, booting...done. (31448+22260)

>> NetBSD/vax boot [980530 13:32] <<
: ra(0,1)netbsd
724992+38912+76744 start 0xa1ad8
[ netbsd symbol table not valid ]
Copyright (c) 1996, 1997, 1998
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 1.3.2 (GENERIC) #0: Sat May 30 12:55:49 CEST 1998
    ragge@subzero:/mnt/users/ragge/1.3/usr/src/sys/arch/vax/compile/GENERIC

realmem = 134103040
avail mem = 114902016
Using 6548 buffers containing 6705152 bytes of memory.
backplane0 (root)
cpu0 at backplane0: MicroVAX 3800/3900
cpu0: CVAX microcode rev 6 Firmware rev 83
uba0 at backplane0: Q22
mtc0 at uba0 csr 174500 vec 774 ipl 17
mscpbus0 at mtc0: version 5 model 3
mscpbus0: DMA burst size set to 4
mt0 at mscpbus0 drive 0: TK50
uda0 at uba0 csr 172150 vec 770 ipl 17
mscpbus1 at uda0: version 3 model 3
mscpbus1: DMA burst size set to 4
ra0 at mscpbus1 drive 0: RA92
ra1 at mscpbus1 drive 1: RA92
dz0 at uba0 csr 160100 vec 304 ipl 17
boot device: ra0
root device (default ra0b): ra0*
dump device (default ra0b): 
file system (default generic): 
root on ra0b dumps on ra0b
ra0: size 2941263 sectors
Clock has gained 146 days - CHECK AND RESET THE DATE.
root file system type: ffs
Enter pathname of shell or RETURN for sh: 
erase ^?, werase ^H, kill ^U, intr ^C

Now when NetBSD is booted you're on your own.
Remember to write bootblocks and to make devices
in dev in your new root filesystem before booting.
Also remember to copy /gennetbsd and /boot to the
new root; it's not there by default.

Good luck!

#

For some reason it didn't create tape devices in /dev, and the file system is read-only (and I can't remount it without an fstab or mtab). I'm going to work around that.

disklabel -B /dev/ra0
newfs /dev/rra0a
newfs /dev/rra0d
newfs /dev/rra0e
mount /dev/ra0a /mnt
mkdir /mnt/dev /mnt/usr /mnt/usr/local /mnt/home
mount /dev/ra0d /mnt/usr
mount /dev/ra0e /mnt/home
cp /dev/MAKEDEV /mnt/dev/
cd /mnt/dev
./MAKEDEV mt0 ra0 std pty0
ln -s nrmt0 nrst0
ln -s rmt0 rst0

(they're not really scsi tapes, but as long as you don't have scsi tapes, the above can make life simpler by not having to reference the MSCP tape directly, since tar defaults to scsi)

We have 8 tarballs on the tape on the third file of the tape. We need the raw (character) device file nrmt (as opposed to rmt, the block device). Fortunately, unlike 4.3BSD, all are referenced from /, so we can do this really easily with a loop:


cd /mnt
mt -f dev/nrmt0 rew
mt -f dev/nrmt0 fsf 2
for i in 1 2 3 4 5 6 7 8; do echo y | tar xvmf dev/nrmt0; mt -f dev/nrmt0 fsf; done
cat > /mnt/etc/fstab << EOF
/dev/ra0a     /             ffs  rw 1 1
/dev/ra0b     none          swap sw 0 0
/dev/ra0d     /usr          ffs  rw 1 2
/dev/ra0e     /home         ffs  rw 1 3
EOF

That's essentially it. We can go ahead and configure some things before rebooting. Doing a chroot into /mnt makes life more pleasant. On the console, I'd rather it treat me like a teletype for editing. We'll set up some basics and

chroot /mnt
unset TERM
/bin/ksh
export EDITOR=ex
echo netbsd13 > /etc/hostname
echo 192.168.102.12 netmask 255.255.255.0 > /etc/ifconfig.qe0
echo 192.168.102.12 netbsd13 >> /etc/hosts
echo 192.168.102.11 > /etc/mygate
echo nitfol.local > /etc/defaultdomain
halt
On reboot, change the boot to dua0. Because we left rc.conf unconfigured, it'll reboot into single user mode. Do 'mount -a' to get your other drives.

Other things to edit: /etc/ttys, make all the ttys "secure" (so you can log in as root). In vi or ex you can do that with:

:%s/network/network secure/
:x
Also, change root's shell to ksh:
# setenv EDITOR=ex
# chsh
Error: tigetnum: lines: Undefined error: 0
/etc/pw.00263a: unmodified: line 14
:%s/csh/ksh
Shell: /bin/ksh
:x
exit
I'm running rip everywhere, so you can set routed (or gateway) to start by changing the line in /etc/rc.conf 'routed=NO' to yes. If you want it to forward its routes, change the option -q to -s (requires sysctl -w net.inet.ip.forwarding=1). To boot into multiuser mode, set this line in rc.conf: 'rc_configured=YES' Optional: lots of source. We don't have curl or wget or even lynx, so I guess I'll need to do this by tape, from outside.

Back in Linux, let's make a tape, and uncompress them where we have some computational power:

mkdir src
cd src
for i in gnusrc pkgsrc sharesrc src syssrc; do curl -O https://ftp.netbsd.org/pub/NetBSD/NetBSD-archive/NetBSD-1.3.2/source/sets/$i.tgz; done
gzip -d *gz
mk-dist-tape.py -o src-tape.tape *tar
And in simh:
sim> at tq0 src/src-tape.tape
sim> go

# mt rew
# for i in 1 2 3 4 5; do tar xv; mt fsf; done
I'm going leave off anything else for now.