Volume Operations
This page covers the full lifecycle of a volume: creating, attaching to a VM, formatting and mounting inside the guest, detaching, and deleting. It also shows how to identify volumes inside a VM when multiple are attached.
Create a Volume
Horizon
- Navigate to Volumes > Volumes in the left sidebar.
- Click Create Volume.
- Fill in the form:
- Volume Name — a descriptive name (e.g.
data-vol-01). - Description — optional.
- Volume Source — choose No source, empty volume for a blank volume, or Snapshot / Image / Volume to create from an existing source.
- Type — select the volume type (e.g.
v-ssd-std). If omitted, the default (v-ssd-std) is used. - Size (GB) — the desired size.
- Availability Zone — select the AZ that matches your VM.
- Volume Name — a descriptive name (e.g.
- Click Create Volume.
The volume appears in the list with status available once it is ready.
CLI
openstack volume create data-vol-01 \
--size 100 \
--type v-ssd-std \
--availability-zone ch-zh1-az2
Check that the volume is ready:
openstack volume show data-vol-01 -c status -c id
The status will change from creating to available.
Ansible
- os_volume:
display_name: "data-vol-01"
size: 100
volume_type: "v-ssd-std"
availability_zone: "ch-zh1-az2"
Terraform
resource "openstack_blockstorage_volume_v3" "data_vol_01" {
name = "data-vol-01"
size = 100
volume_type = "v-ssd-std"
availability_zone = "ch-zh1-az2"
}
Attach a Volume to an Instance
A volume must be in available status before it can be attached. Once attached, it behaves like an additional disk inside the VM.
Horizon
- Navigate to Volumes > Volumes.
- Find your volume and open the actions menu (arrow on the right).
- Select Manage Attachments.
- Click + Attach Volume.
- Select the instance from the dropdown.
- Click Attach Volume.
CLI
openstack server add volume <INSTANCE-NAME> <VOLUME-NAME>
Example:
openstack server add volume my-vm data-vol-01
Note
The optional --device argument to specify a device name (e.g. /dev/sdb) should not be used — it does not work reliably and may be removed in future OpenStack releases.
Format and Mount the Volume
After attaching, log into the VM to find, format, and mount the new disk.
Identify the disk
lsblk
Output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
└─sda1 8:1 0 20G 0 part /
sdb 8:16 0 100G 0 disk
The new volume appears as sdb (100 GB in this example).
Partition and format
Install parted if needed:
sudo apt-get install parted # Debian/Ubuntu
sudo yum install parted # RHEL/CentOS
Create a partition and filesystem:
sudo parted -s /dev/sdb mklabel msdos mkpart primary ext4 0% 100%
sudo mkfs -t ext4 -L datavol /dev/sdb1
Tip
Using a label (-L datavol) makes it easier to mount and track the volume later — you don't need to know the exact device name, and /etc/fstab can reference LABEL=datavol instead of /dev/sdb1.
For XFS instead of ext4:
sudo parted -s /dev/sdb mklabel gpt mkpart primary xfs 0% 100%
sudo mkfs.xfs -L datavol /dev/sdb1
Mount
sudo mkdir -p /mnt/data
sudo mount -L datavol /mnt/data
Verify:
df -h /mnt/data
Persist across reboots
Add an entry to /etc/fstab so the volume mounts automatically on boot:
LABEL=datavol /mnt/data ext4 noatime,nodiratime,user_xattr,nofail 0 0
Warning
Use the nofail option to prevent the VM from blocking the boot process if the volume is unavailable (e.g. due to network issues). Remove nofail only if you want the VM to refuse to boot without the volume.
Note
The nobarrier mount option is not recommended. Volumes are accessed via a cache; ignoring the correct ordering of journal commits may corrupt your filesystem in case of a hardware problem.
Detach and Delete a Volume
Detach
Before detaching, unmount the volume inside the VM:
sudo umount /mnt/data
Then detach via Horizon or CLI.
Horizon: Navigate to Volumes > Volumes, open the volume's actions menu, select Manage Attachments, and click Detach Volume.
CLI:
openstack server remove volume <INSTANCE-NAME> <VOLUME-NAME>
Warning
Detaching a volume while it is still mounted is technically possible, but subsequent IO access to that device inside the VM will return I/O errors. Always unmount first.
After detaching, check that the volume is back in available status:
openstack volume show <VOLUME-NAME> -c status
Delete
Once detached, the volume can be deleted. This cannot be undone.
openstack volume delete <VOLUME-NAME>
The volume enters deleting status and disappears from openstack volume list.
Identifying Volumes Inside a VM
When multiple volumes are attached to the same instance, you can map OpenStack volume IDs to block devices inside the guest.
Volumes appear under /dev/disk/by-id/ as entries of the form scsi-0QEMU_QEMU_HARDDISK_<ID>, where <ID> is a prefix of the OpenStack volume ID.
Example — from the OpenStack side:
openstack volume show data-vol-01 -c id -c attachments
| id | 71bd47d8-b51e-4f12-9c51-0445fc36c9e4 |
| attachments | Attached to my-vm on /dev/sdb |
Inside the VM:
ls /dev/disk/by-id/
scsi-0QEMU_QEMU_HARDDISK_71bd47d8-b51e-4f12-9
The fragment 71bd47d8-b51e-4f12-9 matches the beginning of the volume ID 71bd47d8-b51e-4f12-9c51-0445fc36c9e4.