Migrate VM Storage from Host-Local Storage to Persistent Volume
This guide provides step-by-step instructions for migrating a virtual machine storage from host-local storage to a persistent block storage volume in Private Cloud Director.
Prerequisites
The VM for which the storage is being migrated must be in
stoppedstate before the migration.Ensure that the target volume storage backend is configured and available.
The
OpenStackCLI must be installed and configured.Sufficient storage capacity in the block storage backend.
Steps to Migrate VM Storage
Step 1: Identify the VM and its Local Disk
List all VMs to find the target VM's ID:
openstack server listGet the details of the specific VM:
openstack server show <VM_IDThe disk location will be under the OS-EXT-SRV-ATTR:root_device name field, typically /dev/vda or similar.
Step 2: Create a New Volume
Create a new volume of the required size to migrate the local disk.
openstack volume create --size <SIZE_IN_GB> --bootable --availability-zone <AZ> <NEW_VOLUME_NAME>Verify the volume creation:
openstack volume show <NEW_VOLUME_ID>Step 3: Convert the Local Disk to an Image
Stop the VM if it's running:
openstack server stop <VM_ID>Create an image from the local storage disk of the VM:
openstack image create --disk-format qcow2 --container-format bare --file /var/lib/nova/instances/<VM_ID>/disk <IMAGE_NAME>Verify that the image is successfully created:
openstack image list | grep <IMAGE_NAME>Step 4: Create a New Bootable Volume from the Image
Use the newly created image to create a bootable volume:
openstack volume create --size <SIZE_IN_GB> --image <IMAGE_NAME> --bootable <NEW_VOLUME_NAME>Ensure the volume is available before proceeding:
openstack volume show <NEW_VOLUME_ID>Step 5: Detach Local Storage and Attach New Volume
Detach the local storage disk.
openstack server stop <VM_ID>
openstack server volume detach <VM_ID> <OLD_VOLUME_ID>Attach the newly created volume.
openstack server volume attach --device /dev/vda <VM_ID> <NEW_VOLUME_ID>Step 6: Start the VM
openstack server start <VM_ID>Verify that the VM is running and using the new volume:
openstack server show <VM_ID>Verification
Confirm that the VM boots from the new volume.
Confirm the new volume shows
in-use.Check that the local storage is no longer in use.
Connect to the VM and verify disk configuration
ssh <USERNAME>@<VM_IP>
sudo lsblk
df -hLast updated
Was this helpful?
