Attaching Block Storage

You can attach block storage to instances from the dashboard on the Volumes page. Click the Edit Attachments action next to the volume you want to attach.

To perform this action from command line, run the following command:

$ nova volume-attach <server> <volume> <device>

You can also specify block device mapping at instance boot time through the nova command-line client with this option set:

--block-device-mapping <dev-name=mapping> 

The block device mapping format is <dev-name>=<id>:<type>:<size(GB)>:<delete-on-terminate>, where:

The following command will boot a new instance and attach a volume at the same time. The volume of ID 13 will be attached as /dev/vdc. It is not a snapshot, does not specify a size, and will not be deleted when the instance is terminated:

$ nova boot --image 4042220e-4f5e-4398-9054-39fbd75a5dd7 \
            --flavor 2 --key-name mykey --block-device-mapping vdc=13:::0 \
            boot-with-vol-test

If you have previously prepared block storage with a bootable file system image, it is even possible to boot from persistent block storage. The following command boots an image from the specified volume. It is similar to the previous command, but the image is omitted and the volume is now attached as /dev/vda:

$ nova boot --flavor 2 --key-name mykey \
            --block-device-mapping vda=13:::0 boot-from-vol-test

Read more detailed instructions for launching an instance from a bootable volume in the OpenStack End User Guide.

To boot normally from an image and attach block storage, map to a device other than vda. You can find instructions for launching an instance and attaching a volume to the instance and for copying the image to the attached volume in the OpenStack End User Guide.

Questions? Discuss on ask.openstack.org
Found an error? Report a bug against this page


loading table of contents...