2.18 Template Import Fails Because Virtual Disk UUID Cannot Be Updated (Bug ID 16175655)

This is a file permissions and ownership issue, which may occur in installations where the VirtualBox user is not root. During the import of a template, the UUID of a virtual disk must be changed if a disk image with the same UUID already exists, for example because the same template has been imported before or if the UUID is assigned to the disk of another virtual machine not controlled by Oracle VDI. The non-root VirtualBox user does not have the necessary permissions to assign a new UUID to the virtual disk image file.

The workaround is to manually change the UUID of the virtual disk image file in the source template before importing it. You can do this with the /usr/bin/VBoxManage command (Oracle Linux platforms) or the /opt/VirtualBox/VBoxManage command (Oracle Solaris platforms).

The command syntax is:

VBoxManage storageattach "<VM_name>" --storagectl "<controller_name>" \
--port "<controller_port_no>" --device "<device_no>" --type "hdd" \
--medium "<path_to_disk_image>" --setduuid "<new_disk_image_uuid>"

First, look up the necessary parameters in the virtual machine configuration. You need the storage controller name and the port and device number of the attached medium, or virtual disk. The medium type is "hdd". The full path to the virtual disk is also displayed in the storage controllers configuration section.

The following example shows how the UUID of a virtual disk attached to a virtual machine named windows-7-template is changed.

VBoxManage showvminfo "windows-7-template" --machinereadable

[...]
storagecontrollername0="IDE Controller"
storagecontrollertype0="PIIX4"
storagecontrollerinstance0="0"
storagecontrollermaxportcount0="2"
storagecontrollerportcount0="2"
storagecontrollerbootable0="on"
storagecontrollername1="SATA Controller" 
storagecontrollertype1="IntelAhci"
storagecontrollerinstance1="0"
storagecontrollermaxportcount1="30"
storagecontrollerportcount1="1"
storagecontrollerbootable1="on"
"IDE Controller-0-0"="none"
"IDE Controller-0-1"="none"
"IDE Controller-1-0"="/usr/share/virtualbox/VBoxGuestAdditions.iso"
"IDE Controller-ImageUUID-1-0"="44d80449-ff62-4d9f-b96f-37bd8f5b50b8"
"IDE Controller-tempeject"="off"
"IDE Controller-IsEjected"="off"
"IDE Controller-1-1"="none"
"SATA Controller-0-0"="/home/vboxuser/VirtualBox VMs/windows-7-template/windows-7-template.vdi"
"SATA Controller-ImageUUID-0-0"="71936354-7f1f-41ac-ba44-92aabd28b72c"
[...]

VBoxManage storageattach "windows-7-template" --storagectl "SATA Controller" \
--port "0" --device "0" --type "hdd" \
--medium "/home/vboxuser/VirtualBox VMs/windows-7-template/windows-7-template.vdi" \
--setduuid "71936354-7f1f-41ac-ba44-92aabd28b740"