Launch an instance from a volume You can boot instances from a volume instead of an image. Use the nova boot --block-device parameter to define how volumes are attached to an instance when you create it. You can use the --block-device parameter with existing or new volumes that you create from a source image, volume, or snapshot. To attach a volume to a running instance, see Manage volumes.
Create volume from image and boot instance Use this procedure to create a volume from an image, and use it to boot an instance. You can create a volume from an existing image, volume, or snapshot. List available 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 | | +--------------------------------------+---------------------------------+--------+--------+ To create a bootable volume from an image and launch an instance from this volume, use the --block-device parameter. For example: $ nova boot --flavor FLAVOR --block-device source=SOURCE,id=ID,dest=DEST,size=SIZE,shutdown=PRESERVE,bootindex=INDEX NAME The parameters are: Parameter Description --flavor FLAVOR The flavor ID or name. --block-device source=SOURCE,id=ID,dest=DEST,size=SIZE,shutdown=PRESERVE,bootindex=INDEX SOURCE: The type of object used to create the block device. Valid values are volume, snapshot, image and blank. ID: The ID of the source object. DEST: The type of the target virtual device. Valid values are volume and local. SIZE: The size of the volume that will be created. PRESERVE: What to do with the volume when the instance is terminated. preserve will not delete the volume, remove will. INDEX: Used to order the boot disks. Use 0 to boot from this volume. NAME The name for the server. Create a bootable volume from an image, before the instance boots. The volume is not deleted when the instance is terminated: $ nova boot --flavor 2 \ --block-device source=image,id=e0b7734d-2331-42a3-b19e-067adc0da17d,dest=volume,size=10,shutdown=preserve,bootindex=0 \ myInstanceFromVolume +--------------------------------------+-------------------------------------------------+ | Property | Value | +--------------------------------------+-------------------------------------------------+ | OS-EXT-STS:task_state | scheduling | | image | Attempt to boot from volume - no image supplied | | OS-EXT-STS:vm_state | building | | OS-EXT-SRV-ATTR:instance_name | instance-00000003 | | OS-SRV-USG:launched_at | None | | flavor | m1.small | | id | 2e65c854-dba9-4f68-8f08-fe332e546ecc | | 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 | 2014-02-02T13:29:54Z | | hostId | | | OS-EXT-SRV-ATTR:host | None | | OS-SRV-USG:terminated_at | None | | key_name | None | | OS-EXT-SRV-ATTR:hypervisor_hostname | None | | name | myInstanceFromVolume | | adminPass | TzjqyGsRcJo9 | | tenant_id | f7ac731cc11f40efbc03a9f9e1d1d21f | | created | 2014-02-02T13:29:53Z | | os-extended-volumes:volumes_attached | [] | | metadata | {} | +--------------------------------------+-------------------------------------------------+ List volumes to see the bootable volume and its attached myInstanceFromVolume instance: $ cinder list +--------------------------------------+--------+--------------+------+-------------+----------+--------------------------------------+ | ID | Status | Display Name | Size | Volume Type | Bootable | Attached to | +--------------------------------------+--------+--------------+------+-------------+----------+--------------------------------------+ | 2fff50ab-1a9c-4d45-ae60-1d054d6bc868 | in-use | | 10 | None | true | 2e65c854-dba9-4f68-8f08-fe332e546ecc | +--------------------------------------+--------+--------------+------+-------------+----------+--------------------------------------+
Attach non-bootable volume to an instance Use the --block-device parameter to attach an existing, non-bootable volume to a new instance. Create a volume: $ cinder create --display-name my-volume 8 +---------------------+--------------------------------------+ | Property | Value | +---------------------+--------------------------------------+ | attachments | [] | | availability_zone | nova | | bootable | false | | created_at | 2014-02-04T21:25:18.730961 | | display_description | None | | display_name | my-volume | | id | 3195a5a7-fd0d-4ac3-b919-7ba6cbe11d46 | | metadata | {} | | size | 8 | | snapshot_id | None | | source_volid | None | | status | creating | | volume_type | None | +---------------------+--------------------------------------+ List volumes: $ cinder list +--------------------------------------+---------+--------------+------+-------------+----------+-------------+ | ID | Status | Display Name | Size | Volume Type | Bootable | Attached to | +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+ | 3195a5a7-fd0d-4ac3-b919-7ba6cbe11d46 | available | my-volume | 8 | None | false | | +--------------------------------------+-----------+--------------+------+-------------+----------+-------------+ The volume is not bootable because it was not created from an image. The volume is also entirely empty: It has no partition table and no file system. Run this command to create an instance and boot it with the volume that is attached to this instance. An image is used as boot source: $ nova boot --flavor 2 --image e0b7734d-2331-42a3-b19e-067adc0da17d \ --block-device source=volume,id=3195a5a7-fd0d-4ac3-b919-7ba6cbe11d46,dest=volume,shutdown=preserve \ myInstanceWithVolume +--------------------------------------+----------------------------------------------------+ | Property | Value | +--------------------------------------+----------------------------------------------------+ | OS-EXT-STS:task_state | scheduling | | image | e0b7734d-2331-42a3-b19e-067adc0da17d | | 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 | | OS-SRV-USG:terminated_at | None | | key_name | None | | OS-EXT-SRV-ATTR:hypervisor_hostname | None | | name | myInstanceWithVolume | | adminPass | BULD33uzYwhq | | tenant_id | f7ac731cc11f40efbc03a9f9e1d1d21f | | created | 2013-10-16T01:43:25Z | | os-extended-volumes:volumes_attached | [{u'id': u'3195a5a7-fd0d-4ac3-b919-7ba6cbe11d46'}] | | metadata | {} | +--------------------------------------+----------------------------------------------------+ List volumes: $ nova volume-list Note that the volume is attached to a server: +--------------------------------------+-----------+--------------+------+-------------+--------------------------------------+ | ID | Status | Display Name | Size | Volume Type | Attached to | +--------------------------------------+-----------+--------------+------+-------------+--------------------------------------+ | 3195a5a7-fd0d-4ac3-b919-7ba6cbe11d46 | in-use | my-volume | 8 | None | 8ed8b0f9-70de-4662-a16c-0b51ce7b17b4 | +--------------------------------------+-----------+--------------+------+-------------+--------------------------------------+
Attach swap or ephemeral disk to an instance Use the nova boot --swap parameter to attach a swap disk on boot or the nova boot --ephemeral parameter to attach an ephemeral disk on boot. When you terminate the instance, both disks are deleted. Boot an instance with a 512 MB swap disk and 2 GB ephemeral disk: $ nova boot --flavor FLAVOR --image IMAGE_ID --swap 512 --ephemeral size=2 NAME The flavor defines the maximum swap and ephemeral disk size. You cannot exceed these maximum values.