3 Ways to Run Raspberry Pi Desktop on a Virtual Machine


Most of the tutorials on this website are here to help you solve a specific problem on the Raspberry Pi.
But for once, we won’t do anything on the Raspberry Pi directly. Instead, we will learn how to do without: I will show you how to run Raspberry Pi OS in a virtual machine on Windows, macOS or Linux.

VirtualBox, VMWare and QEMU are three solutions to virtualize a Raspberry Pi.
These emulators can run Raspberry Pi OS on a standard PC running Windows, Linux or macOS.

And here we’ll learn how to do it with these three tools, from your favorite operating system.

These software programs can be very useful if you are a developer, you don’t have your Raspberry Pi with you, or you want to test something without breaking your installation on the SD card.
By the way, you can get a complete Raspberry Pi kit for under $30 (this one for example), so make sure the virtual machine solution is really the best one for you.

Download Raspberry Pi OS for PC

I think this is probably the main problem you’ve encountered: where to find an image compatible with the main hypervisors?

The default image offered on the official website, which is an .img format, which can’t work on VirtualBox for example.
Looking for this image, I came across many forums that said it was not possible to emulate a Raspberry Pi on PC because it turns on ARM architecture, unlike a PC …

And finally, I ended up finding the image, directly on the official website, just above the main download.
So you can download the image of Raspberry Pi OS in ISO format before continuing this guide.
I advise you to use a Torrent client to download it, as it’s much faster.

Use VirtualBox to run Raspberry Pi OS on PC

Introduction

VirtualBox is an open-source hypervisor, developed by Oracle.
It is available for most operating systems: Windows, Linux, macOS, Solaris, …
It allows you to create virtual machines on your computer and supports many operating systems to virtualize.

Raspberry Pi Bootcamp
Sale: 10% off today.
Take it to the next level.
I'm here to help you get started on Raspberry Pi.
Learn all the skills you need in the correct order.

Installation

You can find download links for Windows, Mac, and Linux on this page: https://www.virtualbox.org/wiki/Downloads.

In any case, the installation is straightforward:

  • Download the installer corresponding to your environment.
  • Launch the installer and keep the default options.

Create the virtual machine

Launch Oracle VirtualBox now on your computer, and we will create the virtual machine:

  • Click on New in the top bar.
  • Choose a Name.
  • Type: Linux.
  • Version: Anyone.
  • Memory size: 1Gb is enough, but you can set more depending on your computer memory available.
  • Hard disk: You can keep the default options (8GB, dynamically allocated).

Our new virtual machine is available, but now you have to tell it to start on the previously downloaded iso file:

  • Click on Settings in the top bar.
  • Select Storage in the left menu.
  • Below the first controller, click on Empty.
  • On the right panel, click on the Disc icon to choose the file.
  • Select Choose a Disk File.
  • Browse to the location of the image and validate.

Ok, you should have something like this:

Now we can start the virtual machine and install the Raspberry Pi Desktop:

  • Click on Start in the top bar.
  • A windows shows up to select the start-up disk, click “Start” to confirm.
  • Choose Install in the first menu.
  • Select your Keyboard layout.
  • For partition disks, you can keep the default options (use entire disk > all files in one partition > finish > yes).
  • Installation starts.
  • After a few minutes, the installation wizard will resume.
  • Confirm the bootloader installation to the master boot record.
  • Select /dev/sda.
  • Continue to reboot your new operating system.

Once the reboot is done, you will come to a first start wizard like this one:

Raspberry Pi running in Virtualbox

Choose the settings that best suits you.
Change the default password.
Update your system and reboot one last time.

Your Raspberry Pi Desktop virtual machine running in VirtualBox is finally operational!
You can now check out my 27 tips to take a good start on this operating system if you need help configuring it.

Create a virtual machine running RPI OS in QEMU

Introduction

QEMU is another great open-source machine emulator and virtualizer, developed by Fabrice Bellard under GPL.
It can run many guest systems and it also can be used with KVM to increase virtual machines speed.
QEMU is available for Linux, macOS, and Windows.

Installation

The installation isn’t quite the same depending on your operating system, so I’ll briefly explain how to do this.

Linux installation:

For Debian/Ubuntu, QEMU is available in the repository so that you can install it with:

apt-get install qemu

