Virtualizing a Raspberry Pi with QEMU (2023)

A while ago I wrote about building oneframefor a Raspberry Pi cluster. If you have a shelf, at some point you will want to put some pees on it. Virtualization can make the process of mapping those Pis relatively easy. You can generate custom images from the comfort of your desktop and even automate the entire process. Here's a quick crash course in virtualizing the Pi with QEMU.

All the guides I could find on this were at least a few years old and were missing several key parts of the process. None of them fully worked out of the box. It's hard to blame them though, as a hardware platform like the Pi is, of course, a moving target. For what it's worth, this guide should be complete and current as of October 2016.

The first thing to do is get a base disk image to work with. It shouldn't make much of a difference what you choose (unless you're going for something absurd and masochistic likeArch-Linux). For this guide I useRaspbian Lite. My focus will be on emulating images that are compatible with the Pi 2, although I don't see why they wouldn't work on the Pi 3 as well.

Once you've chosen a distro, download or torrent an .iso file for it. Once you have that, you're good to go. I like to start by making a working copy of this .iso file right away so that if I make a mistake, I can throw it away and start over with a fresh copy without having to download the image again.

mkdir -p ~/workspace/raspberry
cp ~/Downloads/2016-09-23-raspbian-jessie-lite.img ~/workspace/raspberry/raspbian.img

raspbian.imgwill serve as our base image. If you ever want to copy the current state of the virtualized Pi to an SD card, you can do so withddof this file.

(Video) Creating a virtual 64-bit Raspberry PI 3B with Qemu in 2023

We need a custom kernel for QEMU to boot this Pi image. For nowthis github repositoryit keeps the current kernel files available for this purpose. Source code and a build script are included if you're interested.

cd ~/workspace
cp qemu-rpi-kernel/kernel-qemu-4.4.13-jessie himbeere/kernel-qemu

We now have everything we need to boot the Pi, but if we do, there will be a kernel panic and a kernel dump. This is not OK. If you want to see this, you can copy the qemu command below, but be warned: it's not very exciting. What we're going to do now is fix some configuration files so we can get everything working.

Before applying these fixes, we must be able to mount the root partition of the Pi image. There is a hard way and an easy way to do this. The hard way is to read the partition table from the image, multiply one of the fields by 512, and make a giant "mount" call. The easy way is this:

cd ~/workspace/raspberry
sudo kpartx -va raspbian.img
# Make a note of the name of the loop device chosen by kpartx, then...
sudo mount /dev/mapper/loop0p2 /mnt # assuming kpartx chose loop0

kpartx does all the work for us, reading the image's partition table and creating loop devices for its partitions. The first is the boot partition of the Pi and the second is the root file system. So after this operation, we have the root filesystem of the Pi mounted at /mnt. No mess, no stress!

(Video) How to virtualise a Raspberry PI using qemu in linux and or unRAID

Well, this is what we have to change. edit first/mnt/etc/ comment out the first and only line by prepending a#a:


This prevents a kernel panic. I have no idea why.

Next, create a new file:/mnt/etc/udev/rules.d/90-qemu.rules
and add the following lines:

NUCLEO=="sda", SYMLINK+="mmcblk0"
NUCLEO=="sda?", SYMLINK+="mmcblk0p%n",

These are necessary because (/mnt)/etc/fstabspecifies partitions under/dev/mmcblk0for critical parts of the file system. That would make sense for Raspbian under normal circumstances, since it boots from an SD card, but since we're exposing our disk image to the system as/dev/sda, we need to add these assignments if we want to make everyone happy. Of course you could also edit/etc/fstabconcretizesdaInstead ofmmcblk0, but that would break the compatibility between the image and the real Pis.

(Video) Emulating ARM64 Raspberry Pi Image using QEMU

These two fixes should be enough to get Raspbian to boot clean. Optionally, if you want to use SSH to access the Pi from the host machine, you can also configure this by disabling password login (which is good anyway) and adding your public key to "authorized_keys". Of course, if you don't already have a public key, you'll need to run itrsa-keygenFirst. After,

