Jump to content

Armbian the Virtual Machine


lanefu

Recommended Posts

Been dreaming of this one for a while.  Finally got a weekend to focus on it recently.  I'm hoping someone is eager to take what I've done and move It along some more.

Here's what we have so far.

* a linux 'family' called virtual.conf

* a kernel config called linux-virtual-current.config

* a board called virtual-qemu.wip

 

The result is a full HVM accelerated armbian image with a kernel compiled with all the virtio drivers for disk, network and video.   Also a u-boot.bin made for qemu that can boot the image when used as the qemu bios/firmware

 

I've ran it as a VM on ubuntu using plain qemu on a Ampere eMag box.. and using UTM (qemu) on Apple M1 in MacOS

this is using u-boot, not uEFI.. and you need to copy the u-boot.bin manually from cache/sources/u-boot...../u-boot.bin and use it as your chosen bios for qemu.  I left some quick breadcrumbs on how to launch within the board config file.

 

I want to keep the u-boot option, but obviously we need this to support uEFI booting to be viable for the masses.

Next steps:

* automatically resize and convert resulting image to qcow2 format

* solve how to add cloud-init to image

* solve for installing grubEFI for booting and whatever partition layout is needed

* figure a proper way to write uboot to the image so thet qemu can boot without loading as a bios

* strip extra hardware drivers out of kernel and make this thing lean


PS Did I mention Desktop Works too?
image.png
 

 

 

Edited by lanefu
qcow2 image now produced
Link to comment
Share on other sites

For those wondering Why?

Here's several possible reasons

 

  • because we can
  • better opportunities for automated testing of changes
  • faster manual testing
  • easier to test desktop builds (I actually hate flashing sdcard and having to touch hardware)
  • Broaden visibility of armbian as a platform for compute
Link to comment
Share on other sites

10 hours ago, why2 said:

@lanefu awesome work and well done! What can I do with the wip file?
I would like to try your work. Do you have any step-by-step guide to start the Armbian VM?


the WIP file is for building with the armbian build tools...  I have some crappy tips in there for qemu.

okay so here's a really quick n dirty 

 

download UTM for Mac 

Download zip and extract.  this UTM config https://armbian.lane-fu.com/virtual-qemu/Armbian UTM.zip there will be a .utm file and a u-boot.bin file

download one of the virtual-emu images from our nightlies or try whatever is here https://armbian.lane-fu.com/virtual-qemu/. don't forget to extra xz file

 

find utm and right click and choose show package contents(edited)

[8:15 PM]

image.png

then you'll expand and put this u-boot.bin in this subfolder

image.png

 

open the UTM file then clone it to a new virtual machine

 

edit the new virtual machine

image.png

 

goto the drives tab

image.png

click that little trash can to delete the previous image

click import drive to load the new image that you downloaded

and make sure you set the interface to virtio

because it will default to IDE

you'll need to fiddle around with display settings possibly.. the high dpi flag etc.

 

I think I've added to default on the newer images.  make sure spice-vdagent is installed.

 

..  this is all I can help with for now.  You're on your own from here :) Please turn this into some better documentation if you can.

ideally someone needs to figure out a process around this and document it 

 

Link to comment
Share on other sites

Am 19.7.2021 um 05:02 schrieb lanefu:

 

then you'll expand and put this u-boot.bin in this subfolder


Thanks @lanefu , I can mount UTM and see the Contents folder. However, the volume drive is mounted in read only mode, so that I can't copy u-boot.bin to the folder.
/Volumes/UTM/UTM.app on /private/var/folders/ns/bkcwhmm106j0_scbdvv_x29c0000gn/T/AppTranslocation/7DABB818-AE48-4EBF-9012-FF45CF3B9602 (nullfs, local, nodev, nosuid, read-only, noowners, quarantine, nobrowse, mounted by User). How can I mount the folder with read-write?

Link to comment
Share on other sites

4 hours ago, why2 said:

Thanks @lanefu , I can mount UTM and see the Contents folder. However, the volume drive is mounted in read only mode, so that I can't copy u-boot.bin to the folder.
/Volumes/UTM/UTM.app on /private/var/folders/ns/bkcwhmm106j0_scbdvv_x29c0000gn/T/AppTranslocation/7DABB818-AE48-4EBF-9012-FF45CF3B9602 (nullfs, local, nodev, nosuid, read-only, noowners, quarantine, nobrowse, mounted by User). How can I mount the folder with read-write?


You need to install UTM rather than trying to run it from the disk image... UTM is a hypervisor.

Link to comment
Share on other sites

Thanks, I can copy files to the UTM folder now. But I have another issue now. After setting the UTM and importing the image file (.img from the .img.xz file), I see an error "Error trying to start shared directory: The file couldn’t be opened because it isn’t in the correct format.". I set the interface to virtIO. Do I need to add a new second drive?

