QEMU with Alpinelinux - Printable Version +- PINE64 (https://forum.pine64.org) +-- Forum: Pinebook Pro (https://forum.pine64.org/forumdisplay.php?fid=111) +--- Forum: General Discussion on Pinebook Pro (https://forum.pine64.org/forumdisplay.php?fid=112) +--- Thread: QEMU with Alpinelinux (/showthread.php?tid=18202) |
QEMU with Alpinelinux - Surehand53 - 05-03-2023 Alpinelinux in QEMU I have used the introduction from astr0baby and a few other internet sources and came up with a working solution to boot Alpinelinux in QEMU on the Pinebook Pro. The settings are relatively simple and should work with other target ISOs in a similar way. There is no graphics support, yet. The host distro used here is Manjaro. There might be some differences with other distros. Mind you, this describes how to run an arch64 ISO on an arch64 system. Install Qemu and create a folder to keep all files together: Code: pacman -S qemu-base Copy the ISO of Alpinelinux to your qemu folder. I have used the Standard ISO for the aarch64 architecture. Then you need to download a BIOS Code: wget https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd Last thing to prepare is a virtual harddrive to install Alpinelinux Code: qemu-img create -f qcow2 alpine.qcow2 8G This makes a 8G virtual hard disk in a file named alpine.qcow2, the qcow2 format being a format which appears to be 8G to the guest (VM), but only actually writes to the host any sectors which were written to by the guest in practice. Install Alpinelinux With all in place you can now start qemu from the .iso file and then install Alpinelinux to your virtual harddrive Code: qemu-system-aarch64 \ A small explanation. The first line is qemu for the aarch64 architecture. The second line describes the cpu. Then memory of 1024M is assigned. 512M is also fine. No graphics is supported. Next is the bios and then the two drives. The ISO file and the virtual harddrive. Later I show how to use kvm and smp. They could also be used here, but this keeps is simple. Once Alpinelinux has booted login like this: user: root passwd: <leave empty> Once logged in you can straight away start the install process. Code: setup-alpine Please see the Alpine Docu and Alpine Wiki for details of the installation process. You will be asked a bunch of questions, most of them will be default. Things to notice:
Run Alpinelinux After the system is installed successfully, you can poweroff. To restart the system you don't need the ISO file anymore. The command after installation is: Code: qemu-system-aarch64 \ SMP If you want qemu to use more than one cpu add the [backcolor=#f6f8fa]-smp 2[/backcolor] switch. This gives two cpus, more is possible. KVM For Kvm to work you either have to add your user in Manjaro to the kvm group, or run qemu with sudo. Also:
If you use KVM there appears to be a bug that sometimes creates this error message: Quote:qemu-system-aarch64: kvm_init_vcpu: kvm_arch_init_vcpu failed (0): Invalid argument Just repeat the start command until it works. Code: qemu-system-aarch64 \ Edit See comment from jpalus below for a better way to call qemu with kvm. That's it. I am sure there is still much to improve, but it works. References https://drewdevault.com/2018/09/10/Getting-started-with-qemu.html RE: QEMU with Alpinelinux - jpalus - 05-05-2023 (05-03-2023, 01:41 PM)Surehand53 Wrote: If you use KVM there appears to be a bug that sometimes creates this error message: That's not the best advice. qemu with KVM acceleration needs to be run on the same CPU core type throughout its entire lifecycle. That means in case of multi cluster setups qemu needs to be forced to run within single cluster. In case of Pinebook Pro that means setting CPU affinity to either A53 or A72 cores. While repeating start command may work eventually, the VM won't be stable and will crash/hang the moment it will be rescheduled to different core type. In order to set CPU affinity you can use taskset but unfortunately it needs additional privileges (root or CAP_SYS_NICE). One way to run qemu on Pinebook Pro restricted to A72 cores with sudo is: Code: sudo taskset 30 sudo -u user qemu-system-aarch64 -enable-kvm ... For more details see manpage for taskset. RE: QEMU with Alpinelinux - korreckj328 - 05-06-2023 (05-05-2023, 04:13 PM)jpalus Wrote:(05-03-2023, 01:41 PM)Surehand53 Wrote: If you use KVM there appears to be a bug that sometimes creates this error message: So, just started playing with qemu. So I ask this out of complete ignorance. Do you need taskset when using qemu to emulate another arch? I built qemu from scratch since the manjaro-repos are broken and don't let you install qemu-full or qemu-system-i386. (Trying to test a Win95 VM for some older win95 games.) RE: QEMU with Alpinelinux - jpalus - 05-06-2023 (05-06-2023, 04:21 AM)korreckj328 Wrote: So, just started playing with qemu. So I ask this out of complete ignorance. Do you need taskset when using qemu to emulate another arch? I built qemu from scratch since the manjaro-repos are broken and don't let you install qemu-full or qemu-system-i386. (Trying to test a Win95 VM for some older win95 games.) taskset is needed only when using KVM acceleration which can't be used for archs different than native one so no need to use taskset for i386 emulation. It will be slow though. Depending on your needs you might consider using box86 instead for better performance. RE: QEMU with Alpinelinux - slyecho - 05-09-2023 This seems to be a bug on the RK3399 that you need to use a single core type for KVM. On the RK3588S I can use any combination of cores for virtual machines and it works correctly. If you use libvirt then it can be set in the XML: Code: <vcpu placement="static" cpuset="4-5">2</vcpu> RE: QEMU with Alpinelinux - jpalus - 05-09-2023 (05-09-2023, 01:23 PM)slyecho Wrote: This seems to be a bug on the RK3399 that you need to use a single core type for KVM. On the RK3588S I can use any combination of cores for virtual machines and it works correctly. Works the same way (boot failure / unstable if run across different core types) for me on Amlogic S922X (Odroid N2+) as well Rockchip RK3588 (Rock5B). RK3588 is still running vendor kernel so not sure how representative it is but if I set CPU affinity to 1 A55 core and 1 A76 core than it sometimes fails to boot VM with hardware exception and even if it boots one core is fully utilized at all times even when idle which is not the case if CPU affinity is set to single core type. RE: QEMU with Alpinelinux - slyecho - 05-16-2023 I was running Armbian with 5.10.110-rockchip-rk3588 It works well with Linux guests and NetBSD. Windows 11 was a bit unstable and sometimes failed to boot but the core selection didn't matter. |