[SOLVED] Can't install Arch Linux under QEMU. Help Needed!

I want to return to OpenWrt after a while with ipFire, but I have one NodeJS comms app (our corporate video conferencing app) which won't install in OpenWrt because there is no package that provides libdl.so (at least I haven't been able to find it). I'm running on a large x86 PC.

So my solution is to install Arch Linux as a VM under QEMU, as I know our app works (I had to do this on ipFire too).

But how do I do this with only qemu-system-x86_64? I've used this in the past without issue on several VPSs running Ubuntu and Arch, but on OpenWrt I cannot view the screen - I just see "VNC server running on ::1:5900" as the network doesn't load - it pops up in DHCP for about 3 seconds and then dies.

I've got a VM of Debian and Ubuntu running using the Wiki page but I cannot get Arch to run the installer. I tried extracting the kernel from Arch's netboot ISO which starts to load and then kernel panics. I have to get Arch to load as it is the only approved flavour of Linux for our company due to the way we harden it.

I've tried adding -cdrom and various varieties of -drive but drawn a blank.

This is the code I'm using (adapted from my working version of the script on the Wiki)

qemu-system-x86_64 -enable-kvm -cpu host -smp 2 -m 4G \
	-cdrom arch.iso \
	-drive file=arch.qcow2,if=virtio \
	-device virtio-net-pci,mac=E2:F2:6A:01:9D:C9,netdev=br0 \
	-netdev bridge,br=br-lan,id=br0 \
	-nographic

I'm not familiar with qemu-system-x86_64 - I've always used libvirt - so I'm keen to learn. I'm obviously being dumb but I'm stumped so all help gratefully received.

Install more practical vm host - debian, alpine, arch, ubuntu. Then openwrt can route between interfaces if needed, along with dozen re-attachable vms with 24x7 work desktops

Did I understand correctly that you would like to use OpenWrt as your main operating system on this machine and run just one single service in a VM?

If so, would running your service in a docker container or an LXC container be an option? I have two OpenWrt machines with LXC containers, they perform quite well.

Yes, that's correct. I've never used docker or lxc containers. How well will they cope with video comms apps?

For my own peace of mind, I still want to figure out how to get non-debian OS's to install into qemu...

Ive never run qemu with openwrt as a host BUT I run a lot of arch in qemu's with arch host. I also usually run uefi guests.

Maybe these options can help (they may be outdated as I set them alooong time ago and just keep re-using)

-machine type=q35,accel=kvm,kernel_irqchip=on,hpet=off \
-cpu host,kvm=off,hv_vendor_id=nullzilla,hv_relaxed,hv_vpindex,hv_time,hv_synic,hv_stimer,hv_spinlocks=0x1fff \
-smp 2,sockets=1,cores=1,threads=2 \


for the drive I use: 
-drive format=qcow2,file=drive0.qcow2

for cdrom I use: 
-drive file=arch.iso,index=2,media=cdrom

I just created a quick machine with arch as host and guest. I don't have an openwrt machine on an x86

I see arch now has premade vm's.
I grabbed the basic qcow2 from the VM section from https://archlinux.org/download/ and saved it as drive0.qcow2
Read the readme shown in the VM section. It also has the user/pass as arch/arch.