You wrote "make sure spice-vdagent is installed". However, `brwe install spice-vdagent`doesn't find the app or library.

screenshot_utm_error.png

Link to comment
Share on other sites

  • Igor pinned this topic

I am able to use virt-manager with Armbian_22.11.0-trunk_Virtual-qemu_sid_current_5.10.148.img

Since I could not find anything about that I'll post what I did to make it work.

 

You will need the edk2 firmware, guestfish and qemu-system-aarch64 programs.

 

Find the names of the kernel and initrd

 

$ sudo virt-ls -a Armbian_22.11.0-trunk_Virtual-qemu_sid_current_5.10.148.img /boot/ | grep -E 'vmlinuz|initrd.img'
initrd.img-5.10.148-virtual
vmlinuz-5.10.148-virtual

 

Copy them out of the qcow2

 

$ sudo virt-copy-out -a Armbian_22.11.0-trunk_Virtual-qemu_sid_current_5.10.148.img /boot/vmlinuz-5.10.148-virtual /boot/initrd.img-5.10.148-virtual .

 

 

Find the UUID of the root file system

 

$ sudo virt-cat -a Armbian_22.11.0-trunk_Virtual-qemu_sid_current_5.10.148.img /etc/fstab
UUID=99cf7ecb-0abb-48cb-a603-475171df5fc3 / ext4 defaults,noatime,commit=600,errors=remount-ro 0 1
tmpfs /tmp tmpfs defaults,nosuid 0 0

 

  1. Create a VM using virt-manager: New-> Import disk image   and Architecture options aarch64
  2. Provide the exiting storage path: use the file browser to select the img file.
  3. Choose the operating system you are installing: debian-testing  (there isn't a sid option as of yet).
  4. On the Ready to begin installation screen check the Customize configuration before install
  5. In virt-manager: Show Hardware Details (View->details or click the lightbulb icon) -> Boot options -> check Enable direct kernel boot
  6. Fill in the Kernel path and Initrd path with the files you got from virt-copy-out.
  7. Fill in the Kernel args with earlyprintk loglevel=8  root=UUID=99cf7ecb-0abb-48cb-a603-475171df5fc3 rw rootfstype=ext4
  8. But use the UUID from the fstab.

At this point you can start the VM.

 

virt-manager-armbian.png

Link to comment
Share on other sites

Two things about my virt-manager setup:

  1. Every time the kernel package(s) get updated you will need to do the virt-copy-out extraction and update the Kernel path, etc. in virt-manager.
  2. I tried to use UEFI but I got stuck at the UEFI shell with no fs0:>   (does anyone have any suggestions about how to configure the qemu images to use UEFI?)
Edited by ambiamber
copy-editing
Link to comment
Share on other sites

This manual needs updating. This is my script that download X86 (for ARM its the same) UEFI image, convert it to qcow2, create bridged VM, run it and run 1st boot steps:

 

Spoiler
virsh destroy Armbian
virsh undefine Armbian
wget -q -O - "https://redirect.armbian.com/region/EU/uefi-x86/Sid_edge_xfce" | xz -d > image.iso
sudo qemu-img convert -f raw -O qcow2 image.iso /var/lib/libvirt/images/image.qcow2
sudo qemu-img resize /var/lib/libvirt/images/image.qcow2 +10G
virt-install --name Armbian --memory 2048 --vcpus 4 --disk /var/lib/libvirt/images/image.qcow2,bus=sata --import --os-variant ubuntu22.04 --network bridge=br1 --noautoconsole
sleep 10s

# get ip
MAC=$(sudo virsh domiflist Armbian | tail -2 | head -1 | awk '{print $NF}')
USER_HOST=$(sudo nmap -sP 10.0.40.0/24 | grep -i "$MAC" -B 2 | head -1 | awk '{print $NF}')

# login
USER_ROOT=root
PASS_ROOT=testpassword
USER_NORMAL=guest
PASS_NORMAL=testpassword

expect -c "
        spawn sshpass -p 1234 ssh -o "StrictHostKeyChecking=accept-new" ${USER_ROOT}@${USER_HOST}
        set timeout 120
        expect \"Create root password: \"
        send \"${PASS_ROOT}\r\"
        expect \"Repeat root password: \"
        send \"${PASS_ROOT}\r\"
        expect \"zsh\"
        send \"2\r\"
        expect \"*to abort\"
        send \"${USER_NORMAL}\r\"
        expect \"Create*password:\"
        send \"${PASS_NORMAL}\r\"
        expect \"Repeat*password:\"
        send \"${PASS_NORMAL}\r\"
        expect \"Please provide your real name: \"
        send \"${NAME_NORMAL}\r\"
        expect \"*language based on your location*\"
        send \"y\r\"
        expect eof\r"

 


 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines