2

I download qemu-4.0.0.tar.xz from here and after installing all necessary dependencies I run $ ./configure --target-list=aarch64-softmmu to have QEMU installed. I double-check the installation with $ qemu-system-aarch64 --version which returns QEMU emulator version 4.0.0 Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers. I proceed to build the disk image with $ sudo qemu-img create -f qcow2 alpine-img.qcow2 10G which returns Formatting 'alpine-img.qcow2', fmt=qcow2 size=10737418240 cluster_size=65536 lazy_refcounts=off refcount_bits=16. I download alpine-virt-3.12.1-aarch64.iso and alpine-standard-3.12.1-aarch64.iso from here and for both of them when I run sudo qemu-system-aarch64 -cdrom alpine-image.iso -machine virt -m 1024 -smp 4 -hda alpine-img.qcow2 I get a QEMU window which does not proceed with installation, stays there forever, and says compat_monitor0 console QEMU 4.0.0 monitor - type 'help' for more information (qemu). Any help would be appreciated!

EDIT 1: The following command also didn't work: $ sudo qemu-system-aarch64 -boot d -cdrom alpine-standard-3.12.1-aarch64.iso -machine virt -m 1024 -smp 4 -hda alpine-img.qcow2

EDIT 2: Adding the -device virtio-gpu-pci command, i.e., sudo qemu-system-aarch64 -boot d -cdrom alpine-standard-3.12.1-aarch64.iso -machine virt -m 1024 -smp 4 -hda alpine-img.qcow2 -device virtio-gpu-pci opens up the window but this time says: Guest has not initialized the display (yet). The post here says "This isn't an error. It is just QEMU telling you that the guest OS has not yet done what it needs to do to turn on the emulated graphics card and display output. In this case the likely reason for this is that you've tried to run a kernel that won't work on this board model, and so it has crashed before it got anywhere. You can also see this message if the kernel has no graphics support built in and is just doing output to serial console."

EDIT 3: The -nographic option from here also doesn't seem to work.

EDIT 4: I tried the same process with ubuntu-16.04.7-server-arm64.iso and same results...It seems something must be wrong with my build of QEMU.

EDIT 5: I was asked if there's a reason for using an older version of QEMU. The issue is not related to the version of QEMU as it happens for v5.2.0-rc4 as well.

EDIT 6: Definitely take a look at the answer to the post here. My conclusion is that just forget about the .iso files. Instead download the vmlinuz-lts kernel and initramfs-lts initrd files from here and just go with something like this:

qemu-system-aarch64 -machine virt -m 1024 -cpu cortex-a57 -kernel vmlinuz-lts -initrd initramfs-lts -append "console=ttyAMA0 ip=dhcp alpine_repo=http://dl-cdn.alpinelinux.org/alpine/edge/main/" -nographic

Make sure that you're in the directory that the kernel and initrd files are located and definitely use the -nographic option since it didn't work for me otherwise. I haven't yet figured out the details of what exactly is happening. Once I do I'll add an answer. Nevertheless, with the command above you'll finally see the Alpine Linux welcome page!

EDIT 7: The command above doesn't address modloop issues during the boot. You can find the modloop for alpine LTS or edge releases here. Accordingly, the command should change to qemu-system-aarch64 -machine virt -m 1024 -cpu cortex-a57 -kernel vmlinuz-lts -initrd initramfs-lts -append "console=ttyAMA0 ip=dhcp alpine_repo=http://dl-cdn.alpinelinux.org/alpine/edge/main/ modloop=http://dl-cdn.alpinelinux.org/alpine/edge/releases/aarch64/netboot/modloop-lts" -nographic. You can check here for more details.

EDIT 8: I added the -hda flag to the final command to actually install Alpine on an image disk I created using qemu-img. I run alpine-setup and it gets to Available disks are: which I only have a vda option. So I choose it and then I'm asked How would you like to use it? and my options are sys, data, lvm....I pick sys and get ERROR:unable to select packages: syslinux (no such package): required by: world[syslinux]. Does this actually have something to do with the disk image I specified? By the way, without the -hda option there is no question about installing alpine whatsoever. So for installation an install option (maybe -hda) should be passed to the qemu command.

EDIT 9: This link says that by default Alpine uses Syslinux as bootloader. Also, while the package seems to be available here, using apk add syslinux Alpine doesn't return anything...Clearly during the install stage of Alpine on Disk, syslinux is being searched for and not found...

EDIT 10: The answer by @rudib worked like a charm for me. As for the QEMU_EFI-pflash.raw file you can find it in a rpm package here. Just go for the aarch64 entry and simply extract the QEMU_EFI-pflash.raw file.

EDIT 11: Just one last point: If you want to write in the shared directory, make sure to run QEMU as root (sudo) from the host considering that the answer uses the passthrough security model! For more info on this see here.

EDIT 12: In case you want to use samba (i.e., qemu smb) you can use the qemu-system-aarch64 -nographic -machine virt -m 4096 -cpu cortex-a57 -drive if=pflash,format=raw,readonly,file=path_to_efi_file/QEMU_EFI-pflash.raw -drive format=raw,readonly,file=path_to_alpine_virt_iso/alpine-virt-3.12.1-aarch64.iso -drive file=path_to_qcow2_file/alpine.qcow2 -net nic -net user,smb=path_of_shared_folder command in the host and in the guest after installing the cifs-utils package: mount -t cifs //10.0.2.4/qemu mount_point (e.g. /mnt). You can read here where qemu and 10.0.2.4 come from in the previous command.

1
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – terdon
    Dec 6, 2020 at 19:20

1 Answer 1

4

Install

I've successfully used these commands to boot up the alpine image and install it to a qcow2 image:

# create qcow2 image
qemu-img create -f qcow2 alpine.qcow2 10G

# boot up with install medium
qemu-system-aarch64 \
-machine virt -cpu cortex-a57 \
-drive if=pflash,format=raw,readonly,file="/usr/share/edk2/aarch64/QEMU_EFI-pflash.raw" \
-m 512M \
-drive format=raw,readonly,file=/path/to/alpine-standard-3.12.1-aarch64.iso \
-drive file=alpine.qcow2

You need the edk2 package on your host or obtain the file QEMU_EFI-pflash.raw by other means.

Then, you can run setup-alpine and install sys on /dev/vdb (alpine.qcow2). setup-alpine seems to work out of the box just fine here.

After completing the install, shut down the system and remove the install medium:

qemu-system-aarch64 \
-machine virt -cpu cortex-a57 \
-drive if=pflash,format=raw,readonly,file="/usr/share/edk2/aarch64/QEMU_EFI-pflash.raw" \
-m 512M \
-drive file=alpine.qcow2

You should now have booted into your new alpine install.

Graphics

If you want graphics, you can add:

# ramfb seems to work (altough it wont be fast)
-device ramfb
# or virtio gpu, should be faster, but will be detected later
-device virtio-gpu

You'll also need to add peripherals if you want to interact with the vm:

-device usb-ehci -device usb-kbd -device usb-mouse

Shared Folder

If you wanted to share a folder, you could use 9p or maybe the included samba server. 9p should work like this (as in the qemu documentation):

-fsdev local,path=/path/to/your/folder,security_model=none,id=test_dev \
-device virtio-9p-pci,fsdev=test_dev,mount_tag=test_mount

And in the guest:

mount -t 9p -o trans=virtio test_mount /mnt
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.