When running a GlusterFS cluster, you may want to use the volume(s) on the servers themselves.
During the boot process, GlusterFS will take a bit of time to start. systemd-mount
, which handles the mount points from /etc/fstab
, will run before the glusterfs-server
service finishes to start.
The mount will fail so you will end up without your mounted volume after a reboot.
After doing to some research to fix this issue, I stumbled upon this Ubuntu bug report from 2011 (!). At the time, systemd wasn’t the init system, but in 2016 someone posted a pretty good solution for systemd systems.
In my case, I want my GlusterFS volume to be mounted to /srv/
.
In my /etc/fstab
, I have this line (gv0
is my volume):
localhost:/gv0 /srv glusterfs defaults,_netdev 0 0
The solution is to create the /etc/systemd/system/srv.mount.d/
directory, then /etc/systemd/system/srv.mount.d/override.conf
with the following content:
[Unit]
After=glusterfs-server.service
Wants=glusterfs-server.service
Since the /etc/fstab
mount points are translated to unit files by systemd-mount
, we can override them as shown above. In our case, systemd will only mount the volume if glusterfs-server
is started.