I have configured gluserfs on a pair of servers and I'm able to mount this on my client machines. I want to also be able to mount the glusterfs filesystem on both of the glusterfs servers on boot when I take both machines offline and start them from scratch.

These servers are set up as a cluster using pacemaker. In addition to a shared database, pacemaker is also providing a virtual IP address to mount the gluster filesystem from.

I can manually mount the filesystem on each after both servers are up with the command:

mount -t glusterfs nodea:/gv0 /data

Which is great. But I want this to happen automatically at boot.

So I've tried adding an entry to the fstab:

nodea:/gv0  /data       glusterfs   _netdev 0 0

Which works when I run the "mount -a" command after the cluster is up and running. However, it does not work at boot. (This is how the client machines mount the glusterfs on boot, but the cluster is up and running. So of course it works on boot for them.)

I have also tried creating a systemd unit file to handle the mounting of the glusterfs at boot. My unit file is in /etc/systemd/system named "data.mount" and looks like:

# Mounting gluster fs at /data

[Unit]
Description = Automount gluster filesystem
After=pcsd.service

[Mount]
What=nodea:/gv0
Where=/data
Type=glusterfs

[Install]
WantedBy = pcsd.service

Again, this works when both servers are up and running by running the command "systemctl start data.mount". It also works if I only reboot one of the machines in the cluster. But it doesn't work on a reboot of both servers.

If both nodes in the cluster go down, or if I feel like rebooting both at the same time for whatever reason, I want to be sure that when both machines come back up, that the glusterfs is mounted on /data.

As a work around, I've added the following lines to root's crontab on both machines:

@reboot sleep 60 && mount -t glusterfs nodea:/gv0 /data
@reboot sleep 300 && mount -t glusterfs nodea:/gv0 /data

This works if I start both severs up from scratch. But my concern is that if the pacemaker service ever takes longer than 5 minutes to start up, then I still don't have the gluster filesystem mounted on the server at /data.

Is there a way to have the systemd unit file check if it actually mounted the filesystem and if not to retry until it does?

Is there some other way to have the glusterfs mount at boot and to check that it's actually mounted?

  • Why are you using a vip via pacemaker for this? Glusterfs doesn't require this to be clustered. Is this for some other cluster that's colocated on the same instances? – Spooler May 1 '17 at 21:29

You should be able to have systemd automount when needed. I was having problems with Ubuntu 16.04 mounting at boot as well. Based on this message I added noauto,x-systemd.automount to my fstab line:

gluster1:/volume1   /storage-pool   glusterfs   defaults,_netdev,noauto,x-systemd.automount 0 0

I have rebooted the app servers a few times each and they have all successfully mounted. I hope this helps you too!

  • I've done similar via autofs with success. This is easier to manage. – Spooler May 1 '17 at 21:38
  • You saved my life :p – Tim Aug 1 at 19:58

I've been hacking around this issue given LP's attitude:

file: /etc/systemd/system/glusterfsmounts.service:

[Unit]
Description=Glustermounting
Requires=glusterfs-server.service

[Service]
Type=simple
RemainAfterExit=true
ExecStartPre=/usr/sbin/gluster volume list
ExecStart=/bin/mount -a -t glusterfs
Restart=on-failure
RestartSec=3

[Install]
WantedBy=multi-user.target

then you would:

systemctl daemon-reload

systemctl enable glusterfsmounts

and reboot... been the best/stablest thus far for me

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.