/
Attaching and Accessing Volumes to an instance

Attaching and Accessing Volumes to an instance

You can only attach a volume to one instance at a time.

Attaching Volume

Web Interface

  1. Click the drop-down menu on the right-hand side (in Actions column) and select MANAGE ATTACHMENTS

  2. Select the right instance and press ATTACH VOLUME

  3. Note the path in the Attached To column of the volume


Command-Line

Get the Server ID (Instances) and Volume ID (Volume) using command

$ openstack server list +--------------------------------------+--------------------------+--------+----------------------------------------+---------------------------------------------------------+--------------+ | ID | Name | Status | Networks | Image | Flavor | +--------------------------------------+--------------------------+--------+----------------------------------------+---------------------------------------------------------+--------------+ | 6b2bedc4-9d8e-4bf3-be63-1dd49bc2e188 | test-resize-rebuild | ACTIVE | Internal=172.16.102.207 | ubuntu-focal-20.04-gui | c3.small | +--------------------------------------+--------------------------+--------+----------------------------------------+---------------------------------------------------------+--------------+ $ openstack volume list +--------------------------------------+-------------------+-----------+------+-----------------------------------+ | ID | Name | Status | Size | Attached to | +--------------------------------------+-------------------+-----------+------+-----------------------------------+ | 2d61791d-5f52-46e1-81ac-05221c308fe8 | test-cli-snapshot | available | 3 | | +--------------------------------------+-------------------+-----------+------+-----------------------------------+

Run

openstack server add volume <server-id> <volume-id> --device <device-name>



$ openstack server add volume 6b2bedc4-9d8e-4bf3-be63-1dd49bc2e188 2d61791d-5f52-46e1-81ac-05221c308fe8 --device /dev/vdb +-----------+--------------------------------------+ | Field | Value | +-----------+--------------------------------------+ | ID | 2d61791d-5f52-46e1-81ac-05221c308fe8 | | Server ID | 6b2bedc4-9d8e-4bf3-be63-1dd49bc2e188 | | Volume ID | 2d61791d-5f52-46e1-81ac-05221c308fe8 | | Device | /dev/vdb | +-----------+--------------------------------------+

Accessing the volume

  1. Log-in to the attached instance using SSH

  2. (Optional only for new volume) Format the volume (we use ext4 here and assume the attach point is /dev/vdb) (Formatting will wipe your data)



  3. Use lsblk to confirm the device path (usually type disk). The value shown in OpenStack can be inaccurate.



  4. Mount the volume (we use the folder /mnt/test-volume as example)



  5. Add this mount point to /etc/fstab, so it will be mounted automatically on startup 



  6. Add/edit the following line: 



  7. You still need to manually mount it now 



  8. (Optional)You may also want to change the permission of the directory using chmod to enable read/write without sudo





Related content

Create Volume in Web Interface and CLI
Create Volume in Web Interface and CLI
More like this
Detaching a Volume
Detaching a Volume
More like this
Using the OpenStack Command Line Interface
Using the OpenStack Command Line Interface
Read with this
Volume Management in OpenStack
Volume Management in OpenStack
More like this
Create Volume Snapshot
Create Volume Snapshot
More like this
Deleting Volumes
Deleting Volumes
More like this