Integrating a Block Storage on a Server (Linux)

If you assign block storage to a Linux Cloud Server, you must then mount it in the operating system. In this article, we'll show you how to do it.

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.

  • To list the storage blocks assigned to your server, type the following command:
    :~# lsblk After entering the command, you will see all the important information about the existing disks and the assigned storage blocks.

    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 example above, a block of 20 GB of storage is assigned with the name sdc.

  • Optional: If you are using the block storage for the first time, you must format this drive before using it. When you format the drive, all the data on it is deleted. To format the drive, type the sudo mkfs.ext4 command in the following format:
    :~# sudo mkfs.ext4 [block storage name] Example:
    :~# sudo mkfs.ext4 /dev/sdc After entering the command, you will see the following message:
    :~# mke2fs 1.42.9 (28-Dec-2013)
        /dev/sdc is entire device, not just one partition!
        Proceed anyway? (y,n)

  • Type y and press the Enter key. The block storage is now formatted.

  • A mountpoint must be created for the block storage. To create it, type the following command:
    :~# sudo mkdir /mnt/block

  • Open /etc/fstab with the editor (such as vi) and insert the desired mount point in the following format:
    /dev/sdc /mnt/block auto defaults 0 0
    The drive is now mounted.

  • To check the new entry in /etc/fstab and mount the shared storage, type the following command:
    :~# mount -a
  • To access the drive, type the following command:
    :~# cd /mnt/block