GlusterFS or Gluster File System, is a free and open-source distributed file system developed by RedHat. GlusterFS is a scalable file system formed from several servers into one entity file system that allows users to connect and mount the GlusterFS volume.

GlusterFS is a modern file system that can handle petabytes of data. Also, it’s easy to install and maintain, and also easy to scale the file system.

In the following guide, I’ll take you through the installation of GlusterFS on Debian 12 servers. We will create a high-available and replicated storage system with GlusterFS using multiple Debian servers. You will also learn how to mount GlusterFS to a Debian client machine and set up auto-mount of GlusterFS volume via /etc/fstab file.

Prerequisites

Before you proceed with this guide, confirm that you have the following:

  • Multiple Debian 12 servers – This example uses 3 Debian servers for creating the GlusterFS Cluster.
  • A non-root user with administrator privileges.
  • A Debian client machine.

Partitioning Disk with Parted

Before you get started, you will create a new partition that will be used for GlusterFS on each server. In this example, you will create a partition from disk /dev/sdb with a Parted partition manager.

Install parted to your Debian servers using the following apt command.

sudo apt install parted -y

<img alt="install parted" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/18-install-parted.png650c748d2b283.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="287" loading="lazy" src="data:image/svg xml,” width=”750″>

Execute the following parted command to start partitioning the /dev/sdb disk.

sudo parted /dev/sdb

After executing the parted command, you should be in the parted environment.

Run the following command to create a new partition table for disk /dev/sdb to msdos.

mklabel msdos

Now run the command below to create a new primary partition /dev/sdb1 with format ext4 and size 5 GB.

mkpart primary ext4 1MB 5369MB

Once the partition is created, type quit to exit from Parted.

Next, run the command below to format the /dev/sdb1 partition to ext4.

sudo mkfs -t ext4 /dev/sdb1

After the /dev/sdb1 is formatted, the following output will be shown:

<img alt="create partition" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/19-create-partition.png650c748d68a6f.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="568" loading="lazy" src="data:image/svg xml,” width=”602″>

Now run the following command to create a new target mount directory /gluster. Then, mount the /dev/sdb1 partition to the /gluster directory.

mkdir -p /gluster

sudo mount /dev/sdb1 /gluster

Lastly, create a new directory /gluster/brick0 that will be used as the data directory for each GlusterFS server.

sudo mkdir -p /gluster/brick0

Installing GlusterFS Server

After you’ve partitioned your disk on each server, you will add the GlusterFS repository and install the glusterfs-server package to each server.

Execute the following command to add the GPG key of the GlusterFS repository.

curl https://download.gluster.org/pub/gluster/glusterfs/11/rsa.pub | gpg --dearmor > /usr/share/keyrings/glusterfs-archive-keyring.gpg

Then, run the command below to add the GlusterFS repository to your Debian servers.

DEBID=$(grep 'VERSION_ID=' /etc/os-release | cut -d '=' -f 2 | tr -d '"')

DEBVER=$(grep 'VERSION=' /etc/os-release | grep -Eo '[a-z] ')

DEBARCH=$(dpkg --print-architecture)
echo "deb [signed-by=/usr/share/keyrings/glusterfs-archive-keyring.gpg] https://download.gluster.org/pub/gluster/glusterfs/LATEST/Debian/${DEBID}/${DEBARCH}/apt ${DEBVER} main" | sudo tee /etc/apt/sources.list.d/gluster.list

<img alt="add repo" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/1-add-repo.png650c748d9e949.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="198" loading="lazy" src="data:image/svg xml,” width=”750″>

After adding the GlusterFS repository and GPG key, execute the following apt command to update and refresh your Debian package index.

sudo apt update

<img alt="refresh repo" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/2-refresh-repo.png650c748dcff6e.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="148" loading="lazy" src="data:image/svg xml,” width=”750″>

Then execute the apt install command below to install the glusterfs-server package.

sudo apt install glusterfs-server

Input y to proceed with the installation.

