Published: 24.10.2020 | Edited: 22.12.2020 | Tags: qemu,arm

How to run latest Node on an emulated RevPi

sudo pacman -S qemu unzip qemu-arch-extra
  • Extract the image
unzip <revpi-image>.zip
  • Convert .img to .qcow2
qemu-img convert -f raw -O qcow2 <revpi-image>.img <revpi-image>.qcow2

Adjust the size of the image as needed

qemu-img resize <revpi-image>.qcow2 4GB
  • Boot it up with QEMU
sudo qemu-system-arm -kernel kernel-qemu-4.19.50-buster \
   -dtb versatile-pb-buster.dtb \
   -m 256 -cpu arm1176 \
   -machine versatilepb \
   -hda 2020-06-25-revpi-stretch.qcow2 \
   -append "root=/dev/sda2"

As a side note, versatilepb machine only allows for 256 MB of RAMqemu_arm

  • Remove the prompt for inserting serial numberkunbus_qemu
touch /home/pi/.revpi-factory-reset

You can learn more about the process by observing piserial package

dpkg -l piserial
  • Change the hostname
sudo hostnamectl set-hostname revpi
  • Edit /etc/hosts manually and and the hostname there       localhost
::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

# set local hostname here       revpi

Interacting with the guest

  • Back on the host, install virt-manager
sudo pacman -S virt-manager ebtables dnsmasq bridge-utils openbsd-netcat
  • Add yourseld to the necessary groups
sudo usermod -aG kvm,libvirt username
user = "username"
group = "kvm"
  • Define a default networkvirbr0
sudo virsh net-define /etc/libvirt/qemu/networks/default.xml
sudo virsh net-autostart default
sudo virsh net-start default

Check that the network virbr0 is present

brctl show # virbr0
  • Logout and log back in, then start the daemon
sudo systemctl start libvirtd.service
  • Create a domain file /tmp/revpi.xml, a courtesy of kim tinhbase
<domain type='qemu'>
  <memory unit='KiB'>262144</memory>
  <currentMemory unit='KiB'>262144</currentMemory>
    <type arch='armv6l' machine='versatilepb'>hvm</type>
    <kernel>/path/to/kernel-qemu-4.19.50-buster</kernel> <!--update path here-->
    <dtb>/path/to/versatile-pb-buster.dtb</dtb>          <!--update path here-->
    <boot dev='hd'/>
  <cpu mode='custom' match='exact' check='none'>
    <model fallback='forbid'>arm1176</model>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/path/to/.qcow2'/>                   <!--update path here-->
      <target dev='sda' bus='scsi'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    <controller type='pci' index='0' model='pci-root'/>
    <interface type='bridge'>
      <mac address='52:54:00:ed:eb:c7'/>
      <source bridge='virbr0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    <graphics type='spice' autoport='yes'>
      <listen type='address'/>
      <image compression='off'/>
      <gl enable='no' rendernode='/dev/dri/by-path/pci-0000:00:02.0-render'/>
      <model type='virtio' heads='1' primary='yes'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>

Change the path of kernel-qemu-4.19.50-buster, versatile-pb-buster.dtb and .qcow2 file to the correct absolute path

  • Create a new domain for RevPi
sudo virsh define /tmp/
  • Start the domain
sudo virsh start revpi
  • Make sure the avahi-daemon is started
sudo systemctl start avahi-daemon
  • Copy ssh credentials over, the password is raspberry
ssh-copy-id pi@revpi.local
  • Interact with the emulated image
ssh pi@revpi.local

Installing latest Node

The guest has node 10.19.0 present via RevPi backportskunbus_release_full

node -v # 10.19.0

Check the architecture

uname -m # armv6l

Emulated arm1176 CPU is unfortunately an armv6l architecture, which is not officially supported by node

curl -o- | bash

Make sure that installation was successful

command -v nvm
  • nvm does not support armv6l either, use unofficial nvm mirror nvm_unof
NVM_NODEJS_ORG_MIRROR= nvm install 14.9


Further read