In this article:

Allocating Disk Section

Creating the LVM Section

Setting Up Persistent Volume Storage Sections

If the Longhorn storage is used, it is recommended to allocate a separate section of about 250-300 GB in size on each work node. To increase fault-tolerance, one should increase storage volume accordingly.

NOTE. If at least 350 GB is allocated at each work node in the root section, skip this step and proceed to installing the Longhorn storage.

To set up a persistent volume storage section on each work node:

  1. Select the disk section.

  2. Create the LVM section.

It is assumed that the required storage space is unmapped in the existing section or is connected as a separate unmapped section.

To view mapped and unmapped sections and corresponding mount points, execute the command:

lsblk

Next, determine the section with unmapped space of at least 250 GB.

Allocating Disk Section

To allocate a disk section:

  1. Execute commands using SSH key from any directory:

# fdisk /dev/<disk name>
n
p

In the <disk name> substitution specify disk name with unmapped section.

  1. Press the ENTER key three times.

  2. Continue executing the commands:

t
<disk section number>
8e
w

If the disk contains only one section, its number may not be specified.

After executing the operations the disk section is allocated on each work node.

Creating the LVM Section

To create the LVM section with 250 GB size:

  1. Initialize the disk for the LVM section:

# pvcreate /dev/<disk name><disk section number>

For example:

# pvcreate /dev/sdb1

  1. Create a group of volumes:

# vgcreate <name of group of volumes> /dev/<disk name><section number on the disk>

For example:

# vgcreate vg_data /dev/sdb1

After executing the operation, the group of volumes is created with the specified name in the specified section.

  1. Create a logical volume:

# lvcreate -L 250G -n <logical volume name> <name of group of volumes>

For example:

# lvcreate -L 250G -n lv_longhorn vg_data

After executing the operation, the logical volume is created with the specified name and 250 GB size in the specified group of volumes.

  1. Create the ext4 file system in the logical volume:

# mkfs.ext4 /dev/mapper/<name of group of volumes>-<logical volume name>

For example:

# mkfs.ext4 /dev/mapper/vg_data-lv_longhorn

  1. Create the /mnt/longhorn/data folder, in which the volume will be mounted:

# mkdir -p /mnt/longhorn/data

  1. Add a section for automatic mounting to the /etc/fstab folder:

# echo "/dev/mapper/<name of group of volumes>-<logical volume name> /mnt/longhorn/data ext4 defaults 0 1" | sudo tee -a /etc/fstab

For example:

# echo "/dev/mapper/vg_data-lv_longhorn /mnt/longhorn/data ext4 defaults 0 1" | sudo tee -a /etc/fstab

  1. Restart the work node and check the created LVM section:

df -h

The example of response:

/dev/mapper/vg_data-lv_longhorn 246G 36K 246G 1% /mnt/longhorn/data

After executing the operations the /mnt/longhorn/data folder with the ext4 file system and available size 250 GB is created at each work node.

Next, install the Longhorn storage.

See also:

Preparation and Deployment of Fault-Tolerant Cluster Based on Kubernetes | Installing and Setting Up Longhorn Storage