<commit_before>================================
Launch an instance from a volume
================================

You can boot instances from a volume instead of an image.

To complete these tasks, use these parameters on the
:command:`openstack server create` command:

.. tabularcolumns:: |p{0.3\textwidth}|p{0.25\textwidth}|p{0.4\textwidth}|
.. list-table::
   :header-rows: 1
   :widths: 30 15 30

   * - Task
     - openstack server create parameter
     - Information
   * - Boot an instance from an image and attach a non-bootable
       volume.
     - ``--block-device``
     -  :ref:`Boot_instance_from_image_and_attach_non-bootable_volume`
   * - Create a volume from an image and boot an instance from that
       volume.
     - ``--block-device``
     - :ref:`Create_volume_from_image_and_boot_instance`
   * - Boot from an existing source image, volume, or snapshot.
     - ``--block-device``
     - :ref:`Create_volume_from_image_and_boot_instance`

.. note::

   To attach a volume to a running instance, see
   :ref:`Attach_a_volume_to_an_instance`.

.. _Boot_instance_from_image_and_attach_non-bootable_volume:

Boot instance from image and attach non-bootable volume
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Create a non-bootable volume and attach that volume to an instance that
you boot from an image.

To create a non-bootable volume, do not create it from an image. The
volume must be entirely empty with no partition table and no file
system.

#. Create a non-bootable volume.

   .. code-block:: console

      $ openstack volume create --size 8 my-volume
      +---------------------+--------------------------------------+
      | Field               | Value                                |
      +---------------------+--------------------------------------+
      | attachments         | []                                   |
      | availability_zone   | nova                                 |
      | bootable            | false                                |
      | consistencygroup_id | None                                 |
      | created_at          | 2016-11-25T10:37:08.850997           |
      | description         | None                                 |
      | encrypted           | False                                |
      | id                  | b8f7bbec-6274-4cd7-90e7-60916a5e75d4 |
      | migration_status    | None                                 |
      | multiattach         | False                                |
      | name                | my-volume                            |
      | properties          |                                      |
      | replication_status  | disabled                             |
      | size                | 8                                    |
      | snapshot_id         | None                                 |
      | source_volid        | None                                 |
      | status              | creating                             |
      | type                | None                                 |
      | updated_at          | None                                 |
      | user_id             | 0678735e449149b0a42076e12dd54e28     |
      +---------------------+--------------------------------------+

#. List volumes.

   .. code-block:: console

      $ openstack volume list
      +--------------------------------------+--------------+-----------+------+-------------+
      | ID                                   | Display Name | Status    | Size | Attached to |
      +--------------------------------------+--------------+-----------+------+-------------+
      | b8f7bbec-6274-4cd7-90e7-60916a5e75d4 | my-volume    | available |    8 |             |
      +--------------------------------------+--------------+-----------+------+-------------+

