# CubeOS in qemu

**URL:** <https://forum.ewelink.cc/t/cubeos-in-qemu/208409>\
**Category:** Share Your Project\
**Created:** [May 16, 2026, 9:57am UTC](https://forum.ewelink.cc/t/cubeos-in-qemu/208409 "2026-05-16T09:57:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jojkoba](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.ewelink.cc/jojkoba/32/8490_2.png) [@Jojkoba](https://forum.ewelink.cc/u/Jojkoba)\
**Post date:** [May 16, 2026, 9:57am UTC](https://forum.ewelink.cc/t/cubeos-in-qemu/208409/1 "2026-05-16T09:57:35Z")

</div>

#!/bin/bash

# Script to install eWeLink CUBE OS in QEMU for Raspberry Pi 5

# Configuration: 2GB RAM, native aarch64 KVM acceleration, auto-start on boot

set -e

# 1. Install required dependencies

echo “[\*] Updating packages and installing QEMU dependencies…”  
sudo apt update  
sudo apt install -y qemu-system-arm qemu-utils wget xz-utils curl

# 2. Create the working directory

WORKDIR=“/opt/cubeos\_qemu”  
sudo mkdir -p “$WORKDIR”  
sudo chown -R $USER:$USER “$WORKDIR”  
cd “$WORKDIR”

# 3. Fetch the latest CUBE OS image download link from GitHub Releases

echo “[\*] Fetching the latest CUBE OS release URL…”  
LATEST\_URL=$(curl -s [https://github.com](https://github.com) | grep “browser\_download\_url” | grep “raspberrypi” | head -n 1 | cut -d ‘"’ -f 4)

if [-z “$LATEST\_URL”]; then

# Fallback URL if GitHub API rate limit is exceeded

LATEST\_URL=“[https://github.com](https://github.com)”  
fi

IMG\_XZ=$(basename “$LATEST\_URL”)  
IMG\_RAW=“${IMG\_XZ%.xz}”

# 4. Download and extract the image

if [! -f “$IMG\_RAW”]; then  
echo “[_] Downloading CUBE OS…"  
wget -O “$IMG\_XZ” “$LATEST\_URL”  
echo "[_] Extracting image file…”  
unxz “$IMG\_XZ”  
else  
echo “[+] Image file $IMG\_RAW already exists. Skipping download.”  
fi

# 5. Prepare UEFI firmware for ARM64 (Required for QEMU -M virt)

if [! -f “QEMU\_EFI.fd”]; then  
echo “[_] Setting up UEFI firmware…"  
if [-f “/usr/share/AAVMF/AAVMF\_CODE.fd”]; then  
cp /usr/share/AAVMF/AAVMF\_CODE.fd QEMU\_EFI.fd  
elif [-f “/usr/share/qemu-efi-aarch64/QEMU\_EFI.fd”]; then  
cp /usr/share/qemu-efi-aarch64/QEMU\_EFI.fd QEMU\_EFI.fd  
else  
echo "[_] Downloading fallback QEMU\_EFI.fd…”  
wget -O QEMU\_EFI.fd “[https://linaro.org](https://linaro.org)”  
fi  
fi

# 6. Resize the virtual disk by 10GB to provide storage for Docker add-ons

if [! -f “.disk\_resized”]; then  
echo “[\*] Resizing virtual disk…”  
qemu-img resize “$IMG\_RAW” +10G  
touch .disk\_resized  
fi

# 7. Generate the standalone execution script for QEMU (2GB RAM configuration)

echo “[\*] Generating launch script…”  
cat \<\< ‘EOF’ \> start\_vm.sh  
#!/bin/bash  
exec /usr/bin/qemu-system-aarch64  
-cpu host  
-enable-kvm  
-M virt  
-m 2048  
-smp 4  
-bios /opt/cubeos\_qemu/QEMU\_EFI.fd  
-device virtio-blk-device,drive=hd0  
-drive if=none,id=hd0,file=/opt/cubeos\_qemu/raspberrypi4\_64\_prod.img,format=raw  
-net dev,netdev=net0  
-netdev user,id=net0,hostfwd=tcp::8080-:80,hostfwd=tcp::8123-:8123  
-nographic  
EOF

chmod +x start\_vm.sh

# 8. Create and register the systemd service for persistent auto-start on reboot

echo “[\*] Creating systemd service for auto-start on boot…”  
sudo cat \<\< EOF \> /etc/systemd/system/cubeos.service  
[Unit]  
Description=Sonoff CubeOS QEMU Virtual Machine  
After=network.target

[Service]  
Type=simple  
User=$USER  
WorkingDirectory=/opt/cubeos\_qemu  
ExecStart=/opt/cubeos\_qemu/start\_vm.sh  
Restart=always  
RestartSec=10

[Install]  
WantedBy=multi-user.target  
EOF

# Reload systemd configuration and enable the service

sudo systemctl daemon-reload  
sudo systemctl enable cubeos.service

echo “[+] SETUP COMPLETE!”  
echo “[\*] Starting CUBE OS background service…”  
sudo systemctl start cubeos.service

echo “[+] Service is running. Access the web interface at http://YOUR\_RPI\_IP:8080”

---

<div class="post-metadata">

**Author:** ![eerke](https://avatars.discourse-cdn.com/v4/letter/e/eb9ed0/32.png) [@eerke](https://forum.ewelink.cc/u/eerke)\
**Post date:** [May 17, 2026, 12:57pm UTC](https://forum.ewelink.cc/t/cubeos-in-qemu/208409/2 "2026-05-17T12:57:43Z")

</div>

Genius idea. Guess they went for Virtual Box because it is cross platform and so a mini-PC with windows could run it. I use virtual machine manager but was wondering about adding another VM for Cube.  
Was thinking about doing it on my desktop computer which isn’t on all the time but a raspberry pi 5 is enough? I have a pi 5 4GB upstairs I rarely use and don’t run much on. If I understand the script you give the VM 2GB? 2GB left would be fine for the little I do I am pretty sure.

---

<div class="post-metadata">

**Author:** ![Jojkoba](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.ewelink.cc/jojkoba/32/8490_2.png) [@Jojkoba](https://forum.ewelink.cc/u/Jojkoba)\
**Post date:** [May 17, 2026, 6:43pm UTC](https://forum.ewelink.cc/t/cubeos-in-qemu/208409/4 "2026-05-17T18:43:49Z")

</div>

I tried HA in Docker and it ran smoothly. QEMU uses KVM, so it should perform better than Docker. I have a Raspberry Pi 5 with 4GB RAM where other services are running as well. I am using 1 GB RAM for CubeOS . Today, people want everything under one interface, which is why HA is so popular. First of all, until NSPP is fully local, I have to move in this direction. On Raspberry Pi, I can run Frigate, CubeOS, file sharing, torrents, and other specific requirements — the iHost cannot do that, even though I received several reasonable suggestions.

If I offer a device that can handle everything, customers are willing to pay extra. I had to create my own distribution for Raspberry Pi, where both I and the customer have service access. This is just another stage in expanding services. And unlike HA, CubeOS can even be operated by someone who is technically illite.

 ![1779043685193](https://europe1.discourse-cdn.com/flex005/uploads/ewelinkforum/original/2X/2/238f3f2d699bf6f7c29b28fe241e59d29ce38584.jpeg)
