Need help attaching a block device as second disk to a VM

Hi,
I am following the doc Raw Device Mapping (RDM) Datastore — OpenNebula 6.2.2 documentation
to attach a block device as a second disk to an existing VM.

its throwing this error. can you please shed some light on this error message and point me to a fix?

Failed to execute virtualization driver operation: attach_disk.
[Z0][VMM][E]: ATTACHDISK: ERROR: attach_disk: Command “set -e -o pipefail virsh --connect qemu:///system attach-device 3dbd3c37-26d3-4fa5-9b08-51232f54fcb <( cat <<EOT EOT )” failed: error: Failed to attach device from /dev/fd/63 error: internal error: unable to execute QEMU command ‘blockdev-add’: ‘file’ driver requires ‘/dev/vg-nvme0n1/lv-vm1-disk1’ to be a regular file Could not attach /dev/vg-nvme0n1/lv-vm1-disk1 (sdb) to 3dbd3c37-26d3-4fa5-9b08-xxx ExitCode: 1


I also tried changing /dev/vg-nvme0n1/lv-vm1-disk1 to /dev/sdb (assuming that is the block device reference used for the VM itself and not the node).

getting the same error

internal error: unable to execute QEMU command ‘blockdev-add’: ‘file’ driver requires ‘/dev/sdb’ to be a regular file Could not attach /dev/sdb (sdb)

it will be helpful to understand the error itself.
what we are trying to do is adding a block device. but OpenNebula expect is to be a regular file?

keywords: “block device”, “raw”, “LVM”, “Unknown disk name”, “add additional disk to the VM”, “add additional disk to the VM while its running”

Thanks

Hey, did you try creating the image with the CLI?

oneimage create -d ${DATASTORE_ID} --name lv-vm1-disk1 --source /dev/vg-nvme0n1/lv-vm1-disk1 --driver raw --prefix vd --persistent --type OS --size 0MB

I tried the command line.
oneimage create -d 117 --name lv-vm1-disk1 --source /dev/vg-nvme0n1/lv-vm1-disk1 --driver raw --prefix vd --persistent --type OS --size 0MB

I get the below error message:
invalid option: --driver

got some additional inputs and questions.

the datastore “117” is an image datasore which is created like this.

cat rdm.conf
NAME = rdm_vm1_disk1
TYPE = “IMAGE_DS”
DS_MAD = “dev”
TM_MAD = “dev”
DISK_TYPE = “BLOCK”
onedatastore create rdm.conf

  • we are expecting this block storage to be provisioned in the local disk of the node. (its not shared storage like NAS/SAN).
  • attach a raw device to the VM directly. (VM will create the filesystem)
  • the raw device is a logical volume (lvm) on the node

I am in the right path?

What is the opennebula version?

opennebula version is 6.10.0.1

According to the CLI help, you should use --format raw instead of --driver raw:

...
## OPTIONS
     -d, --datastore id|name   Selects the datastore
     --description description Description for the new Image
     --disk_type disk_type     Type of the image BLOCK, CDROM, RBD or FILE (for
                               others, check the documentation)
     --dry                     Just print the template
     --format format           Format of the image (raw, qcow2, ...)
     --fs filesystem           Filesystem to format the image (ext4, xfs, ...)
     --name name               Name of the new image
     --no_check_capacity       Do not check Datastore capacity, only for admins.
     --path path               Path of the image file
...

Also, --disk_type BLOCK should register the device as a block device so ONE knows it should be presented to libvirt as such.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.