Since you have created the volume group, you will be able to use the following tools for managing your volumes:
nova volume-create
nova volume-attach
nova volume-detach
nova volume-delete
![]() | Note |
|---|---|
If you are using KVM as your hypervisor, then the actual device name in the guest will be different than the one specified in the nova volume-attach command. You can specify a device name to the KVM hypervisor, but the actual means of attaching to the guest is over a virtual PCI bus. When the guest sees a new device on the PCI bus, it picks the next available name (which in most cases is /dev/vdc) and the disk shows up there on the guest. |
Installing and configuring the iSCSI initiator
Remember that every node will act as the iSCSI initiator while the server running nova-volumes will act as the iSCSI target. So make sure, before going further that your nodes can communicate with you nova-volumes server. If you have a firewall running on it, make sure that the port 3260 (tcp) accepts incoming connections.
First install the open-iscsi package on the initiators, so on the compute-nodes only
$ apt-get install open-iscsiThen run on the nova-controller (iscsi target), start tgt, which is installed as a dependency of the volume package:
$ service tgt startAnd on the compute-nodes (iscsi initiators) :
$ service open-iscsi startStart nova-volume and create volumes
You are now ready to fire up nova-volume, and start creating volumes!
$ service nova-volume start
Once the service is started, login to your controller and ensure you’ve properly sourced your ‘novarc’ file.
One of the first things you should do is make sure that nova-volume is checking in as expected. You can do so using nova-manage:
$ nova-manage service listIf you see a smiling ‘nova-volume’ in there, you are looking good. Now create a new volume:
$ nova volume-create --display_name myvolume 10--display_name sets a readable name for the volume, while the final argument refers to the size of the volume in GB.
You should get some output similar to this:
+----+-----------+--------------+------+-------------+--------------------------------------+ | ID | Status | Display Name | Size | Volume Type | Attached to | +----+-----------+--------------+------+-------------+--------------------------------------+ | 1 | available | myvolume | 10 | None | | +----+-----------+--------------+------+-------------+--------------------------------------+You can view that status of the volumes creation using nova volume-list. Once that status is ‘available,’ it is ready to be attached to an instance:
$ nova volume-attach 857d70e4-35d5-4bf6-97ed-bf4e9a4dcf5a 1 /dev/vdbThe first argument refers to the instance you will attach the volume to; the second is the volume ID; The third is the mountpoint on the compute-node that the volume will be attached to. Compute generates a non-conflicting device name if one is not passed to attach_volume and ensures that the volume name isn't already attached there.
By doing that, the compute-node which runs the instance basically performs an iSCSI connection and creates a session. You can ensure that the session has been created by running :
$ iscsiadm -m sessionWhich should output :
root@nova-cn1:~# iscsiadm -m session tcp: [1] 172.16.40.244:3260,1 iqn.2010-10.org.openstack:volume-1
If you do not get any errors, you can login to the instance and see if the new space is there.
KVM changes the device name, since it's not considered to be the same type of device as the instances uses as it's local one, you will find the nova-volume will be designated as "/dev/vdX" devices, while local are named "/dev/sdX".
You can check the volume attachment by running :
$ dmesg | tailYou should from there see a new disk. Here is the output from fdisk -l:
Disk /dev/vda: 10.7 GB, 10737418240 bytes 16 heads, 63 sectors/track, 20805 cylinders Units = cylinders of 1008 * 512 = 516096 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0×00000000 Disk /dev/vda doesn’t contain a valid partition table Disk /dev/vdb: 21.5 GB, 21474836480 bytes <—–Here is our new volume! 16 heads, 63 sectors/track, 41610 cylinders Units = cylinders of 1008 * 512 = 516096 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0×00000000Now with the space presented, let’s configure it for use:
$ fdisk /dev/vdbPress n to create a new disk partition.
Press p to create a primary disk partition.
Press 1 to designated it as the first disk partition.
Press ENTER twice to accept the default of first and last cylinder – to convert the remainder of hard disk to a single disk partition.
Press t, then select the new partition you made.
Press 83 change your new partition to 83, i.e. Linux partition type.
Press p to display the hard disk partition setup. Please take note that the first partition is denoted as /dev/vda1 in your instance.
Press w to write the partition table and exit fdisk upon completion.
Lastly, make a file system on the partition and mount it.
$ mkfs.ext3 /dev/vdb1 $ mkdir /extraspace $ mount /dev/vdb1 /extraspace
Your new volume has now been successfully mounted, and is ready for use! The commands are pretty self-explanatory, so play around with them and create new volumes, tear them down, attach and reattach, and so on.

![[Note]](../common/images/admon/note.png)
