I want to mount my RO Filesystem using overlayFS - in order to use two layers FS (Lowerdir and Upperdir).

I tried the following mounting command -

mount -t overlayfs -o lowerdir=/,upperdir=/overlay "overlayfs:/overlay" /mnt && root=/mnt

That mounted /mnt as overlayFS, but set it as RO.

I tried the following in order to mount it as RW (meaning the Upperdir is RW) -

mount -t overlayfs -o rw,lowerdir=/,upperdir=/overlay "overlayfs:/overlay" /mnt && root=/mnt

Still no good.

Some general information -

I would like to mount the R/W FS as UBIFS, my RO FS is SquashFS I'm working on openWRT Thanks everyone!


You're missing workdir=:


Overlaying mainly involves directories. If a given name appears in both upper and lower filesystems and refers to a non-directory in either, then the lower object is hidden - the name refers only to the upper object.

Where both upper and lower objects are directories, a merged directory is formed.

At mount time, the two directories given as mount options lowerdir and upperdir are combined into a merged directory:

mount -t overlay overlay -olowerdir=/lower,upperdir=/upper, workdir=/work /merged

The workdir needs to be an empty directory on the same filesystem as upperdir.

Then whenever a lookup is requested in such a merged directory, the lookup is performed in each actual directory and the combined result is cached in the dentry belonging to the overlay filesystem. If both actual lookups find directories, both are stored and a merged directory is created, otherwise only one is stored: the upper if it exists, else the lower.

Only the lists of names from directories are merged. Other content such as metadata and extended attributes are reported for the upper directory only. These attributes of the lower directory are hidden.

Multiple lower layers

Multiple lower layers can now be given using the the colon : as a separator character between the directory names. For example:

mount -t overlay overlay -olowerdir=/lower1:/lower2:/lower3 /merged

As the example shows, upperdir= and workdir= may be omitted. In that case the overlay will be read-only.

The specified lower directories will be stacked beginning from the rightmost one and going left. In the above example lower1 will be the top, lower2 the middle and lower3 the bottom layer.

  • Do you mean I should use - mount -t overlayfs -o lowerdir=/,upperdir=/overlay,workdir=/overlay "overlayfs:/overlay" /mnt && root=/mnt - Because that fails with 'invalid argument' – dear_tzvi Dec 29 '15 at 13:02
  • @user2568434: no. workdir= has to be on the same fs as upperdir=, but it shouldnt be the same directory. it needs to be an empty directory. – mikeserv Dec 29 '15 at 13:03
  • I see. So I will have to extend my original question: I'm currently using a squashFS root FS (read-only), and I want to use overlay in order to allow writing of data to it. If I follow these instruction, then I will surely fail because overlayFS will be read-only. Can you advice? – dear_tzvi Dec 29 '15 at 13:17
  • @user2568434 - overlayfs will only work to make a sqshfs mount r/w if you you actually overlay some other writable filesystem. Like this: mkdir -p /tmp/olay /tmp/sfs; mount -t tmpfs none /tmp/olay; mkdir /tmp/olay/up /tmp/olay/wrk; mount ./my.sfs /tmp/sfs; mount -t overlay overlay -olowerdir=/tmp/sfs,upperdir=/tmp/olay/up,workdir=/tmp/olay/workdir /tmp/olay – mikeserv Dec 29 '15 at 13:23
  • Thanks! I will change my original directory structure accordingly – dear_tzvi Dec 29 '15 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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