For other distributions, it is usually available as easily via the basic commands:

RedHat/CentOS: yum install qemu-kvm
SUSE: zypper install qemu
Arch: pacman -S qemu

Mac OS installation:

QEMU is available via Homebrew or MacPorts.

HomeBrew:
brew install qemu

MacPorts:
port install qemu

Windows installation:

You can get the last installer version following this link.
Then start the .exe file and follow instructions.

Master your Raspberry Pi in 30 days
Sale: 10% off today.
Download the eBook.
Uncover the secrets of the Raspberry Pi in a 30 days challenge.
Learn useful Linux skills and practice multiples projects.

Create the virtual machine

QEMU is a command line tool.
So whatever your system you’ll have to do this :).
I give instructions for Linux; it may need to be slightly adapted if you are on another system.
In Windows, for example, you need to start the command prompt, and go to the QEMU directory (cd “C:\Program Files\qemu”).

First, create a folder for your VMs and move the image in it:

sudo mkdir ~/qemu/
mv ~/Downloads/IMAGE.iso ~/qemu/
cd ~/qemu

Now let’s launch the image in QEMU with the following command:

qemu-system-x86_64 -hda IMAGE.iso -m 1024 -net nic -net user
  • Choose Install in the first menu.
    You can choose “Graphical install”, but it’s just the same thing slower, so there is no need to do this 🙂
  • Select your Keyboard layout.
  • For partition disks, you can keep the default options (use entire disk > all files in one partition > finish > yes).
  • Installation will begin.
  • After a few minutes, the installation wizard will resume.
  • Confirm the bootloader installation to the master boot record.
  • Select /dev/sda.
  • Continue to reboot your new operating system.

Once the reboot is done, Raspberry Pi Desktop is starting:

Raspberry Pi in QEMU

A wizard will start on first boot.

  • Choose the settings that best suits you.
  • Change the default password.
  • Update your system and reboot one last time.

Your Raspberry Pi Desktop virtual machine running in QEMU is now operational!
You can now install any apps on it, like on a real Raspberry Pi (check my selection of the 17 best apps to install at the beginning here).

Run Raspberry Pi OS on PC with WMWare Workstation

Introduction

VMWare Workstation is a proprietary hypervisor distributed by VMWare, a subsidiary of Dell.
There is a free version, VMWare Workstation Player, for non-commercial use.
Workstation can emulate most operating systems.

VMWare also develops many other professional tools, which can allow you to use virtual machines on a large scale, but this is not the subject of the day :).

Installation

You can download VMWare Workstation Player on the official website.
There is a Linux and Windows version, but I’m not sure about macOS.

On Windows, just run the .exe file to start the setup.

On Linux, you have to start the wizard like this:
sudo sh VMware-Player-VERSION.x86_64.bundle

You can keep default options, and no key is needed for the moment.
On the first start, choose that you want to use Workstation Player for non-commercial use, and you are ready :).

(I had problems with Linux at first, I had to take a newer version than the one given on the site because the modules did not install. If this happens to you, now you’ll know what to do)

Create the virtual machine

We will now create our virtual machine:

  • Select “Create a New Virtual Machine”.
  • Choose “Use ISO image” and browse to your Raspberry Pi OS ISO file.
  • On the next screen, select Linux and Debian 64 bits, for example.
  • Name your virtual machine and change installation folder if you want.
  • For the disk space, you can let 20 GB or decrease it to 10 GB to save disk space on your computer.
  • Finally, click on Finish and Close.

Virtual Machine will start directly after the wizard ends:

  • Click on Start in the top bar.
  • Choose Install in the first menu.
  • Select your Keyboard layout.
  • For partition disks, you can keep the default options (use entire disk > all files in one partition > finish > yes).
  • Installation starts.
  • After a few minutes, the installation wizard resumes.
  • Confirm the bootloader installation to the master boot record.
  • Select /dev/sda.
  • Continue to reboot your new operating system.

You can choose to download and install VMWare Tools if you want, but it isn’t mandatory.

A wizard will start on first boot.

  • Choose the settings that best suits you.
  • Change the default password.
  • Update your system and reboot one last time.

Your Raspberry Pi Desktop virtual machine running in VMWare Workstation is now operational!

What to do next?

