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

In the example we connect to the virtual machine called test-vol4gb as eouser using ssh. First we can see that there are no additional volumes attached.

[eouser@test-vol4gb ~]$ lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 16G 0 disk
└─vda1 253:1 0 16G 0 part /

If the volume does not exist yet, it must be created. Go to Horizon, Volumes, click “Create Volume”. Give it an appropriate name, select size and disk type (either HDD-default or SSD).

../_images/volattach1.png
../_images/volattach2.png

Now, from the volume menu, select “Manage Attachments” and attach the volume to the desired instance. It becomes visible in it as a block device, like /dev/vdb

../_images/volattach3.png

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

../_images/volattach4.png

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

[eouser@test-vol4gb ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 16G 0 disk
└─vda1 253:1 0 16G 0 part /
vdb 253:16 0 4G 0 disk
check is gdisk is installed:
[eouser@test-vol4gb ~]$ gdisk
-bash: gdisk: command not found
install gdisk (Centos):
[eouser@test-vol4gb ~]$ sudo yum check-update
[eouser@test-vol4gb ~]$ sudo yum install -y gdisk
Loaded plugins: fastestmirror
...
Installed:
gdisk.x86_64 0:0.8.6-5.el7

Dependency Installed:
libicu.x86_64 0:50.1.2-15.el7

Complete!

[eouser@test-vol4gb ~]$ sudo gdisk /dev/vdb

GPT fdisk (gdisk) version 0.8.6

Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present

Creating new GPT entries.

Command (? for help): n
Partition number (1-128, default 1):
First sector (34-8388574, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-8388574, default = 8388574) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/vdb.
The operation has completed successfully.

[eouser@test-vol4gb ~]$ lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 16G 0 disk
└─vda1 253:1 0 16G 0 part /
vdb 253:16 0 4G 0 disk
└─vdb1 253:17 0 4G 0 part

[eouser@test-vol4gb ~]$ sudo mkfs.ext4 /dev/vdb1

mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
262144 inodes, 1048315 blocks
52415 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1073741824
32 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

Edit the file /etc/fstab using your favourite editor (nano, vim etc.):

[eouser@test-vol4gb ~]$ sudo vim /etc/fstab

and add the line:

/dev/sdb1 /my_volume ext4 defaults 0 1

Create the mounting point:

[eouser@test-vol4gb ~]$ sudo mkdir /my_volume

Now mount the volume in the system:

[eouser@test-vol4gb ~]$ sudo mount /my_volume

[eouser@test-vol4gb ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 16G 2,5G 14G 16% /
devtmpfs 906M 0 906M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 8,4M 912M 1% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
tmpfs 184M 0 184M 0% /run/user/1000
tmpfs 184M 0 184M 0% /run/user/0
/dev/vdb1 3,9G 16M 3,7G 1% /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.