XCP-ng: A device with the name given already exists on the selected VM
Using the xe cli I ran into this error that was “wrong”. I knew the name didn’t already exist because it was a newly created virtual machine but if you read between the lines, you notice that the name is actually the device number.
[18:25 xcpng01 ~]# xe vdi-list
uuid ( RO) : 084d7726-6319-4134-88d5-9f81f8566fc4
name-label ( RW): xo-debian12
name-description ( RW):
sr-uuid ( RO): 97dd73f1-e454-0243-ac15-a416ef6e2383
virtual-size ( RO): 107374182400
sharable ( RO): false
read-only ( RO): false
...
[18:26 xcpng01 ~]# xe vbd-create vm-uuid=800399e0-5368-6a64-4a5e-e3db62b21d8b vdi-uuid=084d7726-6319-4134-88d5-9f81f8566fc4 device=0 type=Disk mode=rw bootable=true
A device with the name given already exists on the selected VM
device: 0
[18:27 xcpng01 ~]# xe vbd-list vm-uuid=800399e0-5368-6a64-4a5e-e3db62b21d8b
uuid ( RO) : cd4b94af-3a68-17ea-11ef-8c60819c50b0
vm-uuid ( RO): 800399e0-5368-6a64-4a5e-e3db62b21d8b
vm-name-label ( RO): xo-debian12
vdi-uuid ( RO): 615de62c-5527-4ff8-bb50-ac55962c5bd3
empty ( RO): false
device ( RO):
Copilot clued me into the solution, which was to change the device number in my command, so I’ll share my prompt and Copilot’s response.
[18:40 xcpng01 ~]# xe vbd-create vm-uuid=6b72211e-4309-e9e9-8c4d-e4f31b465e69 vdi-uuid=248aca8b-52de-4cf0-9d81-9113f8d83862 device=0 bootable=true mode=rw type=Disk A device with the name given already exists on the selected VM device: 0 [18:42 xcpng01 ~]# xe vbd-list vm-uuid=6b72211e-4309-e9e9-8c4d-e4f31b465e69 uuid ( RO) : 8e8d209c-cd0b-ba58-550f-f3c4cd7e3c08 vm-uuid ( RO): 6b72211e-4309-e9e9-8c4d-e4f31b465e69 vm-name-label ( RO): xo-debian12-08112025 vdi-uuid ( RO): 9b795a07-32ac-43a2-a0ec-a80466c68bf4 empty ( RO): false device ( RO):
It looks like you're trying to attach a new virtual block device (VBD) to a VM in XCP-ng, but you're hitting a conflict because device 0 is already in use. Here's a breakdown and how to resolve it
...
Anyway, changing the device number to one that is unused solved the problem.