run raspberry pi os in virtual machine

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 run Raspberry Pi Desktop on a virtual machine. 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. As it’s currently pretty tough to get a Raspberry Pi board at a decent price (check my tips here), it might be a good temporary solution.

If you’re looking to quickly progress on Raspberry Pi, you can check out my e-book here. It’s a 30-day challenge where you learn one new thing every day until you become a Raspberry Pi expert. The first third of the book teaches you the basics, but the following chapters include projects you can try on your own.

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 is a .img format, which won’t work on VirtualBox. Looking for this image, I came across many forums that said it wasn’t possible to emulate a Raspberry Pi on a PC because it turns on ARM architecture, unlike a PC…

Finally, I ended up finding the image, directly on the official website, just below the main download options. 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.

Option 1: Use VirtualBox to run Raspberry Pi OS on a PC

Introduction

VirtualBox is an open-source hypervisor, developed by Oracle. It is available for most operating systems: Windows, Linux, macOS, Solaris, etc…

It allows you to create virtual machines on your computer and supports many operating systems to virtualize.

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, and fill the form:
  • Choose a Name, storage location and pick the ISO image you just downloaded.
  • I skip the unattended installation, as it’s not the original Debian image, but maybe it works (not tested). I prefer using the full installation wizard manually.
  • You can then adjust the CPU and memory settings if needed (I kept the default values, but 1GB is enough):
  • Finally, set the storage size (16 GB is a decent minimum):
  • And click “Finish” on the summary to create the virtual machine.

Our new virtual machine is available :

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

  • Click on Start in the top bar.
  • A window 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:

Choose the settings that best suit you.
Create the first user and password.
Update your system and reboot one last time.

Download the Pi Glossary!
If you are lost in all these new words and abbreviations, request my free Raspberry Pi glossary here (PDF format)!
Download now

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.

Option 2: 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 the virtual machine’s speed. QEMU is available for Linux, macOS, and Windows.

I’ll give you the short version here, but I have a full tutorial on how to run Raspberry Pi OS in QEMU here.

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:

sudo apt 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

If you need more details, I have a complete guide on how to install QEMU on Ubuntu. And even if you are not using Ubuntu, it’s similar on most distributions, so it should be useful.

Are you a bit lost in the Linux command line? Check this article first for the most important commands to remember and a free downloadable cheat sheet so you can have the commands at your fingertips.

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 by following this link. Then start the .exe file and follow the instructions.

Create the virtual machine

QEMU is a command line tool. But if you have a desktop environment, I highly recommend installing Virtual Machine Manager, which is a GUI you can use with QEMU.
On Linux, it’s available in the default repository:
sudo apt install virt-manager

On Windows, you can try QtEmu, but you are probably better off using VirtualBox (previous option) or VMWare (next option), that are better suited for this.

In Virtual Machine Manager, click on the “+” icon to create a new virtual machine, and follow the steps in the wizard:

  • On the first step, select local install media (as we already downloaded RPI OS):
  • Then pick the image file from your Downloads folder:

    You need to pick the operating system manually (I chose Debian 11), the auto-detect doesn’t work with Raspberry Pi OS.
  • After that, follow the final steps to configure the virtual machine according to your needs and resources available (storage, RAM, CPU, etc.).

Once the virtual machine created, you can start it from the interface, and you’ll get the same menu as with VirtualBox:

Follow these instructions to get Raspberry Pi OS installed on the virtual machine:

  • 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).
  • The 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 starts with the first boot wizard:

As with any Raspberry Pi OS installation, follow the steps to complete the initial configuration:

  • Choose the settings that best suit you.
  • Create the default user and password.
  • Update your system and reboot one last time.

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

Download the Pi Glossary!
If you are lost in all these new words and abbreviations, request my free Raspberry Pi glossary here (PDF format)!
Download now

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).

In command line, you can do something similar by using a line like this:
qemu-system-x86_64 -hda IMAGE.iso -m 1024 -net nic -net user

Option 3: Run Raspberry Pi OS on PC with VMWare 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.

I’ll show you the short version here, but I have a full tutorial on how to run Raspberry Pi OS on VMWare Workstation on this site. Check it you for the details.

Installation

You can download VMWare Workstation Player on the official website. There is a Linux and Windows versions, 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 11, for example.
  • Name your virtual machine and change the 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 if needed.
  • 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 the first boot.

  • Choose the settings that best suit you.
  • Create the user and password you’ll use.
  • 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, etc.), 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 the 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 detail 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 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 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+ is enough for most projects). 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.

💰 Make Money Sharing Your Raspberry Pi Expertise!
Help others navigate the world of Raspberry Pi with your insights.
Become a RaspberryTips Contributor!

Snapshots

Obviously, who says a 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 understanding everything here, or if you prefer the video version, here is a demonstration of how to do this with VirtualBox and VMWare:

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

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now

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.
Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now

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

Reminder: Remember that all the members of my community get access to this website without ads, exclusive courses and much more. You can become part of this community for as little as $5 per month & get all the benefits immediately.

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!

By the way, you can now use a Raspberry Pi as a cheap hypervisor, with solutions like VMWare ESXI or by installing Proxmox on your Raspberry Pi.

Whenever you’re ready, here are other ways I can help you:

The RaspberryTips Community: If you want to hang out with me and other Raspberry Pi fans, you can join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.

