How-to install Raspberry PI Desktop (Raspbian) on a VirtualBox VM

Installing Raspberry PI Desktop (Raspbian) on a Virtualbox VM is very easy and it allows to run some basic scripts on an emulated Raspberry PI board.

Installing Raspberry PI Desktop OS (also known as Raspbian) on a VirtualBox Virtual Machine (VM) is very useful to run and test some code without needing a real Raspberry PI.

The Raspberry PI Desktop includes an emulated Raspberry PI board that can be used to test some basic scripts and check the most common functionalities of this board.

In addition, using VM snapshots, it is really easy to save the state of the machine and revert all the changes done after that point. In this way, it is possible to run different experiments starting from the same virtual machine state. For additional information about snapshots, please check the official Oracle documentation.

Steps to install Raspberry PI Desktop on a VM

  1. In order to install VirtualBox from Oracle on your PC, you first need to download it from the official website.
    When the installation of VirtualBox is complete, then you can install any Operating System (OS) is needed.
    In particular, you can install Raspbian, a Linux OS deriving from Debian.
  2. Download the Raspberry PI Desktop ISO image from the official website.
  3. Launch VirtualBox.
  4. Create a new Linux Virtual Machine indicating Debian 64 bit as Operating System to use. In order to use the same amount of RAM available on a Raspbarry PI 3 (model B+), select 1GB of RAM. After this, when prompted for hard-disk type, select dynamic size and 8-10 GB of available space.
  5. When prompted, select “Graphical Install”.
  6. Setup Language and Keyboard layout.
  7. Choose your partitioning scheme. Choose the default one if you haven’t particular requirements.
  8. When prompted, select and install GRUB Bootloader (select /dev/sda).
  9. Wait until the VM boots into the Raspberry PI Desktop.
  10. When loaded, the OS will check for new updates. Please, wait until all updates have been downloaded and installed.

Install VM Guest Addon for Linux (Debian)

  1. From the menu, click on Devices > Insert Guest Additions.
  2. Open a terminal window and type the following command to install the VirtualBox Guest Additions for Linux Debian:
    sudo sh /media/cdrom0/
  3. In order to enable the shared folders, please type this command:
    sudo adduser pi vboxsf
  4. Add a shared folder to your VM: for example, a shared folder called “PC” pointing to any location to your host machine.
  5. When finished, please reboot typing:
    sudo reboot
debian - How-to tutorials
Press Enter to start Linux Debian with Raspberry PI Desktop
  1. When the OS has finished rebooting, you should have an environment similar to the following one:
Raspbian Desktop OS is ready
Raspbian Desktop OS is ready

On the Desktop, there will be two icons: the used Shared Folder (starting with “sf_” prefix) and the VM Guest Addons folder. If you open the Terminal, you can access both under the media folder; in other words, you need to type:

cd /media/

You can find both folders “cdrom0” and “sf_PC” (or another name, depending on your choice).

In order to eject the VM Guest Addons cdrom, you can also click on the “eject” button on the top-right of the Desktop.

Pietro L. Carotenuto
Pietro L. Carotenuto

C++ Software Engineer, Ph.D. in Information Engineering. I like reading and learning new things while working on new projects. Main author on looking for contributions and guest authors.

Articles: 26

Leave your feedback here:

Your email address will not be published. Required fields are marked *