[SOLVED] How can I attach an rbd image to a VM as a hard disk?

joshcorreia

New Member
Nov 8, 2023
11
0
1
Apologies if the terminology I'm using is incorrect, but I'll try to illustrate what I'm trying to do. The end goal is to be able to import a qcow2 image into ceph and then attach it to any VM across one of my five nodes in the cluster. I originally used "qm" but that only lets me access the local node that the commands are being run on so it won't help me for this.

First, I'm importing my qcow2 image into ceph:
Code:
$ sudo qemu-img convert -f qcow2 -O raw test-image.qcow2 rbd:rbd/vm-352-disk-2

Then I can verify that it imported successfully:
Code:
$ sudo rbd ls
vm-352-disk-0
vm-352-disk-2

1701303128390.png
As you can see in the above image, Proxmox is only aware of vm-352-disk-0 (this is expected because rbd != Proxmox).

Now the only piece that I still need to figure out is how to make Proxmox see this new rbd image as a hard disk. How can I do that?

Thank you!
 
Last edited:
You should be able to do this via a rescan:

Code:
qm disk rescan --vmid 352

Then you it should show up as an unused disk and you can attach it.
 
That command doesn't seem to scan ceph, it's only scanning the local node. Is it possible to scan ceph?

Code:
$ sudo qm disk rescan --vmid 352
rescan volumes...
Configuration file 'nodes/joshtest12/qemu-server/352.conf' does not exist
 
Go to the node where the VM is running. You're on another one.

If it still doesn't work, simply copy the line from the existing disk, change it and paste them below. Stop and start the VM and the disk should be available.
 
Go to the node where the VM is running. You're on another one.
I'm trying to avoid having to connect to other nodes, is it possible to rescan without having to be on the node that the VM is on?

I'm running this in a CI/CD pipeline and ideally don't want to give this node SSH access to any of the other nodes.
 
I'm trying to avoid having to connect to other nodes, is it possible to rescan without having to be on the node that the VM is on?
you dont really need to. assuming you're on ANY node in the cluster:

just edit /etc/pve/nodes/nodename/qemu-server/352.conf to add/change the disk, eg:

scsi2: rbd:vm-352-disk-2,size=xxG

edit- you should use virtio-single for scsi bus if at all possible. you can also use sata1: instead.
 
Last edited:
  • Like
Reactions: joshcorreia
In conjunction with CEPH you should definitely use scsi and activate the discard flag
 
you dont really need to. assuming you're on ANY node in the cluster:

just edit /etc/pve/nodes/nodename/qemu-server/352.conf to add/change the disk, eg:

scsi2: rbd:vm-352-disk-2,size=xxG

edit- you should use virtio-single for scsi bus if at all possible. you can also use sata1: instead.
Thank you, this is exactly what I needed! :)