Virtualized Raspian OS with Virtualbox

This post walks you through the process of installing the Raspberry Pi OS, Raspbian, with VirtualBox. I am going to use this at times to test my software running on the OS that the Raspberry Pi Cluster runs.

Why do I need a special version of Raspbian OS to work with Virtulbox

The Raspbian OS that you install on your SD card for the Raspberry Pi’s has been compiled to work with ARM CPU’s. This is because the Raspberry Pi’s run an ARM CPU as its primary hardware.

Since Virdoesn’tx doesnt support this ARM CPU it is unable to run the standard Raspbian OS. Due to a large amount of requests the Raspberry Pi Foundation recently created an x86 architecture of the Raspbian image that you can run on your PC. This also lets us emulate it using Virtualbox (or other x86 emulation productions).

Therefore the first step to installing and running Raspberry Pi on your computer is downloading the Raspberry Pi Desktop edition ISO.

Raspberry Pi Desktop

Using the above link you can download the ISO which you can then use to install.

Installing Raspbian on Virtualbox

I have chosen Virtualbox to run Raspbian OS on as it is available for both Linux and Windows. Once the image has downloaded we are ready to create our virtual machine.

Creating the Virtual machine

To create the virtual machine you can press “New” in the virtualbox interface. This will open the first screen shown below. Here I have named the machine “Raspbian Bunker Master” which will be used to refer to the machine. Selecting the version of Linux will pre-fill settings in the later screens. Since Raspbian is built upon a Debian install I have selected Debian (32-bit).

Adding RAM to the virtual machine

The next screen asks you the amount of RAM you want to allocate to the virtual machine. Here I am going to give it 1 Gigabyte of RAM to work similarly to the Raspberry Pi 3.

Choosing the type of Virtual Hard Disk to use

The next screens allow us to add a virtual hard drive to the machine. This will work like the SD card in the Raspberry Pi. Here I will create a new virtual hard drive.

Then it asks me what type of image disk I want to use. Since I am going to be using it with Virtulbox it is fine to keep it in VDI (VirtualBox Disk Image).

Now it asks me how I want the virtual hard drive to behave. Here I select a dynamic drive which means the size of the file will expand as it is used. However this will only expand to the maximum size set in the next step. The virtual machine will still think it has the full size when installing.

In this step I choose where I want to save the virtual hard drive to and what size it will be. If you have chosen a dynamic virtual disk type it will expand to this value. If the virtual disk is a fixed type it will be created the maximum size to start with.

Once this has been done the virtual machine has been created.

Turning on PAE

When I was initially running Raspbian I found that it required PAE to be turned on to be able to function. This needs to be enabled in the “Processor” section of the virtual machine. So before installing the OS we need to turn this on. This can be done by selecting the settings menu of the virtual machine. In this options page you need to “System”, then go to the “Processor” tab. This will have a checkbox for “Enable PAE/NX”. Checking this will allow you to run and install Raspbian.

Installing Raspbian OS on the virtual machine

Once the virtual machine has been created you can launch the VM. This will prompt you to insert an ISO into the virtual machine. Here I selected the Raspbian OS I downloaded earlier.

From here I select the command line based install, selecting these options in order

  1. Select Install
  2. Choose language as British English
  3. Select “Guided, use entire disk and LVM” partition install option
  4. Select the main partition to install the OS to, /dev/sda
  5. Choose to “Put all files on one partition”
  6. Confirm all partition changes
  7. Finish the partitioning and confirm writing partitions to disk
  8. Install GRUB, since this is the first OS we need a bootloader
  9. Choose /dev/sda1 as the boot partition
  10. Finish the installation

Once this has been done the live CD will be removed and the machine will reboot.

Now we have a virtual machine that can replicate the Raspbian OS that will run on the Raspberry Pi. I will use this for some testing when using a Raspberry Pi isn’t feasible.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.