Skip to content

Instantly share code, notes, and snippets.

@ptantiku
Last active May 5, 2019 12:00
Show Gist options
  • Save ptantiku/73a7dec95a46d4e1d4b341e832b5346f to your computer and use it in GitHub Desktop.
Save ptantiku/73a7dec95a46d4e1d4b341e832b5346f to your computer and use it in GitHub Desktop.

Resizing Openstack VM's Volumes

Problem:

  1. to resize the volume, the volume must be detached first.
  2. but if it is the only boot volume, or the vm is created by the volume, it cannot be detached.

Solution (after shutdown the VM):

  1. Login . ~/keystone_admin
  2. Check volume ID, VM ID by cinder list or openstack volume list, for ex.

VOLUME=ce6e79c1-5b57-49aa-9a66-acf17f37be70 VM=06e7979a-e23e-4f02-9b57-2bc70442be0a

  1. Go into mysql: mysql
  2. change the volume's mount to other than /dev/vda so it can be unmouted.
use cinder;
select * from volume_attachment where volume_id='ce6e79c1-5b57-49aa-9a66-acf17f37be70';
update volume_attachment set mountpoint='/dev/vdb' where volume_id='ce6e79c1-5b57-49aa-9a66-acf17f37be70';

use nova;
select * from block_device_mapping where volume_id='ce6e79c1-5b57-49aa-9a66-acf17f37be70';
update block_device_mapping set device_name='/dev/vdb', boot_index=1 where volume_id = 'ce6e79c1-5b57-49aa-9a66-acf17f37be70' and deleted_at is NULL;
  1. detach the volume from the VM
openstack server remove volume 06e7979a-e23e-4f02-9b57-2bc70442be0a ce6e79c1-5b57-49aa-9a66-acf17f37be70
  1. resize the volume (e.g. to 100GB)
openstack volume set ce6e79c1-5b57-49aa-9a66-acf17f37be70 --size 100
  1. re-mount the volume
openstack server add volume 06e7979a-e23e-4f02-9b57-2bc70442be0a ce6e79c1-5b57-49aa-9a66-acf17f37be70
  1. Go into mysql and change back to /dev/vda
use nova;
update block_device_mapping set device_name='/dev/vda' where volume_id='ce6e79c1-5b57-49aa-9a66-acf17f37be70' and deleted_at is NULL;

use cinder;
update volume_attachment set mountpoint='/dev/vda' where volume_id='ce6e79c1-5b57-49aa-9a66-acf17f37be70' and deleted=0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment