You can only attach a volume to one instances at a time.
Attaching Volume
Web Interface
Click the drop-down menu on the right hand side (in Actions
column) and select MANAGE ATTACHMENTS
...
Note the path in the Attached To
column of the volume
1. | Click the drop-down menu on the right hand side (in |
2. | Select the right instance and press |
3. | Note the path in the |
Command-Line
Get the Server ID
(Instances) and Volume ID
(Volume) using command
...
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
- 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):Code Block theme Emacs sudo mkfs.ext4 /dev/vdb
Use
lsblk
to confirm the device path (usually typedisk
). The value shown in OpenStack can be inaccurate.Code Block theme Emacs $ 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
Mount the volume (we use the folder
/mnt/test-volume
as example)Code Block theme Emacs sudo mkdir /mnt/test-volume
Add this mount point to /etc/fstab, so it will be mounted automatically on startup
Code Block theme Emacs sudo vim /etc/fstab
Add/edit the following line:
Code Block theme Emacs /dev/vdb /mnt/test-volume ext4 defaults 0 0
You still need to manually mount it now
Code Block theme Emacs sudo mount /mnt/test-volume
- (Optional)You may also want to change the permission of the directory using
chmod
to enable read/write withoutsudo
Code Block theme Emacs chmod