Master your Raspberry Pi in 30 days: 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 multiple projects with step-by-step guides.

The Raspberry Pi Bootcamp: Understand everything about the Raspberry Pi, stop searching for help all the time, and finally enjoy completing your projects.

Master Python on Raspberry Pi: Create, understand, and improve any Python script for your Raspberry Pi. Learn the essentials step-by-step without losing time understanding useless concepts.

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

Similar Posts

13 Comments

  1. Hi I have a question about these set ups. Are any of them able to save the exact image to an SD card that can then be put into the RPi and booted headless. Thus allowing me to set the RPi OS how I like using my virtual machine and then later run headless once I have it set up?

    1. Hi,

      Thanks for your comment

      I don’t think it’s possible, but I never tried this
      Maybe someone else will help you

      1. VmWare or VBox uses less resources than original board, many things you dont need to install as it automatically picks from your physical machine hardware drivers etc, So accordingly, its not possible that you just do copy and paste the stuff and it starts works.

        Hardware should now be upgraded to Plug and Play for ease, or preinstalled and allow to change it later.

        regards

    2. The method presented by Raspberry Tips uses a version of Raspberry Pi desktop compiled for x86 PC. It allows you to experience GUI and maybe do some development for this environment but you cannot produce binary images for running on real Raspberry Pi hardware, which vastly differs from x86 PC. However, you can create scripts and other platform-independent code, which can be later ported to real Raspberry Pi image.

      To create a bootable SD card for Raspberry Pi you need an emulator capable of running ARM code, with GPU, network and all other hardware Raspberry Pi has. Currently limited options seem to exist for QEMU KVM (Linux) using qemu-system-arm package. The package delivers code to emulate about 30 different hardware boards. Unfortunately, I do not see “raspi2” on the list and haven’t checked similarities for “versatilepb” board which can be used instead, according to some manuals.

      I think you should consider use of real Raspberry Pi for preparing the SD image you need. SD card can be easily swapped, removed, copied, backed up on typical SD card reader. You can use x86 Linux machine (physical or virtual) to “open” Raspberry Pi SD card image, make changes you need (without running it) and close for use on real Raspberry Pi. If your target system needs to be headless, you can configure system initially with monitor (basic options, IP and user account config), then use SSH to perform further actions. Also:

      – you can use built-in serial port for configuration/management. Requires some setup and knowledge in electronics, because voltage levels are not typical for RS-232 use case and it is posible to fry your Raspberry Pi in this way,
      – older models (1, 2) have Composite Video output which can be programmed to use instead of HDMI. This allows use of analog (TV) monitors as console or for some other output.

      Initial Raspbian configuration can be done with text editor directly on partition containing /boot filesystem. This is VFAT partition, easily recognized by Windows on SD card connected via reader.

      HTH.

      1. Depends,

        Python is an interpreted language, so, it is not dependent of the operation system, only the right packages versions and own python version.
        Even java is possible to run, i think, since it depends on the JVM and not the processor architecture.

        Different from compiled file in C or C++ binary, which is really compiled for a certain architecture.

  2. I have Raspbian desktop running on a vbox, I don’t have winzip or an actual Pi to test so I can’t say this could work. But if you already have a boot and partition on your SD for your Pi you could try to copy and paste from the vmdk directly into your SD. It will be interesting to check once I get my Pi, or even from vm to vm. I’m Sorry if this doesn’t answer the question.

  3. Hi, what about 3D graphics hardware acceleration: any chance to get GPU passthrough working with AMD e.g. Vega64 or RX?

  4. My codesys is not able to communicate to raspberry pi on a vmware virtual machine . In codesys .. tools .. updatr pi , it not able to detect the vm pi . What to do. But putty can loginto the vm through ssh.

  5. I have just tried to boot a VirtualBox virtual Rasberry Pi Desktop machine on Raspberry Pi micro SD through USB and it does not work (whereas it works on the real Raspberry Pi) so I can confirm the negative answer of Edwin to Nicholas and thank both for the explanation. Raspberry Pi Desktop is not Raspbian!

  6. Thanks for this. It worked pretty well, minus one issue (that I’ve run into), since this doesn’t appear to actually be Raspbian, I can’t update some software.
    Specifically, Sonic Pi is stuck at version 2.10, which is the highest “reasonable to install” version regular linux seems to have, which ended up defeating my purpose, since I’m running Ubuntu and already hit a wall with upgrading that software. Is there some other trick for getting it to think it’s the right environment to update Sonic Pi?

  7. Thanks for the article. I was able to install raspbian buster on vmware workstation up to 2019-09-25-rpd-x86-buster.iso. When I tried to setup a vm using the new 2020-02-12-rpd-x86-buster.iso, the vm always gives me blank screen after installation has completed. Going through the vmware.log didn’t help much. I’ve got similar result when I tried to set up thenew ubuntu 20.04 LTS on vmware. It won’t start up after installation. However 16.04 LTS was installed fine. Could it be only 32bit linux system can be run on vmware?

  8. Ok, the installation work, i have installed the os on virtual box oracle, but the shared notes (ctrl-c, ctrl-v) copy and paste doesn’t work, i chose bidirectional shared.
    It’s annoyng typing from host and guest. Thanks you. Bye

Comments are closed.