mount_union - mount union filesystems
mount_union [-br] [-o options] directory uniondir
The mount_union command attaches directory above uniondir in
such a way
that the contents of both directory trees remain visible.
directory becomes the upper layer and uniondir becomes the
The options are as follows:
-b Invert the default position, so that directory becomes the lower
layer and uniondir becomes the upper layer. However, uniondir
remains the mount point.
Options are specified with a -o flag followed by a
string of options. See the mount(8) man page for
and their meanings.
-r Hide the lower layer completely in the same way as
To enforce filesystem security, the user mounting the
filesystem must be
superuser or else have write permission on the mounted-on
Filenames are looked up in the upper layer and then in the
If a directory is found in the lower layer, and there is no
entry in the
upper layer, then a shadow directory will be created in the
It will be owned by the user who originally did the union
mode ``rwxrwxrwx'' (0777) modified by the umask in effect at
If a file exists in the upper layer then there is no way to
access a file
with the same name in the lower layer. If necessary, a combination of
loopback and union mounts can be made which will still allow
files to be accessed by a different pathname.
Except in the case of a directory, access to an object is
granted via the
normal filesystem access checks. For directories, the current user must
have access to both the upper and lower directories (should
they both exist).
Requests to create or modify objects in uniondir are passed
to the upper
layer with the exception of a few special cases. An attempt
to open for
writing a file which exists in the lower layer causes a copy
entire file to be made to the upper layer, and then for the
copy to be opened. Similarly, an attempt to truncate a lower layer file
to zero length causes an empty file to be created in the upper layer.
Any other operation which would ultimately require modification to the
lower layer fails with EROFS.
The union filesystem manipulates the namespace, rather than
filesystems. The union operation applies recursively down
tree now rooted at uniondir. Thus any filesystems which are
uniondir will take part in the union operation. This
the union option to mount(8) which only applies the union
the mount point itself, and then only for lookups.
# mount -t cd9660 -o ro /dev/cd0a /usr/src
# mount -t union /var/obj /usr/src
mount the CD-ROM drive /dev/cd0a on /usr/src and then attaches /var/obj
on top. For most purposes the effect of this is to make the
appear writable even though it is stored on a CD-ROM.
# mount -t union -o -b /sys $HOME/sys
attaches the system source tree below the sys directory in
home directory. This allows individual users to make private changes to
the source, and build new kernels, without those changes becoming visible
to other users. Note that the files in the lower layer remain accessible
intro(2), mount(2), fstab(5), mount(8), mount_null(8),
The mount_union command first appeared in 4.4BSD.
Without whiteout support from the filesystem backing the upper layer,
there is no way that delete and rename operations on lower
can be done. EROFS is returned for these kind of operations
any others which would make modifications to the lower layer, such as
Running find(1) over a union tree has the side-effect of
creating a tree
of shadow directories in the upper layer.
OpenBSD 3.6 March 27, 1994
[ Back ]