← TUTORIAL
#ovirt

Locked disk after VM clone

updated 22 September 2016

After cloning a VM in oVirt, the cloned disk can end up in a locked state that prevents the VM from booting. This post walks through the database fix to clear that lock.

Background

Early on, I built a Debian 8 server and turned it into a template for fast VM deployment. After a few months I discovered that VMs based on that template remained dependent on it. Cloning gave them their own UUID for both the VM and disk, which was the goal. But after cloning, attempting to boot produced a locked disk error.

Connect to the engine database

SSH into the oVirt engine host:

ssh ovirt-engine

Switch to the postgres user:

su - postgres

Enter the PostgreSQL shell:

psql

List available databases:

\l

skaermbillede-fra-2016-09-21-14-22-11

Connect to the engine database:

\c engine

Find locked disks

Query for disks with imagestatus = 2 (locked):

SELECT image_guid FROM vm_images_view WHERE imagestatus = 2;

skaermbillede-fra-2016-09-21-14-21-57

To see the VM names alongside the GUIDs, check the available columns first:

\d+ vm_images_view

skaermbillede-fra-2016-09-21-14-20-30

Then query both columns:

SELECT image_guid, vm_names FROM vm_images_view WHERE imagestatus = 2;

skaermbillede-fra-2016-09-21-14-21-23

Four disks show as locked. Inspect one to confirm the row:

SELECT * FROM images WHERE image_guid = '4931fabe-a908-45b6-98ec-fe38cf17a475';

skaermbillede-fra-2016-09-21-14-21-42

Unlock the disk

Set imagestatus back to 1 (OK):

UPDATE images SET imagestatus = 1 WHERE image_guid = '4931fabe-a908-45b6-98ec-fe38cf17a475';

The response UPDATE 1 confirms the change. The disk lock is now cleared and the VM can be edited and booted normally.