You are not logged in.

#1 2022-02-02 20:13:30

MegaMexican
Member
Registered: 2021-10-08
Posts: 29

[SOLVED] Can't Install OS to QEMU Imagefile

I'm trying to create a virtual machine with CentOS as guest OS on my Arch host, using QEMU and KVM. Following the instructions from this page: https://wiki.archlinux.org/title/QEMU#Installation.

First I create the imagefile in a directory I set up for it on a secondary SSD:

$ qemu-img create -f qcow2 /data/vmpractice/qemu.imagefile 50G
Formatting '/data/vmpractice/qemu.imagefile', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=53687091200 lazy_refcounts=off refcount_bits=16

Then I try to install the CentOS iso onto the imagefile:

$ qemu-system-x86_64 -cdrom /home/user/Downloads/CentOS-Stream-9-latest-x86_64-dvd1.iso -boot order=d -drive file=/data/vmpractice/qemu.imagefile, format=qcow2
qemu-system-x86_64: format=qcow2: drive with bus=0, unit=0 (index=0) exists

I'm using the fish shell, it returns with an exit code of 1 (meaning the command failed). Running that command with sudo gives me that same message. I have searched for that error message, "qemu-system-x86_64: format=qcow2: drive with bus=0, unit=0 (index=0) exists" and the only solution I found is to not use wildcards, which I'm not so that's not applicable here. I have no clue what part of that command is incorrect. Would anyone be able to shed some insight? Please and thank you.

Last edited by MegaMexican (2022-02-08 13:29:24)

Offline

#2 2022-02-02 22:15:03

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,261

Re: [SOLVED] Can't Install OS to QEMU Imagefile

bash gives same error.
Try removing

, format=qcow2

from the install command so qemu will have to detect the correct format for the imagefile.

Last edited by Lone_Wolf (2022-02-02 22:15:59)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#3 2022-02-03 19:45:28

Mr Victory
Member
Registered: 2021-06-10
Posts: 41

Re: [SOLVED] Can't Install OS to QEMU Imagefile

1. Do not use sudo for QEMU.
2. Try removing the space between "," and "format=qcow2"
3. Append -kvm to your command or VM will run painfully slow.

Offline

#4 2022-02-03 19:48:35

MegaMexican
Member
Registered: 2021-10-08
Posts: 29

Re: [SOLVED] Can't Install OS to QEMU Imagefile

Okay, so progress has been made. Either removing the space between "," and "format" or just removing the ", format=qcow2" entirely work. Adding "-kvm" yields the error "qemu-system-x86_64: -kvm: invalid option"

It boots into the CentOS installer, problem is that when I click "Install CentOS 9 Stream" it just goes to a blank screen with a white underscore cursor.

I did some digging and found this: https://docs.centos.org/en-US/centos/in … stallation but none of those steps I tried worked. VNC is the only thing I haven't tried from their troubleshooting.

Interestingly enough though, the section "The Boot Menu" of this guide: https://docs.centos.org/en-US/centos/in … t-menu-x86 states

To customize the boot options for a particular menu entry:

  • On BIOS-based systems, the preferred way is to press the Tab key and add custom boot options to the command line. You can also access the boot: prompt by pressing the Esc key but no required boot options will be preset in it. In that case, you must always specify the linux option before using any other boot options.

  • On UEFI-based systems, press the e key and add custom boot options to the command line. When ready press Ctrl+X to boot the modified option.

Well in QEMU pressing "e" does nothing, so it acts like it's BIOS-based. But I have this CentOS image on a flash drive on the host, booted into the flash drive and 1. it responds to pressing "e" and 2. it boots the graphical installer no problem. So it seems like QEMU is causing the issue? I'm not sure how, I can't find anything about this in the Archwiki page on QEMU that I linked earlier. Any other forum posts about this I've found are for installing CentOS on a host, not on a VM.

Last edited by MegaMexican (2022-02-03 20:01:33)

Offline

#5 2022-02-03 20:00:41

Mr Victory
Member
Registered: 2021-06-10
Posts: 41

Re: [SOLVED] Can't Install OS to QEMU Imagefile