#. Boot an instance from an image and attach the empty volume to the
   instance.

   .. code-block:: console

      $ openstack server create --flavor 2 --image 98901246-af91-43d8-b5e6-a4506aa8f369 \
        --block-device source=volume,id=d620d971-b160-4c4e-8652-2513d74e2080,dest=volume,shutdown=preserve \
        myInstanceWithVolume
      +--------------------------------------+--------------------------------------------+
      | Field                                | Value                                      |
      +--------------------------------------+--------------------------------------------+
      | OS-DCF:diskConfig                    | MANUAL                                     |
      | OS-EXT-AZ:availability_zone          | nova                                       |
      | OS-EXT-SRV-ATTR:host                 | -                                          |
      | OS-EXT-SRV-ATTR:hypervisor_hostname  | -                                          |
      | OS-EXT-SRV-ATTR:instance_name        | instance-00000004                          |
      | OS-EXT-STS:power_state               | 0                                          |
      | OS-EXT-STS:task_state                | scheduling                                 |
      | OS-EXT-STS:vm_state                  | building                                   |
      | OS-SRV-USG:launched_at               | -                                          |
      | OS-SRV-USG:terminated_at             | -                                          |
      | accessIPv4                           |                                            |
      | accessIPv6                           |                                            |
      | adminPass                            | <PASSWORD>                               |
      | config_drive                         |                                            |
      | created                              | 2014-05-09T16:34:50Z                       |
      | flavor                               | m1.small (2)                               |
      | hostId                               |                                            |
      | id                                   | 1e1797f3-1662-49ff-ae8c-a77e82ee1571       |
      | image                                | cirros-0.3.5-x86_64-uec (98901246-af91-... |
      | key_name                             | -                                          |
      | metadata                             | {}                                         |
      | name                                 | myInstanceWithVolume                       |
      | os-extended-volumes:volumes_attached | [{"id": "d620d971-b160-4c4e-8652-2513d7... |
      | progress                             | 0                                          |
      | security_groups                      | default                                    |
      | status                               | BUILD                                      |
      | tenant_id                            | ccef9e62b1e645df98728fb2b3076f27           |
      | updated                              | 2014-05-09T16:34:51Z                       |
      | user_id                              | fef060ae7bfd4024b3edb97dff59017a           |
      +--------------------------------------+--------------------------------------------+

.. _Create_volume_from_image_and_boot_instance:

Create volume from image and boot instance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can create a volume from an existing image, volume, or snapshot.
This procedure shows you how to create a volume from an image, and use
the volume to boot an instance.

#. List the available images.

   .. code-block:: console

      $ openstack image list
      +-----------------+---------------------------------+--------+
      | ID              | Name                            | Status |
      +-----------------+---------------------------------+--------+
      | 484e05af-a14... | Fedora-x86_64-20-20131211.1-sda | active |
      | 98901246-af9... | cirros-0.3.5-x86_64-uec         | active |
      | b6e95589-7eb... | cirros-0.3.5-x86_64-uec-kernel  | active |
      | c90893ea-e73... | cirros-0.3.5-x86_64-uec-ramdisk | active |<commit_msg>Fix volume id reference in boot from volume example<commit_after>================================
Launch an instance from a volume
================================

You can boot instances from a volume instead of an image.

To complete these tasks, use these parameters on the
:command:`openstack server create` command:

.. tabularcolumns:: |p{0.3\textwidth}|p{0.25\textwidth}|p{0.4\textwidth}|
.. list-table::
   :header-rows: 1
   :widths: 30 15 30

   * - Task
     - openstack server create parameter
     - Information
   * - Boot an instance from an image and attach a non-bootable
       volume.
     - ``--block-device``
     -  :ref:`Boot_instance_from_image_and_attach_non-bootable_volume`
   * - Create a volume from an image and boot an instance from that
       volume.
     - ``--block-device``
     - :ref:`Create_volume_from_image_and_boot_instance`
   * - Boot from an existing source image, volume, or snapshot.
     - ``--block-device``
     - :ref:`Create_volume_from_image_and_boot_instance`

.. note::

   To attach a volume to a running instance, see
   :ref:`Attach_a_volume_to_an_instance`.

.. _Boot_instance_from_image_and_attach_non-bootable_volume:

Boot instance from image and attach non-bootable volume
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Create a non-bootable volume and attach that volume to an instance that
you boot from an image.

To create a non-bootable volume, do not create it from an image. The
volume must be entirely empty with no partition table and no file
system.

#. Create a non-bootable volume.

   .. code-block:: console

      $ openstack volume create --size 8 my-volume
      +---------------------+--------------------------------------+
      | Field               | Value                                |
      +---------------------+--------------------------------------+
      | attachments         | []                                   |
      | availability_zone   | nova                                 |
      | bootable            | false                                |
      | consistencygroup_id | None                                 |
      | created_at          | 2016-11-25T10:37:08.850997           |
      | description         | None                                 |
      | encrypted           | False                                |
      | id                  | b8f7bbec-6274-4cd7-90e7-60916a5e75d4 |
      | migration_status    | None                                 |
      | multiattach         | False                                |
      | name                | my-volume                            |
      | properties          |                                      |
      | replication_status  | disabled                             |
      | size                | 8                                    |
      | snapshot_id         | None                                 |
      | source_volid        | None                                 |
      | status              | creating                             |
      | type                | None                                 |
      | updated_at          | None                                 |
      | user_id             | 0678735e449149b0a42076e12dd54e28     |
      +---------------------+--------------------------------------+

#. List volumes.

   .. code-block:: console

      $ openstack volume list
      +--------------------------------------+--------------+-----------+------+-------------+
      | ID                                   | Display Name | Status    | Size | Attached to |
      +--------------------------------------+--------------+-----------+------+-------------+
      | b8f7bbec-6274-4cd7-90e7-60916a5e75d4 | my-volume    | available |    8 |             |
      +--------------------------------------+--------------+-----------+------+-------------+

#. Boot an instance from an image and attach the empty volume to the
   instance.

   .. code-block:: console

      $ openstack server create --flavor 2 --image 98901246-af91-43d8-b5e6-a4506aa8f369 \
        --block-device source=volume,id=b8f7bbec-6274-4cd7-90e7-60916a5e75d4,dest=volume,shutdown=preserve \
        myInstanceWithVolume
      +--------------------------------------+--------------------------------------------+
      | Field                                | Value                                      |
      +--------------------------------------+--------------------------------------------+
      | OS-DCF:diskConfig                    | MANUAL                                     |
      | OS-EXT-AZ:availability_zone          | nova                                       |
      | OS-EXT-SRV-ATTR:host                 | -                                          |
      | OS-EXT-SRV-ATTR:hypervisor_hostname  | -                                          |
      | OS-EXT-SRV-ATTR:instance_name        | instance-00000004                          |
      | OS-EXT-STS:power_state               | 0                                          |
      | OS-EXT-STS:task_state                | scheduling                                 |
      | OS-EXT-STS:vm_state                  | building                                   |
      | OS-SRV-USG:launched_at               | -                                          |
      | OS-SRV-USG:terminated_at             | -                                          |
      | accessIPv4                           |                                            |
      | accessIPv6                           |                                            |
      | adminPass                            | <PASSWORD>                               |
      | config_drive                         |                                            |
      | created                              | 2014-05-09T16:34:50Z                       |
      | flavor                               | m1.small (2)                               |
      | hostId                               |                                            |
      | id                                   | 1e1797f3-1662-49ff-ae8c-a77e82ee1571       |
      | image                                | cirros-0.3.5-x86_64-uec (98901246-af91-... |
      | key_name                             | -                                          |
      | metadata                             | {}                                         |
      | name                                 | myInstanceWithVolume                       |
      | os-extended-volumes:volumes_attached | [{"id": "b8f7bbec-6274-4cd7-90e7-60916a... |
      | progress                             | 0                                          |
      | security_groups                      | default                                    |
      | status                               | BUILD                                      |
      | tenant_id                            | ccef9e62b1e645df98728fb2b3076f27           |
      | updated                              | 2014-05-09T16:34:51Z                       |
      | user_id                              | fef060ae7bfd4024b3edb97dff59017a           |
      +--------------------------------------+--------------------------------------------+

.. _Create_volume_from_image_and_boot_instance:

Create volume from image and boot instance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can create a volume from an existing image, volume, or snapshot.
This procedure shows you how to create a volume from an image, and use
the volume to boot an instance.

#. List the available images.

   .. code-block:: console

      $ openstack image list
      +-----------------+---------------------------------+--------+
      | ID              | Name                            | Status |
      +-----------------+---------------------------------+--------+
      | 484e05af-a14... | Fedora-x86_64-20-20131211.1-sda | active |
      | 98901246-af9... | cirros-0.3.5-x86_64-uec         | active |
      | b6e95589-7eb... | cirros-0.3.5-x86_64-uec-kernel  | active |
      | c90893ea-e73... | cirros-0.3.5-x86_64-uec-ramdisk | active |
{'fraction_non_alphanumeric': 0.1857849196538937, 'fraction_numerical': 0.04295426452410383, 'mean_word_length': 0.7449584816132859, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 119, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1791003', 'n_tokens_mistral': 4087, 'n_tokens_neox': 3574, 'n_words': 730}