I then created the start script to run it (don't forget the chmod +x script)

#!/bin/sh
vmname="a_test"
macaddr="aa:aa:aa:aa:00:01"

qemu-system-x86_64 \
-name $vmname,process=$vmname \
-enable-kvm \
-machine type=q35,accel=kvm,kernel_irqchip=on,hpet=off \
-cpu host,kvm=off,hv_vendor_id=nullzilla,hv_relaxed,hv_vpindex,hv_time,hv_synic,hv_stimer,hv_spinlocks=0x1fff \
-smp 2,sockets=1,cores=1,threads=2 \
-m 4G -mem-prealloc \
-usb -device usb-tablet \
-vga qxl \
-vnc :1 \
-nographic \
-drive format=qcow2,file=drive0.qcow2,if=virtio \
-net nic,macaddr=$macaddr -net bridge,br=br_qemus

Side Notes:
-I am wondering if you are seeing the nic during the "pxe boot" section when you mention 3 seconds.
-also, as a reminder vnc :1 is port 5901

cdrom install version

grabbed the latest arch linux iso and saved it as arch.iso
created a new qcow2 image: qemu-img create -f qcow2 drive0.qcow2 20G

used the start script (dont forget to chmod +x startscript

#!/bin/bash
vmname="a_test"
macaddr="aa:aa:aa:aa:00:01"

qemu-system-x86_64 \
-name $vmname,process=$vmname \
-enable-kvm \
-machine type=q35,accel=kvm,kernel_irqchip=on,hpet=off \
-cpu host,kvm=off,hv_vendor_id=nullzilla,hv_relaxed,hv_vpindex,hv_time,hv_synic,hv_stimer,hv_spinlocks=0x1fff \
-smp 2,sockets=1,cores=1,threads=2 \
-m 4G -mem-prealloc \
-usb -device usb-tablet \
-vga qxl \
-vnc :1 \
-nographic \
-drive format=qcow2,file=drive0.qcow2,if=virtio \
-drive file=arch.iso,index=2,media=cdrom \
-net nic,macaddr=$macaddr -net bridge,br=br_qemus \
-boot menu=on

It immediately loads into selection screen.
cli looks like:

vnc looks like:

After the selection screen the cli terminal stops working (as expected)
After the selection screen the vnc client needed to reconnect.

It ran archinstall
I haven't used archinstall before (it's relatively a new thing). But I think this is as far as you were looking.

side note:
-I usually use a lot more options (don't forget vnc in this example is not protected)
-I use spice in a lot of my machines. especially gui. audio, usb passthrough from client, etc...
-I like using remmina as the client. It supports spice, rdp, vnc, etc... nicely.
-I found it annoying to use \ in the start scripts a LOOONG time ago as its extra steps to add/remove lines. Doing it this way you can just comment out what you don't want and add/remove as you wish
I do it like:

#!/bin/bash
vmname="a_test"
macaddr="aa:aa:aa:aa:00:01"
port_vnc=1

OPTS=""
OPTS="$OPTS -name $vmname,process=$vmname"
OPTS="$OPTS -enable-kvm"
OPTS="$OPTS -machine type=q35,accel=kvm,kernel_irqchip=on,hpet=off"
OPTS="$OPTS -cpu host,kvm=off,hv_vendor_id=nullzilla,hv_relaxed,hv_vpindex,hv_time,hv_synic,hv_stimer,hv_spinlocks=0x1fff"
OPTS="$OPTS -smp 2,sockets=1,cores=1,threads=2"
OPTS="$OPTS -m 4G -mem-prealloc"
OPTS="$OPTS -usb -device usb-tablet"
OPTS="$OPTS -vga qxl"
OPTS="$OPTS -vnc :$port_vnc"
OPTS="$OPTS -nographic"
OPTS="$OPTS -drive format=qcow2,file=drive0.qcow2,if=virtio"
OPTS="$OPTS -drive file=arch.iso,index=2,media=cdrom"
OPTS="$OPTS -net nic,macaddr=$macaddr -net bridge,br=br_qemus"
OPTS="$OPTS -boot menu=on"

echo qemu-system-x86_64 $OPTS
echo ========================
echo
qemu-system-x86_64 $OPTS

Wow, I've just woken up and seen your messages @Triwoog - thank you so much

I think you are 100% correct!

I think this could be my issue. How do I get a vnc client to reconnect? I presume on the OpenWrt host rather than my PC (as there isn't an IP I can attach to)?

I've got to prepare to go to work now, but I'll try your steps above later today and report back

Thanks again

@Triwoog You are my hero! Thank you so much.

The solution was to put the IP address of the OpenWrt box in the -vnc line as in

-vnc 192.168.1.1:5901

So simple. I would never have realised this without your nudge to reconnect the vnc client. A huge thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.