# Storage

OpenStack offers two kinds of persistent storage that survive instance termination:

- **Volumes (Cinder)**: block storage attached to a single instance, like a hard drive.
- **Shares (Manila)**: shared file systems, such as NFS or CephFS, that can be mounted by multiple instances at once.

## Volumes (Cinder)

Volumes are attached to an instance as a block device (for example `/dev/vdb`). You can add a volume when launching an
instance or attach one later.

To create and attach a volume in Horizon:

1. Go to **Project → Volumes → Volumes** and click **Create Volume**.
2. Give it a **name** and a **size** (GB), then click **Create Volume**.
3. Next to the volume, click **Manage Attachments → Attach to Instance**, select your instance and save.

After attaching, you can format and mount it from inside the instance:

``` bash
sudo mkfs.ext4 /dev/vdb            # only the first time
sudo mkdir /mnt/data
sudo mount /dev/vdb /mnt/data
```

To make the mount persist across reboots, add an entry to `/etc/fstab`.

!!! note
    The root disk of an instance is also a volume (backed by Ceph). Treat it the same way: attach additional volumes
    for data you want to keep.

## Shares (Manila/CephFS)

A share is a file system that several instances can mount at the same time. We currently offer NFS shares backed by
Ceph. Shares are provisioned as a *share network* within your project, and instances that need to mount them must be
on that network.

To create a share in Horizon:

1. Go to **Project → Share → Shares** and click **Create Share**.
2. Choose the **share type** (e.g. NFS), a **size**, and the **share network** of your project.
3. Once the share is `available`, mount it from an instance on the same share network:

   ``` bash
   sudo mkdir /mnt/share
   sudo mount -t nfs <share path> /mnt/share
   ```

The exact mount command is shown in the Horizon share details.

!!! warning
    Shares, like all OpenStack storage, are not location-redundant. Use them for data you can recreate, not for
    mission-critical backups.

## Related

- [Creating a virtual machine](https://datalab.tuwien.ac.at/infrastructure/openstack/creating-a-vm/)
- [Networking](https://datalab.tuwien.ac.at/infrastructure/openstack/networking/)