echo "Password authentication failed" >> /mnt/etc/ssh/sshd_config
mkdir -p /mnt/home/pi/.ssh
gato ~/.ssh/ >> /mnt/home/pi/.ssh/autorizadas_claves

And you're ready to go. This disables password authentication but grants passwordless access to anyone with your private key.

you should hang out too/mntin this point:
sudo amount /mnt
This may not be strictly necessary, but given that, it seems like common sense./mntit will be mounted from a partition in the image file, which we'll give to QEMU in a moment. Leaving a partition mounted and using it with QEMU at the same time risks corrupting the file system under certain circumstances.

Now is the time: we are really going to start our virtual Pi! Here is the call:

qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M vielseitigpb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1"-hda raspbian.img-redir tcp:5022::22

(Video) Como simular Raspbian OS (Raspberry Pi) en QEMU para WINDOWS 11 & 10

theaobjectived work to bootstillLogin request.The default login is:
Username - Pi
NoSword - Raspberry
if you haven'tZobelPassword authentication for old SSH then sheshould change thisPassword as soon as you login.

For the sake of education, Ilet's breakthedifferent parts of herQEMUto callnorte:

  • Since Pi is an ARM system, of course you callQEMUARMemulator.
  • we had itThe kernel image thatreceived fromGithub before.
  • We indicate the CPUmodel as arm1176, and we give the device 256I am fromRAM.
  • Whatwe-type ARM boardspecify asVersatilePB.
  • -without rebootit is necessary becausewithout it,Run commands likesshutdown of udo -hnowin the guestin fact it would not closeunder thevirtual systemStengelbutI would restart it instead. I'm not sure why.
  • We specify- The series-ptdioto allowstandard/standard inputoutsideIt is used for a serial connection. EastAs far as I know it's not absolutely'swidespread in eExamples and would be cMediumYou areuseful for scripted interactions with the guest operating system.
  • -AppeNorth Dakotaallows us to pass kernel parameters athe guest.We specifythe"Disk" partition should be mounted as root, and we tell himthe systemReboot after 1 second into kernel panic. You can replace this jokeh is a larger integerawait longer, get stuck with 0 in panic,or with a negative numberfenceKernel panics cause an immediate reboot.
  • Of course, we also indicate our working copy of Raspbianyowizard fileas THe-System'sprimary disk.
  • finally weadjusted toSet up port forwarding so we can connect from the host via SSH.Port 5022 on the hostwill be redirectedPort 22 on the Pi. that leavesTu ssh aSpentfrom the host like this: ssh -p 5022 pi@localhost

If you want to copy your configured Pi image to an SD card, you can simply plug the card in and use itdmesgto find the name of your block device (we assume here that it is a/dev/mmcblk0) and then write to this block device from the image filedd:

sudo dd if=raspbian.img of=/dev/mmcblk0 bs=4M status=progress

And once this is complete, your SD card should be done! Note that you'll probably want to expand the filesystem once you're done writing to the Pi, since the maximum size of the SD card is likely to be a bit larger than this disk image. In Raspbian it is theraspi-configUtility offers a help tool for this.

So that's enough to use QEMU to virtualize a Raspberry Pi and create custom SD card images! If you have anything to add, you can leave a comment below.

(Video) [arm64] emulate raspberry pi with qemu


Can QEMU emulate a Raspberry Pi? ›

Running qemu for the Raspberry PI 3 hardware

It will boot using the Raspberry PI 3 kernel provided by the kernel8. img file and will have a few boot options that configure the console and the root drive which for a Raspberry PI is the eMMC device located at /dev/mmcblk0p2 .

Can QEMU emulate Raspberry Pi 4? ›

But qemu cannot have definitions for all the existing machines and brands, and for example the Raspberry PI 4 is missing.

How to use QEMU for Raspbian? ›

  1. Open up a Command Prompt.
  2. Change directory to the folder containing the kernel and image files e.g. D:/Temp/raspbian.
  3. Type in the command: D:\> run_raspbian.bat. The QEMU window appears running Raspbian OS.
