box.matto.nl

home/

NetBSD 5.1 on kvm

Last edited
KVM is a great way to run virtual machines on your Linux box.
NetBSD can run very well on it.

Startup script

Some options are needed to get NetBSD to run without much problems. The scripts below sets those options. Because my kvm-server is headless (no keyboard an no monitor) I use vnc to do the remote install:

kvm -vnc 192.168.1.2:1  \
    -net nic,model=ne2k_pci,macaddr=00:16:3e:03:00:17 \
    -net tap,ifname=tap1,script=/etc/qemu-ifup-br0 \
    -m 1024 \
    -smp 1 \
    -no-acpi \
    -localtime \
    -tdf \
    -no-kvm-pit \
    -hda testnetbsd.img 
    -cdrom amd64cd-5.1.iso \
    -boot d

By using vnc the installation can be done remote. In this case by running the following command:

xtightvncviewer 192.168.1.2:1

Change your ip-addresses accordingly. The address 192.168.1.2 belongs to the kvm-server (the machine that runs kvm).
Change the ip-addresses to your local network settings.

In the command shown here I choose amd64cd-5.1.iso as the installation medium. This gives a 64-bit i386 version of NetBSD.

After installation, do some basic setup, like adding a user and setting the network.

Setup network

Create /etc//ifconfig.ne0 with the following content:

up
192.168.1.228 netmask 0xffffff00

This gives the machine a static ip-address 192.168.1.228. Change this to your local network settings.

Edit /etc/rc.conf

Add some lines to /etc/rc.conf:

hostname="netbsd51.yourdomain.org"
defaultroute="192.168.1.254"
sshd="YES"

Above the hostname is set to netbsd51.yourdomain.org and the default gateway is 192.168.1.254. Change this to your local network settings. The last line starts sshd automagicly after boot.

Edit /etc/resolv.conf

Set the nameserver in your /etc/resolv.conf:

nameserver 192.168.1.254

Change this to your local network settings.

Update the host-file

Edit /etc/hosts and add a line containing the ip-address of your box and its hostname:

192.168.1.228   netbsd51.yourdomain.org netbsd51

Change /boot.cfg

You have to choose for a no acpi and no smp boot every time you want to boot NetBSD. This can be changed by changing the default boot-option. This can be done by editing /boot.cfg on you NetBSD virtual machine.:

Change the default from 1 to 4:

menu=Boot normally:boot netbsd
menu=Boot single user:boot netbsd -s
menu=Disable ACPI:boot netbsd -2
menu=Disable ACPI and SMP:boot netbsd -12
menu=Drop to boot prompt:prompt
default=4
timeout=5

Add a user

Add a user with a home-directory and add this user to the group wheel. By adding a user to the group wheel this user is able to do su. This makes it possible to remotely manage your system.

useradd -m -G wheel <username>
passwd <username>

Reboot and test that is works

Reboot and check that the default boot-option is with ACPI and SMP disabled and that the network is setup properly. Test that you can login over ssh.

Resources

NetBSD 5.0 on kvm on ghantoos.org