Attaching and Accessing Volumes to an instance
You can only attach a volume to one instance at a time.
Attaching Volume
Web Interface
Click the drop-down menu on the right-hand side (in
Actions
column) and selectMANAGE ATTACHMENTS
Select the right instance and press
ATTACH VOLUME
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
Log-in to the attached instance using SSH
(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):Use
lsblk
to confirm the device path (usually typedisk
). The value shown in OpenStack can be inaccurate.Mount the volume (we use the folder
/mnt/test-volume
as example)Add this mount point to /etc/fstab, so it will be mounted automatically on startup
Add/edit the following line:
You still need to manually mount it now
(Optional)You may also want to change the permission of the directory using
chmod
to enable read/write withoutsudo