Sep 9, 2019

Can you virtualize a Raspberry Pi? ›

In fact, there is a Raspberry Pi OS Desktop version just for that! And even better, you can install Raspberry Pi OS Desktop directly on a virtual machine. This will allow you to do some experiments and test Raspberry Pi OS, directly from your computer (on Windows, Linux, or Mac).

Can QEMU provide virtualization? ›

QEMU is a machine emulator that can run operating systems and programs for one machine on a different machine. However, it is more often used as a virtualiser in collaboration with KVM kernel components. In that case it uses the hardware virtualisation technology to virtualise guests.

What systems can QEMU emulate? ›

QEMU can boot many guest operating systems, including Linux, Solaris, Microsoft Windows, DOS, and BSD; it supports emulating several instruction sets, including x86, MIPS, 32-bit ARMv7, ARMv8, PowerPC, SPARC, ETRAX CRIS and MicroBlaze. KVM Hosting. Here QEMU deals with the setting up and migration of KVM images.

Can QEMU emulate hardware? ›

Admins looking for an alternative tool for emulating hardware should consider QEMU, which supports x86, PowerPC, ARM and SPARC architectures. QEMU is an open source emulator and virtualization tool that specializes in emulating different CPU architectures.

Is QEMU like VirtualBox? ›

Features: QEMU is both an emulator and hypervisor. VirtualBox is just a hypervisor. Apart from this, their feature set mostly boils down to the various architectures and operating systems that both support, but we have already covered all of that in the above sections.

Can QEMU run without KVM? ›

Qemu without KVM is incredibly slow. User Mode Linux has not been ported to arm! It only works with x86 at the moment.

How do I run a VM with QEMU? ›

Create the test VM. Create a boot script from the QEMU command.
Once again, I'll guide you through the steps.
  1. Step 1: Locate the QEMU log file on your virtualization host. ...
  2. Step 2: Copy lines from the log file to your new script. ...
  3. Step 3: Create the shell script. ...
  4. Step 4: Run the VM using your newly created script.
Mar 6, 2020

Does QEMU have a GUI? ›

Qemu-gui allows record executions and replay it. Execution is a scenario of work system inside qemu. Execution includes all user and network interaction, interrupts, timers and other. You can replay one scenario many times and make analysis if you need.

How to use QEMU on Windows for Raspberry Pi? ›

Emulate a Raspberry Pi on Windows With QEMU
  1. Browse to the download folder.
  2. Unzip to your HDD (use C:/QEMU)
  3. Open the QEMU subfolder.
  4. Double-click bat to get started.
  5. A virtualized Raspberry Pi will appear, with Raspbian Wheezy booting up.
  6. Wait while this completes---it should progress as illustrated in this video.
Nov 5, 2020

Which virtualization is best for Raspberry Pi? ›

VMWare ESXi has been the industry standard for deploying and managing Virtual Machines on Servers using VMWare. Now it also has an ARM Version by the name of ARM-Fling, and since Raspberry Pi runs on ARM it's the best combination to use to set up your mini-portable Virtualisation Server.

How do you simulate Raspberry Pi on PC? ›

To emulate Raspberry Pi, download the Windows version of VMWare and install it by running the executable (.exe) file. After successfully installing the program, create a new virtual machine and open the Raspbian iso file to initiate the Raspberry Pi emulator.

Can a Raspberry Pi run VirtualBox? ›

Bottom line, VirtualBox won't run on a Raspberry Pi or on your phone.

Is QEMU better than KVM? ›

This means that KVM uses the hardware virtualization capabilities of the host machine's CPU to run virtual machines, while QEMU relies on software emulation to run virtual machines. As a result, KVM tends to be more efficient and performant than QEMU but is also more hardware-dependent.

Which is faster QEMU or VirtualBox? ›

VirtualBox is faster and has a better UI than QEMU. It's also a good choice only for x86 and x64 architectures. Lastly, VirtualBox doesn't require advanced knowledge or experience.

Is QEMU KVM faster than VirtualBox? ›

KVM, a type 1 hypervisor, is smaller and faster than VirtualBox, but VirtualBox is more scalable. KVM is better integrated with Linux, and while it will work with other guests, it works best with Linux. In short, if you want to install a binary Linux distribution as a guest, it's better to use KVM.

What is the difference between QEMU virtualization and emulation? ›

The Main Difference Between Virtualization and Emulation

In virtualization, you can directly access the hardware. The main difference between the virtual machine and emulator is that the virtual machine runs code directly with a different set of domains in use language. The basic emulation requires an interpreter.

What is the maximum QEMU ARM CPU? ›

The maximum vector length supported by qemu is 2048 bits.

Can you run Windows 10 in QEMU? ›

Initial setup

Open up the Virtual Machine Manager and click on the upper left button to open the New VM window. The first thing you have to do is to select how you would like to install the operating system. In this case, we are using a Windows 10 ISO image. Click forward and choose the Windows 10 ISO you downloaded.

Does QEMU use UEFI? ›

UEFI for x86 QEMU/KVM VMs is called OVMF (Open Virtual Machine Firmware). It comes from EDK2 (EFI Development Kit), which is the UEFI reference implementation.

Does QEMU use BIOS or UEFI? ›

Most Qemu software runs BIOS (Legacy) initialization software. In many cases, a user may want to run Qemu with UEFI instead of BIOS. Additionally, a user may prefer run Qemu in command line or graphically with Aqemu.

What hypervisor does QEMU use? ›

QEMU, short for Quick Emulator – is a type-2 hypervisor that emulates a machine's processor through dynamic binary translation. Despite QEMU having the ability to run on its own and emulate all virtual machine resources, all emulation is performed in-software.

What is the difference between KVM and QEMU? ›

So to conclude: QEMU is a type 2 hypervisor that runs within user space and performs virtual hardware emulation, whereas KVM is a type 1 hypervisor that runs in kernel space, that allows a user space program access to the hardware virtualization features of various processors.

Can QEMU emulate Windows? ›

Windows can run fine under QEMU and KVM, but since installing it with QEMU or libvirt directly is not very straightforward, most people prefer using other hypervisors which have a fancy GUI.

Why is VMware so much better than VirtualBox? ›

VMware provides 3D graphics with DirectX 10 and OpenGL 3.3 support for all of its products. Video memory, incase of VirtualBox, is limited to 128 MB. Video memory, incase of VMware, is limited to 2 GB. To support 3D graphics in VirtualBox, you must manually enable 3D acceleration on the virtual machine.

What is the default RAM for QEMU? ›

RAM. -m MEMORY - Specify the amount of memory (default: 128 MB).

Why do we need QEMU with KVM? ›

QEMU can make use of KVM when running a target architecture that is the same as the host architecture. For instance, when running qemu-system-x86 on an x86 compatible processor, you can take advantage of the KVM acceleration - giving you benefit for your host and your guest system.

What is the difference between VM and KVM? ›

Cost is a key differentiator between KVM and the VMware virtualization solutions. KVM is distributed as part of many open source operating systems, so there isn't an additional cost. With VMware, you will need to purchase licenses for various products and will be locked into an enterprise license agreement (ELA).

Does QEMU use Hyper V? ›

QEMU disk image utility for Windows. It is used for converting, creating, and consistency checking of various virtual disk formats. It is compatible with Hyper-V, KVM, VMware, VirtualBox, and Xen virtualization solutions.

What does QEMU stand for? ›

Share to Facebook Share to Twitter. Definition(s): A software module that is a component of the hypervisor platform that supports full virtualization by providing emulation of various hardware devices.

Is QEMU easy to use? ›

QEMU is a fast processor emulator using dynamic translation to achieve good emulation speed. It is a free open-source alternative to VMware. As QEMU requires no host kernel patches to run, it is very safe and easy to use.

Can QEMU run VMWare image? ›

KVM/QEMU will directly support a VMWare VMDK image. Unzip the Foswiki VMWare image to a local directory. The following shell script will launch the image with a user mode networking interface.

