[SOLVED] QEMU fail to boot Virtual Machine failed : Could not read from CD ROM

hamuto

New Member
Dec 2, 2021
4
1
3
26
Using libvirt, I am creating VM on Proxmox with Scaleway.
I have an ansible file that create a VM name CentOS_Base, the most important commands are:

Bash:
# Downloading a CentOS-7-x86_64-GenericCloud-1809.qcow2
curl https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1809.qcow2

# Create root disk based on cloud init img
qemu-img create -b CentOS-7-x86_64-GenericCloud.qcow2 -f qcow2 -F qcow2 CentOS_Base.qcow2 20G

# Create iso image for cloud init
genisoimage -output cidata.iso -volid cidata -joliet -r user-data meta-data

# Create the VM
virt-install --connect qemu:///system --import --name CentOS_Base --ram 2048 --vcpus 2
--disk CentOS_Base.qcow2,format=qcow2,bus=virtio --disk cidata.iso,device=cdrom
--network network:default,model=virtio --os-type=linux --os-variant=rhel7 --noautoconsole


user-data and meta-data are already created.

The issue : I need to create the VM with QEMU

I found few sources, for how to convert the virtual machine to QEMU.

Using this https://developers.redhat.com/blog/2020/03/06/configure-and-run-a-qemu-based-vm-outside-of-libvirt article
And this https://unix.stackexchange.com/questions/587045/convert-libvirt-xml-into-qemu-command-line question.

I have created a script file, when this script is run, it will (supposedly) convert the VM to QEMU.

Bash:
#!/bin/sh

export LC_ALL=C
export XDG_DATA_HOME=/var/lib/libvirt/qemu/domain-1-CentOS_Base/.local/share
export XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain-1-CentOS_Base/.cache
export XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain-1-CentOS_Base/.config
export QEMU_AUDIO_DRV=spice

/usr/bin/qemu-system-x86_64
-name guest=CentOS_Base,debug-threads=on
...
-display gtk

The problem with the script is that, it simulates/run the VM but doesn't create it.
So I tried to recreate the VM with the command qm create:


Bash:
qm create 9006 --name CentOS-vm1 --memory 2048 --net0 virtio,bridge=vmbr1 --serial0 socket --vga serial0
-ide2 GlusterFs:iso/cidata.iso -bootdisk scsi0 -scsi0 GlusterFs:32 --scsihw virtio-scsi-pci
-ostype l26 -sockets 1 -cores 2 -cpu host -numa 1

qm importdisk 9006 CentOS_Base.qcow2 GlusterFs -format qcow2

When I try to boot I get a message saying the boot drive can't be found.

SNaN6.png


Checking the image with qemu-img shows no errors.
Bash:
qemu-img check /mnt/pve/GlusterFs/images/9006/vm-9006-disk-0.qcow2

No errors were found on the image.
26771/327680 = 8.17% allocated, 0.08% fragmented, 0.00% compressed clusters
Image end offset: 21478375424
 
Last edited:
Hi,
Bash:
qm create 9006 --name CentOS-vm1 --memory 2048 --net0 virtio,bridge=vmbr1 --serial0 socket --vga serial0
-ide2 GlusterFs:iso/cidata.iso -bootdisk scsi0 -scsi0 GlusterFs:32 --scsihw virtio-scsi-pci
-ostype l26 -sockets 1 -cores 2 -cpu host -numa 1

qm importdisk 9006 CentOS_Base.qcow2 GlusterFs -format qcow2
the first command creates a new empty 32 GiB image on the GlusterFs storage and attaches it to scis0. It also sets the boot disk as scsi0. The second command imports the existing image, but will not attach it. Please check the config if there is an unused disk. Try to attach that and correct the bootorder, e.g. in the VM Options in the UI.
 
  • Like
Reactions: hamuto
Hi,

the first command creates a new empty 32 GiB image on the GlusterFs storage and attaches it to scis0. It also sets the boot disk as scsi0. The second command imports the existing image, but will not attach it. Please check the config if there is an unused disk. Try to attach that and correct the bootorder, e.g. in the VM Options in the UI.
Yes that exactly what the problem.

The qm importdisk command create an unesed disk, that I can set to scis1 and after changing the boot order to scis1, I can finally boot.

But how can I attach the CentOS_Base.qcow2 image to the scis0 boot disk?
 
Yes that exactly what the problem.

The qm importdisk command create an unesed disk, that I can set to scis1 and after changing the boot order to scis1, I can finally boot.

But how can I attach the CentOS_Base.qcow2 image to the scis0 boot disk?
You don't really need to, since the boot disk is now scsi1. To do it, you would need to detach both disks and then re-attach the other one to scsi0.
 
  • Like
Reactions: hamuto
You don't really need to, since the boot disk is now scsi1. To do it, you would need to detach both disks and then re-attach the other one to scsi0.
What I wanted to do was:

Bash:
qm create 9007 --name CentOS-vm1 --memory 2048 --net0 virtio,bridge=vmbr1 --serial0 socket --vga serial0 -ide2 GlusterFs:iso/cidata.iso  -ostype l26 -sockets 1 -cores 2 -cpu host -numa 1
qm importdisk 9007 CentOS_Base.qcow2 GlusterFS -format qcow2
qm set 9007 --scsi0 GlusterFs:9007/vm-9007-disk-0.raw --scsihw virtio-scsi-pci --boot order=scsi0
qm resize 9007 scsi0 +12G

This will first create the VM, then import the image, then attach it scsi0 and make sure the boot order is first scsi0 then resize the disk.
Thank you for your help.
 
  • Like
Reactions: fiona
I'm having a similar problem, with all sorts of ISO files. I have ubuntu, centos, rocky linux, and getting the same error. I'm using the GUI to deploy and I can see the iso files, no issues there, but it won't read them. Error is: could not read from cdrom (code 0004).
Please advise. Thanks
 
Last edited:
I was downloading the wrong iso, next time I need to pay more attention to the file or use the url.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!