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

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

...

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

...

Code Block
themeEmacs
$ 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
    sudo mkfs.ext4 /dev/vdb


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

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


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

    Code Block
    themeEmacs
    sudo mkdir /mnt/test-volume


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

    Code Block
    themeEmacs
    sudo vim /etc/fstab 


  6. Add/edit the following line: 

    Code Block
    themeEmacs
    /dev/vdb /mnt/test-volume ext4 defaults 0 0


  7. You still need to manually mount it now 

    Code Block
    themeEmacs
    sudo mount /mnt/test-volume


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


    Code Block
    themeEmacs
     chmod