Debian on an emulated SPARC machine


QEMU is a generic and open source processor emulator which can emulate i386, x86_64, MIPS, MIPSEL, PowerPC and SPARC systems. In case of SPARC it can emulate a SparcStation 5 or a SparcStation 10.

The Debian Etch distribution supports SparcStation 5 or a SparcStation 10 natively, including emulated ones. That makes a cheap development platform. The emulated system running on an Athlon 64 X2 3800+ is around the same speed as a SparcStation 5 with a 170MHz CPU, and possibly with much more RAM (my emulated system has 512MiB of RAM).

Please note that Debian dropped SPARC32 support with Lenny, and that QEMU doesn't support (yet) SPARC64 targets.

This howto has been written for a Debian host system, but could be easily adapted for other distributions.

Alternatively prebuilt images are also available.

Installing QEMU

QEMU is currently available as a package in the Debian distribution, you will need at least version 0.9.1. If you want to compile it yourself, here is the procedure:


To build QEMU a few packages like SDL needs to be installed on your system. gcc version 3.4 is also needed, as some parts of QEMU do not build with newer gcc versions. As QEMU is present in the archive, just run:

$ su -c "apt-get build-dep qemu"

Then run the configure script:

$ cd qemu-0.9.1
$ ./configure

Then compile it:

$ make

And install it on your system:

$ su -c "make install"

Preparing the installation

First you need to create an image of the hard disk. In my case I have chosen to emulate a 10GB hard-disk, but this size could be changed to correspond to your needs. Note that the file is created in qcow format, so that only the non-empty sectors will be written in the file.

A small tip: create a directory to hold all the files related to the emulated SPARC machine.

$ qemu-img create -f qcow hda.img 10G

It is necessary to have a SPARC kernel image to pass to QEMU and an initrd image of the Etch Debian-Installer.

$ wget

Installing Debian Etch

To start the installation process, use the following line:

$ qemu-system-sparc -hda hda.img -cdrom debian-40r3-sparc-netinst.iso -boot d

After a few seconds you should see OpenBIOS booting the CD-ROM. At the prompt, just press enter.

OpenBIOS booting the CD-ROM

You should then see the kernel booting:

Debian-Installer booting

And then the first screen of the Debian-Installer:

First screen of Debian-Installer

Proceed exacty as with a normal installation. If you need some documentation, please refer to the Debian installation guide.

At the end of the installation. Congratulations!

End of the installation

Using the system

First boot

To start the system use the following command:

$ qemu-system-sparc -hda sparc.img

After a few seconds the system should give you a login prompt. Enjoy your new SPARC platform:

Console login

More RAM

By default QEMU emulate a machine with 128MiB of RAM. You can use the -m option to increase or decrease the size of the RAM. It is however limited to 256MiB. If you want to use more RAM (up to 2047MiB), switch the machine to a SparcStation 10 machine (-M SS-10).

Connect your emulated machine to a real network

When no option is specified QEMU uses a non priviledged user mode network stack that gives the emulated machine access to the world. But you probably want to make your emulated machine accessible from the outside. It is possible by using the tap mode and bridging the tap interface with the network interface of the host machine.

The first thing to do is to active a bridge on your host machine. For that you have to modify the /etc/network/interfaces file as follow:

auto eth0
iface eth0 inet dhcp

auto br0
iface br0 inet dhcp
  bridge_ports eth0
  bridge_maxwait 0

Then you need to install the bridge-utils package and restart your network interface:

# apt-get install bridge-utils
# ifdown eth0
# ifup br0

Create a script call /etc/qemu-ifup that will be executed upon the start of QEMU:

echo "Executing /etc/qemu-ifup"
echo "Bringing up $1 for bridged mode..."
sudo /sbin/ifconfig $1 promisc up
echo "Adding $1 to br0..."
sudo /usr/sbin/brctl addif br0 $1
sleep 2

As you probably don't want to execute QEMU as root, you need to create a qemu user group and authorize the brctl and ifconfig commands for users of the qemu via sudo. You need to add the following lines to /etc/sudoers (edit the file using visudo):

Cmnd_Alias QEMU = /usr/sbin/brctl, /sbin/ifconfig

Finally you can start your emulated machine using the following command

$ qemu-system-sparc -hda hda.img -net nic,macaddr=00:16:3e:00:00:01 -net tap
You don't need to give a MAC address if you are emulating only one machine, as QEMU will use a default one. However if you have more than one emulated machine (don't forget QEMU can also emulate other architectures than SPARC), you will have to specify a unique MAC address for each machine. I advise you to select an address from the range 00:16:3e:xx:xx:xx, which has been assigned to Xen.

Other options

QEMU has a lot of other useful options. For a full list, please refer to the QEMU documentation.