<img alt="install glusterfs server" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/3-install-glusterfs-server.png650c7491e00ca.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="432" loading="lazy" src="data:image/svg xml,” width=”720″>

Once the glusterfs-server is installed, run the systemctl command below to start and enable the glusterd service.

sudo systemctl start glusterd

sudo systemctl enable glusterd

Lastly, verify the glusterd service to ensure that the service is running and enabled.

sudo systemctl status glusterd

The following output reveals that the glusterd service is running and enabled.

<img alt="start enable glusterd" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/4-start-enable-verify-glusterd.png650c749221635.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="251" loading="lazy" src="data:image/svg xml,” width=”750″>

Initializing GlusterFS Cluster

With the glusterfs-server package installed, the next step is to initialize the GlusterFS Cluster. In this example, you will initialize the GLusterFS Cluster from server1, then you will add both server2 and server3 to the cluster.

From the server1 terminal, execute the gluster command below to initialize the GlusterFS Cluster with members of server2 on IP address 192.168.10.21 and server3 with IP address 192.168.10.22.

sudo gluster peer probe 192.168.10.21

sudo gluster peer probe 192.168.10.22

If the initialization is successful, the output message “peer probe: success” will be displayed.

<img alt="initialize cluster" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/4-initialize-glusterfs-cluster.png650c749249c71.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="146" loading="lazy" src="data:image/svg xml,” width=”509″>

Now move to server2 or server3 and run the gluster command below to verify the GlusterFS Cluster status.

sudo gluster peer status

If everything goes well, two peers will be available on your GlusterFS Cluster.

<img alt="peer status" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/6-peer-status.png650c749274988.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="256" loading="lazy" src="data:image/svg xml,” width=”432″>

On server2 – you should see the server1 and server3.

<img alt="peer status server2" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/7-peer-status-server2.png650c7492b0058.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="253" loading="lazy" src="data:image/svg xml,” width=”423″>

On server3, you should see the server1 and server2.

<img alt="peer status server3" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/8-peer-status-server3.png650c7492d6666.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="254" loading="lazy" src="data:image/svg xml,” width=”425″>

Lastly, you can also verify the list of available peers on your GlusterFS Cluster using the gluster command below.

sudo gluster pool list

The following output shows that the GlusterFS Cluster has three different servers.

<img alt="pool list" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/9-pool-list.png650c7493385b9.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="173" loading="lazy" src="data:image/svg xml,” width=”611″>

Creating GlusterFS Volume

At this point, you’ve initialized the GlusterFS Cluster. To make the GLusterFS available for clients, you must create the volume on your GlusterFS cluster.

Execute the following command to create a new volume volume1 with 3 replicas, server1, server2, and server3.

sudo gluster volume create volume1 replica 3 192.168.10.20:/gluster/brick0 192.168.10.21:/gluster/brick0 192.168.10.22:/gluster/brick0

Once volume volume1 is created, start it using the gluster command below.

sudo gluster volume start volume1

The output “volume start: volume1: success” indicates that the volume1 is started.

<img alt="create start volume" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/10-create-start-volume.png650c74936d29e.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="98" loading="lazy" src="data:image/svg xml,” width=”750″>

Now run the following command to check the list of available volumes on your GlusterFS Cluster.

sudo gluster volume info

The following output reveals that volume1 is created with type Replicate and 3 servers, such as server1, server2, and server3.

<img alt="volume info" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/11-volume-info.png650c7493a7e82.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="430" loading="lazy" src="data:image/svg xml,” width=”446″>

Mounting GlusterFS Volume

In the following section, you will mount the GlusterFS volume volume1 that you’ve created to a Debian Client machine. To achieve that, you must add the GlusterFS repository and install the glusterfs-client package to your Debian client machine.

Download the GPG key for the GLusterFS repository to your Debian client machine.

curl https://download.gluster.org/pub/gluster/glusterfs/11/rsa.pub | gpg --dearmor > /usr/share/keyrings/glusterfs-archive-keyring.gpg

Add the GLusterFS repository by executing the following command on your client.

DEBID=$(grep 'VERSION_ID=' /etc/os-release | cut -d '=' -f 2 | tr -d '"')

DEBVER=$(grep 'VERSION=' /etc/os-release | grep -Eo '[a-z] ')

DEBARCH=$(dpkg --print-architecture)
echo "deb [signed-by=/usr/share/keyrings/glusterfs-archive-keyring.gpg] https://download.gluster.org/pub/gluster/glusterfs/LATEST/Debian/${DEBID}/${DEBARCH}/apt ${DEBVER} main" | sudo tee /etc/apt/sources.list.d/gluster.list

Now refresh your Debian client repository and install the glusterfs-client package via the following apt command.

sudo apt update

sudo apt install glusterfs-client

Type y to proceed with the installation. Once the glusterfs-client is installed, you can now mount the GlusterFS volume to your Debian client machine.

<img alt="install glusterfs client" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/12-install-client.png650c7493d76bb.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="211" loading="lazy" src="data:image/svg xml,” width=”593″>

Next, execute the following command to create a new target mount directory /mnt/data.

mkdir -p /mnt/data

Then, run the following command to mount the volume1 to the /mnt/data directory. You can change the GlusterFS server IP address with server1, server2, or server3.

sudo mount.glusterfs 192.168.10.20:/volume1 /mnt/data

Once volume1 is mounted, verify it using the following command.

sudo df -h

If everything goes well, you should see that volume1 is mounted to the /mnt/data directory.

<img alt="mount glusterfs volume" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/13-glusterfs-mount.png650c74942843b.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="380" loading="lazy" src="data:image/svg xml,” width=”658″>

Now that the GlusterFS volume is mounted, you will verify the write access of the target mount directory and verify the data replication from the client machine to servers on the GlusterFS Cluster.

Next, move to the /mnt/data directory and create new files using the following command. This will create multiple files in that directory and ensure that the volume is writable.

cd /mnt/data

touch file{1..15}.md

Check the list of available files using the ls command below.

ls -ah

<img alt="test write" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/14-test-write.png650c74961b439.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="205" loading="lazy" src="data:image/svg xml,” width=”750″>

Now move to the GlusterFS servers, server1, server2, or server3, and run the ls command below to check the list of available files.

ls /gluster/brick0

When replication is working, you should see files on all those GlusterFS servers created from the Debian client machine.

Below data is replicated to server1.

<img alt="replicated server1" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/15-replicated-server1.png650c74963b687.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="131" loading="lazy" src="data:image/svg xml,” width=”750″>

Below data replicated to server2

<img alt="replicated server2" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/16-replicated-server2.png650c749664767.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="137" loading="lazy" src="data:image/svg xml,” width=”750″>

Below data replicated to server3.

<img alt="replicated server3" data-ezsrc="https://kirelos.com/wp-content/uploads/2023/09/echo/17-replicated-server3.png650c74968cc47.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="128" loading="lazy" src="data:image/svg xml,” width=”750″>

Setting Up Auto-Mount GlusterFS Volume

In the following section, you will learn how to set up auto-mount of GlusterFS volume via /etc/fstab file. This allows you to mount the GlusterFS volume automatically at boot.

Open the /etc/fstab file using the following nano editor command.

sudo nano /etc/fstab

Insert the following configuration to mount the volume1 to the target directory /mnt/data.

192.168.10.20:/volume1 /mnt/data glusterfs defaults,_netdev 0 0

Save and exit the file when finished.

Now run the following command to reload systemd manager and verify the /etc/fstab configuration. When no output message, it confirms that you’ve proper /etc/fstab configuration.

sudo systemctl daemon-reload

sudo mount -a

Conclusion

Great job! You’ve successfully installed the GlusterFS on Debian 12 servers and created the GlusterFS Cluster with 3 servers. You’ve also created and mounted a GlusterFS volume to the Debian client machine. Furthermore, you’ve also configured the auto-mount of GlusterFS volume using the /etc/fstab file.