Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

Attaching Volume

Web Interface

  1. Click the drop-down menu on the right

...

Select the right instance and press ATTACH VOLUME

Note the path in the Attached To column of the volume

...

  1. -

...

  1. hand side (in Actions column) and select MANAGE ATTACHMENTS

...

  1. Image Added
  2. Select the right instance and press ATTACH VOLUME

...

  1. Image Added
  2. Note the path in the Attached To column of the volume

    Image Added

Command-Line

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

Code Block
$ 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

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


Code Block
$ 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)

    Code Block

...

themeEmacs
  1. sudo mkfs.ext4 /dev/vdb


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

    Code Block

...

  1. $ lsblk
    
    NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    loop0     7:0    0 73.1M  1 loop /snap/lxd/21902
    loop1     7:1    0 55.4M  1 loop /snap/core18/2128
    loop3     7:3    0 72.6M  1 loop /snap/lxd/21750
    loop4     7:4    0 61.9M  1 loop /snap/core20/1169
    loop5     7:5    0 32.5M  1 loop /snap/snapd/13640
    loop7     7:7    0 42.2M  1 loop /snap/snapd/14066
    loop8     7:8    0 55.5M  1 loop /snap/core18/2253
    loop9     7:9    0 61.9M  1 loop /snap/core20/1242
    sr0      11:0    1  470K  0 rom  /mnt/context
    vda     252:0    0   20G  0 disk
    ├─vda1  252:1    0 19.9G  0 part /
    ├─vda14 252:14   0    4M  0 part
    └─vda15 252:15   0  106M  0 part /boot/efi
    vdc     252:32   0    3G  0 disk


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

    Code Block

...

...

  1. sudo mkdir /mnt/test-volume


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

    Code Block

...

  1. sudo vim /etc/fstab 


  2. Add/edit the following line: 

    Code Block

...

...

  1. /dev/vdb /mnt/test-volume ext4 defaults 0 0


  2. You still need to manually mount it now 

    Code Block

...

  1. sudo mount /mnt/test-volume


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


    Code Block

...

  1.  chmod