Integrating a Block Storage on a Server (Linux)

If you assign a block storage to a Cloud Server on which a Linux operating system is installed, you must then integrate this on the server. To integrate a block storage on your server: 

Prerequisites: 

You have created a block storage. 

You have assigned the block storage to the server. 

You have logged in to the server as an administrator.

Step 1

To list the block storage assigned to the server, enter the following command:

lsblk

After entering the command, you will see all the important information about the drives and the assigned block storage. Example:

NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   80G  0 disk
sda1              8:1    0    1G  0 part /boot
sda2              8:2    0   79G  0 part
  centos-root   253:0    0   77G  0 lvm  /
  centos-swap   253:1    0    2G  0 lvm  [SWAP]
sdc               8:32   0   20G  0 disk
sdc1              8:33   0    1M  0 part
sdc2              8:34   0  127M  0 part
sdc3              8:35   0 19.9G  0 part
sr0              11:0    1 1024M  0 rom

In the above example, the server is allocated a block storage with a size of 20 GB. This has the name sdc.

Step 2

Optional: if you are using the block storage for the first time, you must format this drive before you first use it. When you format the drive, all data on it will be deleted. To format the drive, enter the sudo mkfs.ext4 command in the following format:

sudo mkfs.ext4 [Name des Block Storages]

Example:

sudo mkfs.ext4 /dev/sdc

After entering the command, the following message will be displayed:

mke2fs 1.42.9 (28-Dec-2013)
/dev/sdc is entire device, not just one partition!
Proceed anyway? (y,n)
Step 3

Enter y and press the Enter key.

The block storage has been formatted.

Step 4

A mount point must be created to mount the block storage. To create this, enter the following command:

sudo mkdir /mnt/block
Step 5

Open /etc/fstab with the editor (for example, vi) and insert the required attachment point in the following format:

/dev/sdc /mnt/block auto defaults 0 0
Step 6
To check the new entry in /etc/fstab and mount the shared storage, enter the following command:
mount -a

The drive is mounted.

Step 7

To access the drive, type the following command:

cd /mnt/block