Ordinarily, Cinder volumes can only be attached to one instance at a time. Thus, you need to detach it from one instance before attaching it to another. To detach a volume, we will use another OpenStack client command called openstack server remove volume
.
To detach a volume from an instance, you will need the following:
openstack
command-line clientopenrc
file with appropriate credentials for the environmentFor our example, these values are as follows:
cookbook.volume
cookbook.test
/mnt1
Carry out the following steps to detach a volume to an instance using the openstack
client:
in-use
in our environment:openstack volume list
This will bring back an output like the following. Note that the information provided shows you if a volume is in use and what instance it is attached to:
df -h
This will show an output like the following:
Filesystem Size Used Avail Use% Mounted on udev 238M 0 238M 0% /dev tmpfs 49M 1.8M 48M 4% /run /dev/vda1 2.1G 843M 1.3G 41% / tmpfs 245M 0 245M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 245M 0 245M 0% /sys/fs/cgroup tmpfs 49M 0 49M 0% /run/user/1000 /dev/vdb 9.8G 23M 9.2G 1% /mnt1
/mnt1
volume:sudo umount /mnt1
(Verify that it has been unmounted by running df -h
again).
openstack server remove volume cookbook.test c ookbook.volume
cookbook.test
instance:openstack volume list
This shows the volume is available and not attached to any instance:
Detaching a Cinder volume from an instance is similar to the steps you would take when removing a USB stick from a computer. First, we need to unmount it from the instance so the operating system doesn't complain about an unexpected removal of some storage. Next under the openstack
client, the server remove volume
option takes the following syntax:
openstack server remove volume instance_name_or_id volume_name_or_id
18.226.165.70