1

I have a Raspberry Pi 4b, with 4GB of RAM. I would like to run a Virtual Machine with other Raspberry Pi operating systems as Guest (Ubuntu MATE, LibreELEC, possibly RISC OS).

I tried using AQEMU, with 512MB RAM allocated, a qcow2 drive image assigned, a .img ubuntu image assigned as boot drive, & TCG acceleration selected instead of KVM (TCG offers ARM hardware emulation, KVM did not), but got an error:

KVM Kernel Module Not Loaded!
To load this Module, Enter in Terminal with root privileges: "modprobe kvm-intel". Or If Use AMD Processor: "modprobe kvm-amd".

Commands sudo modprobe kvm-intel & kvm-amd both fail (I'm on ARM), & my searches have returned next to nothing, so I haven't gotten any farther trying to emulate a Pi on my Pi yet.

Is it even possible to run a Pi OS in a VM on a Pi 4? If so, how?

6
  • 7 days & zero responses... Should I make my question less specific, like "How would one emulate an ARM guest an a Raspberry Pi 4b host?" Sep 15 '20 at 8:39
  • I assume that no one of the experienced users are very interested doing what you asked. 1. lack of performance of Raspberry Pis to manage virtual machines. It is annoying slow. Maybe usable with a RPi 4B? No one have tried it so far. You could be the first one. 2. No need to use virtual machines, RasPis are cheep devices. 3. Even your "specific" question is to broad. You can use KVM, Container (LXC, Docker, systemd-container with systemd-nspawn), chroot and so on.
    – Ingo
    Sep 15 '20 at 12:40
  • Container solutions are usable but what solution should we suggest? One may work with Ubuntu MATE but not with RISC OS. And the software running in a container must be compiled for the ARM processor.
    – Ingo
    Sep 15 '20 at 12:46
  • Can I use KVM? I have found guides for running emulation on a Pi 3, & AQEMU has a template for a Pi 2 guest, but I haven't found any info at all on emulating ARM on Pi hosts, so I can't narrow that any. What container solution could you suggest for MATE? I can't get any ARM guest VM to run yet, so I'm asking for anything that'll work at all. Sep 16 '20 at 23:49
  • Sorry, I can't help further with this on a Raspberry Pi. I have no experience with it (no interest doing it).
    – Ingo
    Sep 17 '20 at 11:32
1

Since nobody answers, I'll post my half solution here, but before that, I'd like to ask you in foreword: please if you find a better solution then mine, don't forget to post it, because I'm having a hard time figuring out this topic too.


First of all, I got to ask if you enabled the 64 bit on raspbian. If not, it can be done by

sudo nano /boot/config.txt

Go to the very end of the file and add this line:

arm_64bit=1

then reboot.

You can find more information about what you just did here. Maybe it's not related but it's worth a try and might solve your issue.


If you're still stuck, here it goes how I solved my similar issue on my raspi4, but I'd be happier if I could solve it more straightforward:

I had virtual machines (I could even run three of them, although didn't run anything on them. The biggest load I think was when I had two machines, one with a minecraft server running and the other some small tasks like bittorrent, a webserver and maybe some other small things.) on a headless rpi4 with 4 gigs of ram and a minimal (xorg) 64bit ubuntu on it (the one which the rpi-imager also includes among the "other OS" section). So I can tell that probably it's possible what you're trying to do. I didn't dare to put graphical desktops neither on the host or the client. What I did was installing cockpit on it by

sudo apt-get install cockpit

It uses kvm, although I didn't manage to figure out what commands this interface executes. point is, that with cockpit you get a web interface to your server where you can install VM-s. If I remember well it automatically started the webserver which could be reached on the 9090 port through a webbrowser.
More about cockpit here

The setup for installation is quite comfortable (automatically grabs the selected image and basically just point and click), the catch though is that at the installation process the serial console is quite buggy I did debian installs, when the TUI fell apart or seemed to be not respondend, I moved around with the arrow keys and blindly hit enter. It's not too bad though, 90% of the time TUI stayed together. You also gotta be patient, I remember the first time I did it, I almost gave up because it takes for a while for the console to wake up. So wait, and if you got unpatient play around with the arrow key, that might bring the console to life.

3
  • I don't believe that there are better answers. The Raspberry Pi simply isn't made for running virtual machines. Your are trying to "make a car flying".
    – Ingo
    Jan 29 at 19:33
  • Nothing except VPS are "made" for running VMs but VMs are made for running on a cornucopia of platforms. Cell phones aren't made to run virtual machines either, but they do it quite well. Virtualization eats a lot of RAM, but otherwise, the overhead can be quite manageable, especially if the "bare metal" host machine's hardware supports the features of the emulated hardware. Running Pi2 tasks on a Pi4 should not at all be too resource intensive; it simply isn't working in the first place. This question is not a matter of the Pi being incapable (plenty of resources!) it's how can it be done Mar 1 at 20:13
  • arm_64bit=1 is true, thanks for pointing that out, as it's potentially critical. I've never come up with a use case where my Pi would be as convenient to use headless (I usually use a Pi where there is no other viable machine, needing another machine just to access it would be counter-effective.), so I have no experience at all using a serial port terminal interface, since the '90s. The notes on the console not always showing up are much appreciated. This question had no answers for so long I've repurposed my Pi4 but I'll try to look into it & see if we can arrive at an answer. Thanks again! Mar 1 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.