# Elastic Volume Service (EVS)

EVS is flexible disk provisioning for Elastic Cloud Server (EVS). Use this for production deployments where needed, so that the disk space can flexibly expanded. This prevents the need for compute migrations that cause more overhead.

## EVS Setup

1. Go to the EVS portal
2. "Create disk"
3. Choose the region of your destination server (for optimal performance)
4. Choose "General Purpose SSD"
5. Choose somewhere between 10-25GB
6. Encrypt the volume according to the threat model (if unknown, `evs/default`)
7. Optional: Add informative tags (for example, `libscie=sso`)
8. Give an informative name (for example, `org.libscie.git` for the service on `https://git.libscie.org`)

We recommend using one EVS per production service, to allow for compartmentalization of disks per service. Services may be on the same server at this time, but that is not a guarantee it will remain so.

Note that disk space can be expanded at any time in the future, so if you are unsure about your needs, pick 25GB to start.

### Attaching EVS to ECS

Upon creation of your EVS, it will need to be attached to be useful (see also [OTC docs](https://docs.otc.t-systems.com/elastic-volume-service/umn/getting_started/initializing_an_evs_data_disk/introduction_to_data_disk_initialization_scenarios_and_partition_styles.html)). If you created an EVS during the server creation, it will already be attached!

Conceptually, you will partition, format, and attach the disk.

#### Partitioning

1. SSH into the server
2. Run `fdisk -l` or `lsblk` to identify the newly attached drive
3. Run `fdisk /dev/vdb` (double check the drive with results from step 2) to start formatting the disk
4. Return `n` to initialize the formatting
5. Return `p` to setup one primary partition
6. Take the default values for the next three steps (that is, press `Enter` three times)
7. Optional: Check the partitions by returning `p`
8. Return `w` to write partitions to disk

#### Formatting

1. Run `partprobe`
2. Run `mkfs -t ext4 /dev/vdb1` (double check the `ext4` and `/dev/vdb1` for your scenario)

#### Attaching (aka "mounting")

1. Identify the path where you want the disk to be attached (for example, `/mnt/evs-disk`)
2. Run `mount /dev/vdb1 /mnt/evs-disk` (replacing the disk and attachment path)

This attaches the drive until the server is rebooted. 

##### Attaching the disk upon boot

1. Find the UUID for the disk `blkid /dev/vdb1`
```
/dev/vdb1: UUID="905943cb-c59b-401d-b686-22e0c1131869" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="fae0084f-01"
```
2. Open the config file: `nano /etc/fstab`
3. Add a new line with the specific mount information, for example
```
UUID=905943cb-c59b-401d-b686-22e0c1131869  /mnt/evs-disk  ext4  defaults  0 2
```
4. Unattach the manually attached drive: `umount /dev/vdb1`
5. Reload the `fstab` config - run `systemctl daemon-reload`
6. Check your disk is attached

## Expanding existing EVS

https://docs.otc.t-systems.com/elastic-volume-service/umn/expanding_evs_disk_capacity/index.html

https://docs.otc.t-systems.com/elastic-volume-service/umn/expanding_evs_disk_capacity/extending_disk_partitions_and_file_systems_linux/extending_partitions_and_file_systems_for_data_disks_linux.html#evs-01-0109-en-us-topic-0044524728-section31113372194023

## Migrating an EVS between servers

Elastic Volume Services (EVS) can be unmounted and remounted on another Elastic Cloud Server (ECS) as needed. However, be careful to not multi-mount an EVS, considering it is not made for this purpose. Elastic Volume Service (EVS) is made for single mount only, multi-mount is possible with a Scalable File Service (SFS).

Conceptually, migrating and EVS is simple: Unmount from current server and mount onto the new one. **Be sure to create a backup prior to prevent any data loss!**

1. Go to your current server and stop the services using the drive
2. Unmount the drive: `sudo umount /dev/vdb1` (adjusted for your drive, see `df`)
3. Go to the OTConsole and detach the drive from the Elastic Cloud Server (ECS)
4. Attach the drive to the new Elastic Cloud Server (ECS)
5. Find the relevant drive using `sudo lsblk` (check for the sizes)
6. Add the mount point to `/etc/fstab` to ensure it is mounted upon boot