raspberry-pi-virtualbox

Emulating Raspberry Pi on a Virtual Machine with VirtualBox

  • 2 min

In this post, we are going to see how to emulate a Raspberry Pi with Raspbian in a virtual machine using Oracle VM VirtualBox.

Emulating a Raspberry Pi in a virtual machine can be useful, for example, to perform tests without having a physical Raspberry Pi available, or to experiment in a controlled environment before deploying it on the real machine.

It should also be said that, although in recent times virtualizing a Raspberry Pi has become much simpler (before it was an almost impossible mission) with the release of Raspberry Pi Desktop, the image still has limitations compared to having a real Raspberry Pi running.

In any case, it is very simple and doesn’t take up much hard drive space, so if you are going to work frequently with Raspberry Pi, it is useful to have a virtual machine on your computer for testing and experiments.

Create the Virtual Machine

First, download and install the latest version of Virtual Box from https://www.virtualbox.org/

On the other hand, download the latest version of Raspberry Pi Desktop from https://www.raspberrypi.org/downloads/raspberry-pi-desktop/.

raspberry-pi-virtual-box-1

Launch Virtual Box and add a new machine.

raspberry-pi-virtual-box-2

Give your machine a name, for example “RaspberryPi”, and select type “Linux”, version “Other Linux”.

raspberry-pi-virtual-box-3

Increase the memory size to 512 Mb.

raspberry-pi-virtual-box-4

Now we need to create a virtual hard disk, where the machine’s files will be stored. Choose “Create a new virtual hard disk”.

raspberry-pi-virtual-box-5

Leave the default hard disk type.

raspberry-pi-virtual-box-6

Now we choose whether we want the size to be dynamically allocated or fixed size.

  • If it is dynamically allocated, the virtual hard disk file will only have the size of the space actually occupied in the virtual machine. But in return, performance will be lower when it has to expand the size.
  • If we choose fixed size, performance will be higher, but the virtual hard disk file will always occupy the maximum size of the virtual hard disk.

We can choose dynamically allocated.

raspberry-pi-virtual-box-7

Choose a name for the virtual hard disk file, for example “RaspberryPi”, and for size choose between 8Gb - 16Gb. In general, 8Gb will be more than enough.

raspberry-pi-virtual-box-8

Our virtual machine is now created. Now, double-click to start it.

Installing Raspberry Pi Desktop

The first time we boot, we will be asked to insert an image as a Virtual CD for OS installation. We choose the image we downloaded in the first step.

raspberry-pi-virtual-box-9

Choose “Graphic install” and follow the installer steps, leaving the default options it offers.

raspberry-pi-virtual-box-10

At the end of the process, our virtual machine with Raspberry Pi will start, and we are ready to start playing and experimenting with it.

raspberry-pi-virtual-box-12