2.7.3. Launch an instance from a volume

After you create a bootable volume, you can launch an instance from that volume.
Optionally, to configure your volume, see the OpenStack Configuration Reference.
  1. To choose an image to create a bootable volume from, run the following command to list images:
    $ nova image-list
    +--------------------------------------+-------------------------------+------+--------+
    | ID                                   |Name                           |Status| Server |
    +--------------------------------------+-------------------------------+------+--------+
    | e0b7734d-2331-42a3-b19e-067adc0da17d |cirros-0.3.1-x86_64-uec        |ACTIVE|        |
    | 75bf193b-237b-435e-8712-896c51484de9 |cirros-0.3.1-x86_64-uec-kernel |ACTIVE|        |
    | 19eee81c-f972-44e1-a952-1dceee148c47 |cirros-0.3.1-x86_64-uec-ramdisk|ACTIVE|        |
    +--------------------------------------+-------------------------------+------+--------+
  2. To create a bootable volume from an image, include the image ID in the command:
    # cinder create --image-id e0b7734d-2331-42a3-b19e-067adc0da17d --display-name my-boot-vol 8
    +---------------------+--------------------------------------+
    |       Property      |                Value                 |
    +---------------------+--------------------------------------+
    |     attachments     |                  []                  |
    |  availability_zone  |                 nova                 |
    |       bootable      |                false                 |
    |      created_at     |      2013-10-16T01:27:48.645390      |
    | display_description |                 None                 |
    |     display_name    |             my-boot-vol              |
    |          id         | 3195a5a7-fd0d-4ac3-b919-7ba6cbe11d46 |
    |       image_id      | e0b7734d-2331-42a3-b19e-067adc0da17d |
    |       metadata      |                  {}                  |
    |         size        |                  8                   |
    |     snapshot_id     |                 None                 |
    |     source_volid    |                 None                 |
    |        status       |               creating               |
    |     volume_type     |                 None                 |
    +---------------------+--------------------------------------+
    Before the volume builds, its bootable state is false.
  3. To list volumes, run the following command:
    $ cinder list
    +--------------------------------------+-----------+-----------------+------+-------------+----------+-------------+
    |                  ID                  |   Status  |   Display Name  | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+-----------------+------+-------------+----------+-------------+
    | 3195a5a7-fd0d-4ac3-b919-7ba6cbe11d46 | available |   my-boot-vol   |  8   |     None    |   true   |             |
    +--------------------------------------+-----------+-----------------+------+-------------+----------+-------------+
    Note that the bootable state is now true. Copy the value in the ID field for your volume.
  4. To launch an instance, include the --block_device_mapping parameter:
    $ nova boot --flavor FLAVOR --block_device_mapping DEVNAME=ID:TYPE:SIZE:DELETE_ON_TERMINATE NAME
    The command arguments are:
    ParameterDescription
    --flavor FLAVOR
    The flavor ID.
    --block_device_mapping DEVNAME=ID:type:size:delete-on-terminate
    • DEVNAME. A device name where the volume is attached in the system at /dev/dev_name. This value is typically vda.
    • ID. The ID of the volume to boot from, as shown in the output of nova volume-list.
    • type. Either snap or any other value, including a blank string. snap means that the volume was created from a snapshot.
    • size. The size of the volume, in GBs. It is safe to leave this blank and have the Compute service infer the size.
    • delete-on-terminate. Boolean. Indicates whether the volume is deleted when the instance is deleted. You can specify:
      • True or 1
      • False or 0
    NAME
    The name for the server.

    Note

    You must specify an image when booting from a volume, even though the specified image is not used. Otherwise, the Attempt to boot from volume - no image supplied error is returned.
    You can also attach a swap disk on boot with the --swap flag, or you can attach an ephemeral disk on boot with the --ephemeral flag.
    For example, you might enter the following command to boot from a volume. The volume is not deleted when the instance is terminated:

    Note

    For more information on the block device handling options, see Section A.4.1, “Block Device Configuration Options”
    $ nova boot --flavor 2 --image e0b7734d-2331-42a3-b19e-067adc0da17d \ --block_device_mapping vda=3195a5a7-fd0d-4ac3-b919-7ba6cbe11d46:::0 myInstanceFromVolume
    +-------------------------------------+--------------------------------------+
    | Property                            | Value                                |
    +-------------------------------------+--------------------------------------+
    | OS-EXT-STS:task_state               | scheduling                           |
    | image                               | cirros-0.3.1-x86_64-uec              |
    | OS-EXT-STS:vm_state                 | building                             |
    | OS-EXT-SRV-ATTR:instance_name       | instance-00000003                    |
    | flavor                              | m1.small                             |
    | id                                  | 8ed8b0f9-70de-4662-a16c-0b51ce7b17b4 |
    | security_groups                     | [{u'name': u'default'}]              |
    | user_id                             | 352b37f5c89144d4ad0534139266d51f     |
    | OS-DCF:diskConfig                   | MANUAL                               |
    | accessIPv4                          |                                      |
    | accessIPv6                          |                                      |
    | progress                            | 0                                    |
    | OS-EXT-STS:power_state              | 0                                    |
    | OS-EXT-AZ:availability_zone         | nova                                 |
    | config_drive                        |                                      |
    | status                              | BUILD                                |
    | updated                             | 2013-10-16T01:43:26Z                 |
    | hostId                              |                                      |
    | OS-EXT-SRV-ATTR:host                | None                                 |
    | key_name                            | None                                 |
    | OS-EXT-SRV-ATTR:hypervisor_hostname | None                                 |
    | name                                | myInstanceFromVolume                 |
    | adminPass                           | BULD33uzYwhq                         |
    | tenant_id                           | f7ac731cc11f40efbc03a9f9e1d1d21f     |
    | created                             | 2013-10-16T01:43:25Z                 |
    | metadata                            | {}                                   |
    +-------------------------------------+--------------------------------------+
    Now when you list volumes, the volume is attached to a server:
    $ nova volume-list
    +--------------------------------------+-----------+-----------------+------+-------------+--------------------------------------+
    | ID                                   | Status    | Display Name    | Size | Volume Type | Attached to                          |
    +--------------------------------------+-----------+-----------------+------+-------------+--------------------------------------+
    | 3195a5a7-fd0d-4ac3-b919-7ba6cbe11d46 | in-use    | my-boot-vol     | 8    | None        | 8ed8b0f9-70de-4662-a16c-0b51ce7b17b4 |
    +--------------------------------------+-----------+-----------------+------+-------------+--------------------------------------+