Is QEMU a docker? ›

Multi-architecture support

With support for Apple M1 ARM Mac and QEMU included in Docker Desktop, you are able to build and use multi-architecture images (Linux x86, ARM, Windows) on whatever platform you are working on out of the box.

Can QEMU emulate arm? ›

QEMU can emulate both 32-bit and 64-bit Arm CPUs. Use the qemu-system-aarch64 executable to simulate a 64-bit Arm machine.

How do I emulate a Raspbian OS in QEMU Windows 10? ›

Raspberry Pi Emulator for Windows 10
  1. Step 2: Download QEMU. Go to ...
  2. Step 3: Download the Kernel. Go to ...
  3. Step 4: Download Raspbian. Go to ...
  4. Step 5: Set Up the Emulator. ...
  5. Step 6: Optimize the Emulator.

Where can I simulate my Raspberry Pi? ›

That's where a Raspberry Pi simulator comes in.
Here are four of your best options.
  • Microsoft Azure. ...
  • Wokwi. ...
  • Wyliodrin Studio. ...
  • Lab Center's Visual Designer.
Dec 30, 2022

Can I run a Windows VM on a Raspberry Pi? ›

A cursory glance at Windows 11's system requirements show that it is simply too big to run on a Raspberry Pi. Incredibly, however, it can be done. Thanks to a tool called WoR-flasher, you can now install Windows 10 and 11 on a Raspberry Pi 4.

What is the most powerful Raspberry Pi model? ›

Raspberry Pi 400 Personal Computer Kit

Featuring a quad-core 64-bit processor, 4GB of RAM, wireless networking, dual-display output, and 4K video playback, as well as a 40-pin GPIO header, it's the most powerful and easy-to-use Raspberry Pi computer yet.

What is more powerful than a Raspberry Pi? ›

About: Banana Pi, a dual-core, Android 4.2 product, is better than Raspberry Pi in various aspects. Banana Pi M3 is a single-board computer (SBC) with an Octa-core processor and 2GB RAM. There are several other versions of Banana Pi, such as Banana pi M+, Banana pi Pro, etc.

Is Raspberry Pi powerful enough for Web server? ›

A Raspberry Pi makes excellent sense as an inexpensive and power-efficient way to host websites and web applications over a local network. It's a great testbed or development environment where you have full access right up to the metal.

Can I power Raspberry Pi from my PC? ›

Powering using a micro-usb cable

Another way to power the Raspberry Pi is with a micro-usb cable connected to a usb port on a laptop. Note that there are different types of usb connectors. The Raspberry Pi uses a micro-usb connector. You can also directly power it with an AC adapter.

Can you control a Raspberry Pi from a computer? ›

You can connect to your Raspberry Pi remotely using Remote Desktop in Windows 10.

Can you run Raspberry Pi OS on PC? ›

Debian with Raspberry Pi Desktop is our operating system for PC and Mac. It provides the Raspberry Pi OS desktop, as well as most of the recommended software that comes with Raspberry Pi OS, for any PC or Apple Mac computer.

How to create a Raspberry Pi virtual machine? ›

How to run Raspberry Pi Desktop on Windows or macOS
  1. Step 1: Download and install VirtualBox. ...
  2. Step 2: Download Debian with Raspberry Pi Desktop. ...
  3. Step 3: Launch VirtualBox and create a new virtual machine. ...
  4. Step 4: Install Raspberry Pi Desktop. ...
  5. Step 5: Make the virtual machine interactive. ...
  6. Step 6: Set up a shared folder.

Can Raspberry Pi run Windows EXE? ›

Installing Windows Application on Raspberry Pi

Now, to install an application on Raspberry Pi, you will first need to download a Windows application in “.exe” format. In our case, we are going to download the VLC media player as an example for you to learn how you can install Windows applications.

Is there going to be a Raspberry Pi 5? ›

That being said, Raspberry Pi CEO Mr. Eben Upton has made it clear that the Raspberry Pi 5 won't be coming until 2024. As announced in a recent blog post, 100,000 units will enter the supply chain, and in the second half of 2023, we can expect inventory levels to return to pandemic norms.