Once your virtual machine is installed, and no matter which hypervisor you choose, I invite you to follow the various tutorials on this website to set up the necessary software (ssh, vnc, …), as if you were on a Raspberry Pi.
Here are a few links to help you with this:

There are probably other things that are more dependent on the fact that your Raspberry Pi OS is on a virtual machine:

  • Network card: by default, I had network and Internet in these 3 installation cases, but depending on your environment, it might not work on first boot. Or maybe you will need the opposite: isolate the virtual machine of the network.
  • File sharing: it can be interesting to have a shared folder between your virtual machine and your computer (especially for developers, to work on your computer, and launch the application on the virtual machine).
  • Adjust the hardware: you may have to adjust the screen resolution, disk size or RAM to suit your needs.

I will not go into more details about all of this because it depends on your goals with this system.
But be aware that once Raspberry Pi is virtualized and functional, you can follow any tutorial on the chosen hypervisor to help you, it does not depend on Raspberry Pi OS most of the time.

Why do I need a virtual machine?

The following will depend on why you created this virtual machine, but I can give you some reasons why you might need a virtual machine.

Not (yet) a Raspberry Pi

If you do not have a Raspberry Pi, but you plan to buy one, testing its capabilities on a virtual machine might be a good idea.
This allows you to have a good vision of what you will be able to do. Maybe to test, install, or program the software that you would like to use, so you can make the purchase when you’re sure.

If it’s the only reason, I would consider a cheap Raspberry Pi board to get started quickly (a Zero kit or even the Pi 3B+ are really affordable right now on Amazon). This way, you would have a real overview :).

Moving

You are addicted to Raspberry Pi, but you can’t take it everywhere?
A virtual machine on your usual computer allows you to continue your projects, even without having the Raspberry Pi with you.

More powerful

Whether you’re a tester, developer, or just curious, running your Raspberry Pi desktop on a virtual machine will help you increase power and efficiency by taking advantage of your computer’s resources.
This can save you a lot of time on some applications, even if it’s less true with the new models like the Raspberry Pi 4 8GB.

Snapshots

Obviously, who says virtual machine says you can create snapshots.
A snapshot and a complete image of the virtual machine at a time T.
So it becomes possible to test something, and go back if it does not happen as expected (instead of having to recreate an SD card, reinstall everything needed, etc … if we work directly on the Raspberry Pi).

Video

If you need more help to understand everything here, or if you prefer the video version, here is a demonstration on how to do this wih VirtualBox and VMWare:

You can also subscribe to see all the news videos in your YouTube Feed:

Recommended stuff for taking it to the next level

  • Raspberry Pi 4: After your first tests in a virtual machine, you are now ready to switch to a real Raspberry Pi device. It’s really not the same, you won’t regret it!
  • Learn everything step by step: If you are afraid to get started for real, I have written a book on the topic, so it’s not that complicated! The promise is to master your first Raspberry Pi in 30 days, and it’s absolutely possible. Try it and let me know.
  • Start with the cheapest model: If your problem is the price, you can totally start with a minimal model just to see if it’s for you. If you are mainly doing this for basic things or programming, this model should be perfect.

Conclusion

So, we saw how to create a Raspberry Pi OS virtual machine on three different hypervisors:
– VirtualBox
– QEMU
– VMWare Workstation

We also saw what the benefits of virtualization could be when talking about Raspberry Pi.
It’s up to you now to launch your projects on this, good luck!

Raspberry Pi Resources

Not sure where to start?
Understand everything about the Raspberry Pi, stop searching for help all the time and finally enjoy completing your projects.
Watch the Raspberry Pi Bootcamp course now

Master your Raspberry Pi in 30 days
Don’t want the basic stuff only? If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiples projects with step-by-step guides.
Download the e-book

VIP Community
If you just want to hang out with me and show your support, you can also join the Patreon community. I share behind-the-scenes content there and give you early access to my content. You’ll also get a shoutout when you join.
More details here

You can also find all my recommendations for tools and hardware on this page.


This tutorial doesn't work anymore? Report the issue here, so that I can update it!


Patrick Fromaget

I'm the lead author and owner of RaspberryTips.com. My goal is to help you with your Raspberry Pi problems using detailed guides and tutorials. In real life, I'm a Linux system administrator with a web developer experience.

Recent Posts

Raspberry Pi Bootcamp - 10% off