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  \
    -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:


Change your ip-addresses accordingly. The address 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 netmask 0xffffff00

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

Edit /etc/rc.conf

Add some lines to /etc/rc.conf:


Above the hostname is set to and the default gateway is 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:


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: 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

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.


NetBSD 5.0 on kvm on