Can VirtualBox emulate Raspberry Pi? ›

VirtualBox will install the Raspberry Pi Desktop OS to the virtual disk, meaning you will no longer need to have the disk installed.

What emulators are available for Raspberry Pi? ›

  • The Best Raspberry Pi Emulators. Considerations. ...
  • The Best Raspberry Pi Emulators. RetroArch. ...
  • The Best Raspberry Pi Emulators. Lakka. ...
  • The Best Raspberry Pi Emulators. Batocera. ...
  • The Best Raspberry Pi Emulators. RecalBox. ...
  • The Best Raspberry Pi Emulators. RetroPie. ...
  • The Best Raspberry Pi Emulators. ...
  • The Best Raspberry Pi Emulators.

Is QEMU same as KVM? ›

Unlike native QEMU, which uses emulation, KVM is a special operating mode of QEMU that uses CPU extensions (HVM) for virtualization via a kernel module. Using KVM, one can run multiple virtual machines running unmodified GNU/Linux, Windows, or any other operating system. (See Guest Support Status for more information.)

What is the best way to emulate Raspberry Pi? ›

To emulate Raspberry Pi, download the Windows version of VMWare and install it by running the executable (.exe) file. After successfully installing the program, create a new virtual machine and open the Raspbian iso file to initiate the Raspberry Pi emulator.

Can QEMU run in VirtualBox? ›

A: VirtualBox makes use of QEMU in two ways: first of all, some of our virtual hardware devices have their origin in the QEMU project. We have found them to be very useful and took them as a starting point.

Does VirtualBox support QEMU? ›

As discussed earlier, QEMU can be used for emulation and virtualization, however, VirtualBox can be used for virtualization only. QEMU comes with dual support of emulation and virtualization whereas the latter provides only virtualization features.

Does NASA use Raspberry Pi? ›

GASPACS (Get Away Special Passive Attitude Control Satellite) CubeSat is a NASA-sponsored mini-satellite project built by students from Utah State University (USU). The team behind it think it's the first satellite to use Raspberry Pi Zero as its flight computer.

Which software is most useful for Raspberry Pi? ›

Your Raspberry Pi needs an operating system to work. This is it. Raspberry Pi OS (previously called Raspbian) is our official supported operating system.

Is VirtualBox better than QEMU? ›

VirtualBox is faster and has a better UI than QEMU. It's also a good choice only for x86 and x64 architectures. Lastly, VirtualBox doesn't require advanced knowledge or experience.

Which is better VirtualBox or QEMU? ›

Compatibility: Although both can be used across different operating systems, VirtualBox is the much better choice if you want to port virtual machines across systems like Windows, Linux, and MacOS. For hardware compatibility, QEMU will work much better with Linux, as it is closely integrated with KVM.


1. Emulating a Raspberry with QEMU
(Andrea Manzi)
2. Resize Raspberry Pi image and emulate with QEMU
(Kai Hu)
3. Raspberry Pi Emulator for Windows 10 Full Setup Tutorial and Speed Optimization
4. Virtualiza un Raspberry PI 4 con QEMU
(La cueva del ultimo dragon Last Dragon)
5. Emulating ARM with Virt-Manager QEMU | Linux Guide
6. An emulated Raspberry Pi on QEMU/Linux
(Hans Bezemer)
Top Articles
Latest Posts
Article information

Author: Aracelis Kilback

Last Updated: 02/08/2023

Views: 6643

Rating: 4.3 / 5 (44 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Aracelis Kilback

Birthday: 1994-11-22

Address: Apt. 895 30151 Green Plain, Lake Mariela, RI 98141

Phone: +5992291857476

Job: Legal Officer

Hobby: LARPing, role-playing games, Slacklining, Reading, Inline skating, Brazilian jiu-jitsu, Dance

Introduction: My name is Aracelis Kilback, I am a nice, gentle, agreeable, joyous, attractive, combative, gifted person who loves writing and wants to share my knowledge and understanding with you.