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
euca-describe-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.
euca-detach-volume vol-00000002
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.
