Attaching volumes to an instance – OpenStack

Recommended by 0 users

This procedure details the steps involved in attaching a Cinder volume to an existing compute instance using the cinder and nova command line interfaces.

Now that we have a usable volume, we can attach this to any instance. We do this by using the nova volume-attach command in Nova Client.

Getting ready

To begin with, assure that you are logged into the Ubuntu client that has access to the Nova Client tools. These packages can be installed using the following command:

sudo apt-get update
sudo apt-get install python-novaclient

How to accomplish it…

Carry out the following steps to attach a volume to an instance using Nova Client:

  • If you have no instance running, spin one up. Once running, run the nova list command and note the instance ID.
# Source in credentials source .stackrc
nova list

The following output is generated:


  • Using the instance ID, we can attach the volume to our running instance, as follows:
nova volume-attach <instance_id> <volume_id> /dev/vdc


/dev/vdc is specified here so as not to conflict with /dev/vdb, as the former refers to the same instance described previously.

  • The preceding command will output the name of the volume when successful. To view this, log in to your running instance and view the volume that is now attached:
sudo fdisk -l /dev/vdc
  • We should see 1 GB of space available for the running instance. As this is like adding a fresh disk to a system you need to format it for use and then mount it as part of your filesystem.
sudo mkfs.ext4 /dev/vdc sudo mkdir /mnt1
sudo mount /dev/vdc /mnt1 df -h
  • We should now see the newly attached disk available at /mnt1:

Filesystem              Size            Used Avail Use% Mounted on

/dev/vda 1.4G 602M 733M 46% /
devtmpfs 248M 12K 248M 1% /dev
none 50M 216K 50M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 248M 0 248M 0% /run/shm
/dev/vdb 5.0G 204M 4.6G 5% /mnt
/dev/vdc 5.0G 204M 4.6G 5% /mnt1

How it works…

Attaching a cinder-volume is no different from plugging in a USB stick on your own computer—we attach it, (optionally) format it, and mount it.

Under Nova Client, the option volume-attach takes the following syntax:

nova volume-attach instance_id volume_id device

instance_ id is the ID returned from the nova list for the instance that we want to attach the volume to. The volume_id is the name of the device within the instance that we will use to mount the volume that can be retrieved using nova volume-list. This device is the device that will be created on our instance that we use to mount the volume.


Related Pages:

Sample Resume:

Interview Questions:

0 Responses on Attaching volumes to an instance – OpenStack"

Leave a Message

Your email address will not be published. Required fields are marked *

Copy Rights Reserved © Mindmajix.com All rights reserved. Disclaimer.
Course Adviser

Fill your details, course adviser will reach you.