How to attach a volume to VM less than 2TB on Linux on ESA HPC

If the volume does not exist yet, it must be created. Go to Horizon, Volumes, click Create Volume.

../_images/volattach1.png

Give it an appropriate name, select size and disk type (either HDD-default or SSD).

../_images/volattach2.png

Now, from the volume menu, select “Manage Attachments” and attach the volume to the desired instance.

../_images/volattach3.png
../_images/volattach4.png

It becomes visible in it as a block device, like /dev/vdb or /dev/sdb (depending on what disk type we chose), e.g:

../_images/volattach5.png

If the volume had not been used before (it has been freshly created), it must be first partitioned and formatted. Open the terminal and type:

$ sudo fdisk /dev/sdb
Command (m for help): n

Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p):<ENTER>
Using default response p.
Partition number (1-4, default 1): <ENTER>
First sector (2048-104857599, default 2048): <ENTER>
Last sector, +sectors or +size{K,M,G,T,P} (2048-104857599, default 104857599): <ENTER>
Created a new partition 1 of type 'Linux' and of size 50 GiB.
Command (m for help): w

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

$ lsblk /dev/sdb
$ sudo mkfs.ext4 /dev/sdb1

Previously used volume (moved from another VM) is usually already partitioned and formatted.

Now mount the volume in the system. Edit the file /etc/fstab with ‘sudo’ by using your favourite editor (nano, vim etc.):

$ sudo vim /etc/fstab

Add the line:

/dev/sdb1 /my_volume ext4 defaults 0 1

and create a mounting point, then mount it:

$ sudo mkdir /my_volume
$ sudo mount /my_volume

On the next reboot, the volume will be mounted automatically. Volumes may be attached to a live system, without the need to reboot it.