Did you add -kvm to QEMU command line options?
Did you try serial? QEMU has a serial accessible with Ctrl-Alt-2 (return to display with Ctrl-Alt-1)

Offline

#6 2022-02-03 20:12:11

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] Can't Install OS to QEMU Imagefile

The option is actually -enable-kvm. And try one of the other video options. I use virtio-vga-gl but I've never tried a CentOS guest.


Jin, Jîyan, Azadî

Offline

#7 2022-02-03 20:12:49

MegaMexican
Member
Registered: 2021-10-08
Posts: 29

Re: [SOLVED] Can't Install OS to QEMU Imagefile

Did you add -kvm to QEMU command line options?

I edited my last post with an answer to that, you asked right as I was editing. It doesn't like it sad

According to the View tab in QEMU, Ctrl+Alt+2 is tied to compatmonitor0, Ctrl+Alt+3 is serial0. The monitor seems to work, serial0 takes me to a black screen with a white cursor. Switching back to VGA (Ctrl+Alt+1) takes me back to the screen before, black with a white underscore cursor.

The QEMU monitor did produce something interesting though:

(qemu) info kvm
kvm support: disabled

So that's intriguing.

Offline

#8 2022-02-03 20:45:34

MegaMexican
Member
Registered: 2021-10-08
Posts: 29

Re: [SOLVED] Can't Install OS to QEMU Imagefile

So I tried different video options:

$ qemu-system-x86_64 -cdrom /home/user/Downloads/CentOS-Stream-9-latest-x86_64-dvd1.iso -boot order=d -drive file=/data/vmpractice/qemu.imagefile,format=qcow2 -enable-kvm -vga virtio gallium-drivers=virgl -device virtio-vga-gl -display gtk,gl=on
libEGL warning: DRI3: Screen seems not DRI3 capable
libEGL warning: DRI2: failed to authenticate
qemu-system-x86_64: gallium-drivers=virgl: drive with bus=0, unit=0 (index=0) exists
$ qemu-system-x86_64 -cdrom /home/user/Downloads/CentOS-Stream-9-latest-x86_64-dvd1.iso -boot order=d -drive file=/data/vmpractice/qemu.imagefile,format=qcow2 -enable-kvm -vga virtio gallium-drivers=virgl -device virtio-vga-gl -display sdl,gl=on
qemu-system-x86_64: gallium-drivers=virgl: drive with bus=0, unit=0 (index=0) exists

I've tried the following as well with no change:

$ qemu-system-x86_64 -cdrom /home/user/Downloads/CentOS-Stream-9-latest-x86_64-dvd1.iso -boot order=d -drive file=/data/vmpractice/qemu.imagefile,format=qcow2 -enable-kvm -vga vmware
$ qemu-system-x86_64 -cdrom /home/user/Downloads/CentOS-Stream-9-latest-x86_64-dvd1.iso -boot order=d -drive file=/data/vmpractice/qemu.imagefile,format=qcow2 -enable-kvm -vga cirrus
$ qemu-system-x86_64 -cdrom /home/user/Downloads/CentOS-Stream-9-latest-x86_64-dvd1.iso -boot order=d -drive file=/data/vmpractice/qemu.imagefile,format=qcow2 -enable-kvm -vga qxl
qxl_send_events: spice-server bug: guest stopped, ignoring

Offline

#9 2022-02-03 22:54:01

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,599

Re: [SOLVED] Can't Install OS to QEMU Imagefile

MegaMexican wrote:
(qemu) info kvm
kvm support: disabled

So that's intriguing.

KVM enabled on machine level?

You may try this line, You don't have to completely use it, tried on a Fedora workstation ISO with qcow2 img:

qemu-system-x86_64 -boot order=d,menu=on,reboot-timeout=2000 -m size=3072,slots=0,maxmem=3221225472 -k en-us -name CentOS-Stream-9-latest-x86_64-dvd1.iso_0 -device virtio-scsi-pci,id=scsi0 -display sdl -vga virtio -audiodev pa,id=snd0 -device ich9-intel-hda -device hda-output,audiodev=snd0 -device virtio-net-pci,romfile=,netdev=net0 -netdev user,id=net0,hostfwd=tcp::60033-:22 -machine type=q35,smm=on,accel=kvm,usb=on,pcspk-audiodev=snd0 -global ICH9-LPC.disable_s3=1 -enable-kvm -device scsi-cd,bus=scsi0.0,drive=cdrom0 -drive id=cdrom0,if=none,format=raw,media=cdrom,read-only=on,file=/home/user/Downloads/CentOS-Stream-9-latest-x86_64-dvd1.iso -hdc /data/vmpractice/qemu.imagefile -serial stdio -no-reboot

edit: 'smm' is needed for secure boot! '-no-reboot': explains itself;-) etc. man qemu is my friend...

Last edited by qinohe (2022-02-03 22:59:52)

Offline

#10 2022-02-07 13:37:39

MegaMexican
Member
Registered: 2021-10-08
Posts: 29

Re: [SOLVED] Can't Install OS to QEMU Imagefile

So that worked, but why did it work? Which option specifically got it to work?

Offline

#11 2022-02-07 16:02:15

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,599

Re: [SOLVED] Can't Install OS to QEMU Imagefile

MegaMexican wrote:

So that worked, but why did it work? Which option specifically got it to work?

You are supposed to make a little effort yourself too ;-) , you could have tried it with help of the fine manuals ...
&&& You need to read the manuals for there don't have to, but, there could be 'snags' in my line...
Like I said in my previous post, you don't have to completely use that line,  but at least notice the RAM!
These would be the part that makes it work:

qemu-system-x86_64 -m size=3072 -device virtio-scsi-pci,id=scsi0 -display sdl -vga virtio -enable-kvm -device scsi-cd,bus=scsi0.0,drive=cdrom0 -drive id=cdrom0,if=none,file=/home/user/Downloads/CentOS-Stream-9-latest-x86_64-dvd1.iso -hdc /data/vmpractice/qemu.imagefile

Offline

#12 2022-02-07 18:30:25

MegaMexican
Member
Registered: 2021-10-08
Posts: 29

Re: [SOLVED] Can't Install OS to QEMU Imagefile

Sorry, I tried reading the man page for qemu but there's a handful of options that I don't understand.

Namely, I don't understand why "device" shows up multiple times, and I don't know how you knew which devices to list for those arguments.

Offline

#13 2022-02-07 18:37:35

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] Can't Install OS to QEMU Imagefile

MegaMexican wrote:

why did it work? Which option specifically got it to work?

Probably the "-m size=3072,slots=0,maxmem=3221225472" bit.

Only 512KiB is allocated by default and I'm sure the installer needs more than that. I would try at least "-m 1G". Sorry for not noticing that in the OP.

EDIT: oops, sorry qinohe, you already explained that. I'll go back to sleep now...

Last edited by Head_on_a_Stick (2022-02-07 18:38:31)


Jin, Jîyan, Azadî

Offline

#14 2022-02-07 23:08:38

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,599

Re: [SOLVED] Can't Install OS to QEMU Imagefile

MegaMexican wrote:

Sorry, I tried reading the man page for qemu but there's a handful of options that I don't understand.

Namely, I don't understand why "device" shows up multiple times, and I don't know how you knew which devices to list for those arguments.

Imagine a PC, how many devices are in there; a network card a VGA card a sound card etc. etc.
Every one is a 'device' with many different options you can set for the device/s you like to emulate.

So, basically you need to at least know/understand what devices make a PC.
Start simple and slowly build a line that is quite complicated (if you look at it now!) but still is nothing more than emulating hardware(mostly) you'd like your PC to have.

The first time I looked at 'man qemu' I may have thought the same as you but practice makes it work.
If you successfully want to use qemu CLI you need to dive into that man page and maybe use a search engine to help you understand some parts that need explanation.
Doing that will make you succeed!

Offline

#15 2022-02-08 13:28:59

MegaMexican
Member
Registered: 2021-10-08
Posts: 29

Re: [SOLVED] Can't Install OS to QEMU Imagefile

Roger that! I'll study up on that as much as possible. Thanks for being patient with me.

Offline

Board footer

Powered by FluxBB