Persistent volume storage ("volumes") is Nectar's way of providing you with disk space. Volumes  are virtual devices; they can live alongside your virtual machine. A volume's life cycle is independent of a virtual machine, but manipulating data on a volume typically requires that it is attached to a virtual machine. Volumes appear as block storage devices and are typically used to hold a file system, mounted into your operating system, making the storage available to your applications. Volumes can be unmounted and detached from a VM and attached to and mounted on another. Data on a volume persists even when you terminate your virtual machine. You can make bootable volumes, you can use volume snapshots and a volume can be transferred to another project.

In this article you can read some basic instructions on how to use Volume Storage in Nectar. You will require a suitable volume allocation. You will learn to create, attach and detach volumes using the Nectar dashboard. You will use Linux commands to format (if necessary), mount and unmount your volumes, and check your volume's usage. 

We also have a step by step tutorial for how to create and use volume storage. Please visit Nectar Tutorial Website.

Allocation for Persistent Volume Storage

A volume storage allocation can be requested using the Allocation Request form, under Allocations on your dashboard, either as part of a New Request (resulting in a new project) or as an amendment to an existing project under My Requests. 

Like instances, volumes are hosted in an availability zone and importantly volumes can only be attached to instances running in the same availability zone. When requesting a volume storage allocation, you will need to consider where your solution will be hosted. 

Volume Service. The section of the Allocation Request form where you can request Volume Storage allocation/s

Create a persistent volume storage

You can see your project's volume storage allocation on the Project | Compute | Overview page on your Nectar dashboard, e.g. 

To create a volume

  • On your Nectar Cloud Dashboard;

  • navigate to Volumes | Volumes;

  • click the '+ Create Volume' button;

  • give your volume a meaningful name and description;

  • specify a 'Volume Source' to determine how the volume will be built;

  • specify the size of the volume in GB;

  • enter an 'Availability Zone' (this must be the same zone as any instance it will be attached to);

  • click 'Create Volume' button.

When selecting Image for Volume Source, you will be able to select an image from the image catalog. This is useful for creating bootable volumes.

When selecting Volume for Volume Source, you will be able to select from the existing volumes in your project. 

Attach a volume to an instance

You can attach the volume created earlier to a running virtual machine. See the below instruction:

  • On your Nectar Cloud Dashboard;

  • navigate to Volumes | Volumes;

  • from the ActionMenu for the Volume, select 'Manage Attachments'

  • in the Attach to Instance section of the 'Manage Volume Attachments' dialog, select the instance to attach your volume to.

  • click 'Attach Volume' button

Nectar will now attach your volume to the selected instance. When this is complete your volume (on the Volumes | Volumes page) will show a value in the Attached To column similar to '/dev/vdc on acme_instance'

Formatting and mounting

You can verify the device name that your attached volume will have in your instance in the Attached To column on the Volumes | Volumes page on your Nectar dashboard. 

In your instance you can see the attached Volume as a Block Device using the lsblk (list block devices) command. 

ubuntu@acme-vm:~$ lsblk
vda    252:0    0  10G  0 disk
└─vda1 252:1    0  10G  0 part /
vdb    252:16   0  60G  0 disk /mnt
vdc    252:32   0  65G  0 disk

Depending on how you created your volume, it may not have a file system and you need to create one before mounting, i.e. format the device. The exact format command syntax is dependent on the virtual machine's operating system and the type of file system you need. The example below formats the volume attached as '/dev/vdc/' in the Ubuntu-based instance 'acme-vm' using the 'ext4' filesystem. 

ubuntu@acme-vm:~$ sudo mkfs -t ext4 /dev/vdc

WARNING: Formatting a device/volume erases all existing data on a device, if a file system already exists on the target device/volume.

WARNING: Formatting a device/volume erases all existing data on a device, if a file system already exists on the target device/volume.

To make your volume/device available to the operating system you need to mount it on a directory called a mount point. You can mount your device using an in-memory-only mount, but the mount will be lost upon rebooting your instance. We recommend you configure the mounting of your device/volume filesystem using the configuration file /etc/fstab.

In memory only
You can use below commands to create a mount point called /pvol and  to mount the device /dev/vdc at that mount point.

ubuntu@acme-vm:~$ sudo mkdir /pvol
ubuntu@acme-vm:~$ sudo mount /dev/vdc /pvol -t auto

Using /etc/fstab
 To ensure that your Volume is remounted after a reboot of your instance, you should configure it in the file '/etc/fstab'. Use a text editor to add the following line to /etc/fstab, where /dev/vdc is the device you're mounting and /pvol is the its target mount point.

/dev/vdc  /pvol    auto    defaults,nofail   0  2

After adjusting the /etc/fstab file you need to initiate any changes. Use the mount all command:

ubuntu@acme-vm:~$ sudo mount --all

You may have to change ownership or write privileges to enable writing to the ephemeral storage, using chown, chgrp or chmod, e.g.

ubuntu@acme-vm:~$ sudo chown ubuntu:ubuntu /pvol

* your use-case or operating system may require a different approach than this example. 

Unmounting and detaching

You can use the umount command (note the spelling of the umount command) to unmount your device from its mount point (here /pvol). E.g.

ubuntu@acme-vm:~$ sudo umount /pvol

You can use the Nectar dashboard to detach a volume from an instance. Navigate to the Volumes | Volumes page, and use the ActionMenu for your volume to show the Manage Volume Attachments dialog. (Alternatively you can use the ActionMenu of the instance on the Compute | Instances page)

Notes: Volumes must be detached before deletion.

Check your Storage

You attached and mounted volume storage will behave like any other disk/block device in Linux. Here are some commands that can allow you to look at your mounted storage blocks and keep track of their usage:

lsblk -l for info : man lsblk

df -hT for info : man df

du -h <path/to/directory> for info : man du