Integrating a Block Storage on a Server (Linux)
Please use the “Print” function at the bottom of the page to create a PDF.
For Cloud Server
If you assign a block of storage to a Linux Cloud Server, you must then mount it on that server. To mount a block of storage on your server, follow the steps below.
Requirements
You have created a block of storage.
You have assigned the block storage to the server.
You have logged on to the server as administrator.
Create Partition
To list the block of storage that is assigned to your server, type the following command:
:~# lsblk
After typing the command, you will be shown all the important information about the available disks and the assigned block of storage. Example:
root@localhost:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 487M 0 part /boot
└─sda2 8:2 0 99.5G 0 part
├─vg00-lv00 253:0 0 1.9G 0 lvm [SWAP]
└─vg00-lv01 253:1 0 97.6G 0 lvm /
sdb 8:16 0 20G 0 disk
sr0 11:0 1 1024M 0 romIn the above example, a block of storage with a size of 20 GB is assigned. This block has the name sdb.
To call the /dev/sdb partition in fdisk, type the following command:
[root@localhost ~]# fdisk /dev/sdb
After typing the command, the following message is displayed:
[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.37.4).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xc0e4ed63.To add a partition, type n. Then press Enter.
Command (m for help):
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extendedTo select the partition type Primary, type p. Then press Enter.
Select (default p): p
Enter the partition number of the partition. Example:
Partition number (1-4, default 1): 1
Enter the start sector. Example:
First sector (2048-41943039, default 1050624): 2048
To use all the available storage space, press Enter.
After the input the following information will be displayed after entering:Last sector, +sectors or +size{K,M,G,T,P} (2048-41943039, default 41943039):
Created a new partition 1 of type 'Linux' and of size 20 GiB.To check the changed partition table, type p. Then press Enter.
To write the partition table to the Storage block and exit the program, type w.
Restart the server.
Formatting the hard disk
When you use the Storage block for the first time, you must format this drive before using it for the first time. Formatting the drive will erase all data on it.
To format the drive, type the command sudo mkfs.ext4 in the following format:
[root@localhost ~]# sudo mkfs.ext4 [name of the block storage]
Example:
[root@localhost ~]# sudo mkfs.ext4 /dev/sdb1
mke2fs 1.446 (5-Mar-2019)
Creating filesystem with 5242624 4k blocks and 1310720 inodes
Filesystem UUID: 1c6b3ca0-ac85-4a64-8c50-c267ad829f99
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
The block Storage is formatted.
Mount Block Storage
In order to mount the Block Storage, a mount point must be created. To create this, type the following command:
[root@localhost ~]# sudo mkdir /mnt/block
Open /etc/fstab with the editor (e.g. vi). To do this, enter the following command:
[root@localhost ~]# sudo vi /etc/fstab
Add the desired mounting point in the following format:
/dev/sdb1 /mnt/block auto defaults 0 0
Note
The editor vi has an insert mode and a command mode. You can access the insert mode with the i key. In this mode, the characters entered are immediately inserted into the text. To call up the command mode, press the ESC key afterwards. If you use the command mode, your keyboard entries are interpreted as a command.
To save the changes made, press the ESC key and type :wq. Then press Enter.
To have the new entry in /etc/fstab checked and the block storage mounted, enter the following command:
[root@localhost ~]# mount -a
To access the drive, enter the following command:
[root@localhost ~]# cd /mnt/block