# Network-Attached Volumes

Additional SSD storage volumes that can be attached to your VPS instances.

## Overview

Volumes are network-attached block storage devices powered by [Longhorn](https://longhorn.io/), providing persistent storage that can be attached and detached from VPS instances without requiring a restart. Volumes are independent from your VPS instance and persist even when the VPS is stopped or deleted.

### Key Benefits

- **Hotpluggable**: Attach and detach volumes on running VMs without downtime
- **Persistent**: Data survives VPS restarts and can outlive the VPS instance
- **Flexible Sizing**: 10 GB to 500 GB, expandable at any time
- **Replicated**: Data is replicated across nodes for redundancy

## Performance

Volumes use network-attached storage, which means data travels over the network between nodes. This results in different performance characteristics compared to the local NVMe root disk.

### Benchmark Comparison

| Metric | Root Disk (Local NVMe) | Volume (Network-Attached) |
|--------|----------------------|--------------------------|
| Sequential Write | ~2.4 GB/s | ~50 MB/s |
| Sequential Read | ~10.2 GB/s | ~75 MB/s |
| Interface | virtio-blk | virtio-scsi |
| Storage Backend | OpenEBS LVM (local NVMe) | Longhorn (replicated) |

### Why the Difference?

The root disk of your VPS uses **local NVMe SSDs** with direct access to the physical drive, delivering full NVMe speeds. Volumes use **Longhorn network-attached storage**, where data is replicated across multiple nodes over the network for redundancy. The current 1 Gbps network interconnect between nodes is the primary bottleneck (~125 MB/s theoretical max).

### Upcoming Improvement

We are planning a **10 Gbps network upgrade** that will significantly improve volume throughput, bringing speeds closer to 1 GB/s.

### Recommended Use Cases

Volumes are ideal for:

- **Bulk data storage** (media files, archives, logs)
- **Backup targets** and data exports
- **Application data** that doesn't require high IOPS
- **Extra storage** when your root disk profile isn't enough

For latency-sensitive workloads (databases, caches, heavily accessed application files), keep your data on the local NVMe root disk.

## Pricing

Volumes are billed at **EUR 0.04/GB/month**, calculated hourly.

| Size | Monthly Cost |
|------|-------------|
| 10 GB | EUR 0.40 |
| 50 GB | EUR 2.00 |
| 100 GB | EUR 4.00 |
| 500 GB | EUR 20.00 |

## Getting Started

### Creating a Volume

1. Navigate to **Storage > Volumes** in the dashboard
2. Click **Create Volume**
3. Choose the volume size (10 - 500 GB)
4. Enter a name for the volume
5. Select the VPS instance to attach it to
6. Click **Create & Buy now**

The volume will be created and automatically hot-plugged into your running VPS within a few seconds.

### Using the Volume Inside Your VPS

Once attached, the volume appears as a new block device (typically `/dev/sda` or `/dev/sdb`). You need to format and mount it:

```bash
# Check available disks
lsblk

# Create a filesystem (first time only)
mkfs.ext4 /dev/sda

# Create a mount point and mount
mkdir -p /mnt/volume
mount /dev/sda /mnt/volume

# Verify
df -h /mnt/volume
```

To make the mount persist across reboots, add it to `/etc/fstab`:

```bash
echo '/dev/sda /mnt/volume ext4 defaults,nofail 0 2' >> /etc/fstab
```

### Resizing a Volume

Volumes can only be expanded, not shrunk:

1. Go to **Storage > Volumes**
2. Click **Resize** on the volume
3. Enter the new size
4. The PVC expansion happens online, no restart required

After resizing, expand the filesystem inside the VPS:

```bash
resize2fs /dev/sda
```

### Detaching a Volume

1. Inside the VPS, unmount the volume first:
   ```bash
   umount /mnt/volume
   ```
2. Go to **Storage > Volumes**
3. Click **Detach** on the volume

**Warning**: Detaching a volume permanently deletes the volume and all data on it.

## Technical Details

- **Storage Backend**: Longhorn (replicated block storage)
- **Storage Class**: `longhorn-vps-volume`
- **Volume Mode**: Block
- **Access Mode**: ReadWriteOnce
- **Bus**: SCSI (for hotplug compatibility)
- **Filesystem**: User's choice (ext4 recommended)
- **Replication**: Configurable via Longhorn (default: 3 replicas)

---

**Questions?** Contact support at support@danubedata.ro
