Setup an OpenBSD SPARC64 VM in QEMU

Last modification on

This describes how to setup an OpenBSD SPARC64 VM in QEMU.

Create a disk image

To create a 5GB disk image:

qemu-img create -f qcow2 fs.qcow2 5G

Install

In this guide we'll use the installation ISO to install OpenBSD. Make sure to download the latest (stable) OpenBSD ISO, for example install62.iso.

  • Change -boot c to -boot d to boot from the CD-ROM and do a clean install.
  • Change -cdrom install62.iso to the location of your ISO file.
  • When the install is done type: halt -p
  • Change -boot d back to -boot c.

Start the VM:

#!/bin/sh
LC_ALL=C QEMU_AUDIO_DRV=none \
qemu-system-sparc64 \
	-machine sun4u,usb=off \
	-realtime mlock=off \
	-smp 1,sockets=1,cores=1,threads=1 \
	-rtc base=utc \
	-m 1024 \
	-boot c \
	-drive file=fs.qcow2,if=none,id=drive-ide0-0-1,format=qcow2,cache=none \
	-cdrom install62.iso \
	-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-1,id=ide0-0-1 \
	-msg timestamp=on \
	-serial pty -nographic \
	-net nic,model=ne2k_pci -net user

The VM has the following properties:

  • No audio.
  • No USB.
  • No VGA graphics: serial console.
  • Netdev is ne0 (Realtek 8029).
  • 1024MB memory.

From your host connect to the serial device indicated by QEMU, for example:

(qemu) 2017-11-19T15:14:20.884312Z qemu-system-sparc64: -serial pty: char device redirected to /dev/ttyp0 (label serial0)

Then you can use the serial terminal emulator cu to attach:

cu -l /dev/ttyp0

Another option could be using the simple terminal(st) from suckless.

st -l /dev/ttyp0

using cu to detach the cu(1) man page says:

Typed characters are normally transmitted directly to the remote machine (which
does the echoing as well).  A tilde ('~') appearing as the first character of a
line is an escape signal; the following are recognized:

    ~^D or ~.  Drop the connection and exit.  Only the connection is
               the login session is not terminated.

On boot you have to type:

root device: wd0a
for swap use the default (wd0b) Press enter

Initial settings on first boot (optional)

Automatic network configuration using DHCP

echo "dhcp" > /etc/hostname.ne0

To bring up the interface (will be automatic on the next boot):

sh /etc/netstart

Add a mirror to /etc/installurl for package installation. Make sure to lookup the most efficient/nearby mirror site on the OpenBSD mirror page.

echo "https://ftp.hostserver.de/pub/OpenBSD" > /etc/installurl