[OpenStack Beginner’s Guide for Ubuntu 11.04] Storage Management
Nova-volume provides persistent block storage compatible with Amazon’s Elastic Block Store. The storage on the instances is non persistent in nature and hence any data that you generate and store on the file system on the first disk of the instance gets lost when the instance is terminated. You will need to use persistent volumes provided by nova-volume if you want any data generated during the life of the instance to persist after the instance is terminated.
Commands from euca2ools package can be used to manage these volumes.
Here are a few examples:
Interacting with Storage Controller
Make sure that you have sourced novarc before running any of the following commands. The following commands refer to a zone called ‘nova’, which we created in the chapter on “Installation and Configuration”. The project is ‘proj’ as referred to in the other chapters.
Create a 10 GB volume
euca-create-volume -s 10 -z nova
You should see an output like:
VOLUME vol-00000002 1 creating (proj, None, None, None) 2011-04-21T07:19:52Z
List the volumes
You should see an output like this:
VOLUME vol-00000001 1 nova available (proj, server1, None, None) 2011-04-21T05:11:22Z VOLUME vol-00000002 1 nova available (proj, server1, None, None) 2011-04-21T07:19:52Z
Attach a volume to a running instance
euca-attach-volume -i i-00000009 -d /dev/vdb vol-00000002
A volume can only be attached to one instance at a time. When euca-describe-volumes shows the status of a volume as ‘available’, it means it is not attached to any instance and ready to be used. If you run euca-describe-volumes, you can see that the status changes from “available” to “in-use” if it is attached to an instance successfully.
When a volume is attached to an instance, it shows up as an additional SCSI disk on the instance. You can login to the instance and mount the disk, format it and use it.
Detach a volume from an instance.
The data on the volume persists even after the volume is detached from an instance. You can see the data on reattaching the volume to another instance.
Even though you have indicated /dev/vdb as the device on the instance, the actual device name created by the OS running inside the instance may differ. You can find the name of the device by looking at the device nodes in /dev or by watching the syslog when the volume is being attached.