How to make OverlayFS with multiple upperdirs?

0

I have the following directories:

/var/steamcmd
/var/servers/1/custom
/var/servers/2/custom
/var/servers/3/custom
... there could be many directories like this, not just 3.

My goal is to make the directory steamcmd the base, and for each custom directory I want the files to be merged with the base, so if there is a file in both custom and steamcmd then custom will be prioritized.

In order to do so I decided first to focus on one directory (/var/servers/1/...) and created another 2 directories, so my directories are:

/var/steamcmd ---------------> lowerdir
/var/servers/1/custom -------> upperdir
/var/servers/1/overlayWork --> work directory
/var/servers/1/steamcmd -----> the merged folder

I came up with this command, but with no success:

$ mount -t overlay -o \
lowerdir=/var/steamcmd,\
upperdir=/var/servers/1/custom,\
workdir=/var/servers/1/overlayWork \
/var/servers/1/steamcmd

I'm getting the following error when executing:

mount: /var/servers/1/steamcmd: can't find in /etc/fstab.

How do I fix this? and can I make this work with multiple directories like presented above? (/var/servers/{X}/custom)

HTMHell

Posted 2018-06-09T14:50:51.497

Reputation: 103

1You need overlay as the first positional parameter, as in mount -t overlay -o lowerdir=/var/steamcmd,upperdir=/var/servers/1/custom,workdir=/var/servers/1/overlayWork overlay /var/servers/1/steamcmd. The extra overlay can also precede the -o. – AFH – 2018-06-09T15:57:40.993

I'll make it an answer, so others can see that it's solved. – AFH – 2018-06-09T17:11:31.717

Answers

1

You need overlay as the first positional parameter, as in:

mount -t overlay \
-o lowerdir=/var/steamcmd,\
upperdir=/var/servers/1/custom,\
workdir=/var/servers/1/overlayWork \
overlay /var/servers/1/steamcmd
#^^^^^#

The extra overlay can also precede the -o:

                 #vvvvv#
mount -t overlay overlay \
-o lowerdir=/var/steamcmd,\
upperdir=/var/servers/1/custom,\
workdir=/var/servers/1/overlayWork \
/var/servers/1/steamcmd

Without this positional parameter, mount will assume that its options are defined in /etc/fstab; hence your error message.

AFH

Posted 2018-06-09T14:50:51.497

Reputation: 15 470