add .Mt to man pages in sbin/
[dragonfly.git] / sbin / mount_union / mount_union.8
1 .\" Copyright (c) 1994
2 .\" The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" This code is derived from software donated to Berkeley by
5 .\" Jan-Simon Pendry.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\" 3. Neither the name of the University nor the names of its contributors
16 .\"    may be used to endorse or promote products derived from this software
17 .\"    without specific prior written permission.
18 .\"
19 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 .\" SUCH DAMAGE.
30 .\"
31 .\"     @(#)mount_union.8       8.6 (Berkeley) 3/27/94
32 .\" $FreeBSD: src/sbin/mount_union/mount_union.8,v 1.6.2.2 2001/12/20 16:46:05 ru Exp $
33 .\"
34 .Dd March 27, 1994
35 .Dt MOUNT_UNION 8
36 .Os
37 .Sh NAME
38 .Nm mount_union
39 .Nd mount union filesystems
40 .Sh SYNOPSIS
41 .Nm
42 .Op Fl br
43 .Op Fl o Ar options
44 .Ar directory
45 .Ar uniondir
46 .Sh DESCRIPTION
47 The
48 .Nm
49 command
50 attaches
51 .Ar directory
52 above
53 .Ar uniondir
54 in such a way that the contents of both directory trees remain visible.
55 By default,
56 .Ar directory
57 becomes the
58 .Em upper
59 layer and
60 .Ar uniondir
61 becomes the
62 .Em lower
63 layer.
64 .Pp
65 The options are as follows:
66 .Bl -tag -width indent
67 .It Fl b
68 Invert the default position, so that
69 .Ar directory
70 becomes the lower layer and
71 .Ar uniondir
72 becomes the upper layer.
73 However,
74 .Ar uniondir
75 remains the mount point.
76 .It Fl o
77 Options are specified with a
78 .Fl o
79 flag followed by a comma separated string of options.
80 See the
81 .Xr mount 8
82 man page for possible options and their meanings.
83 .It Fl r
84 Hide the lower layer completely in the same way as mounting with
85 .Xr mount_null 8 .
86 .El
87 .Pp
88 To enforce filesystem security, the user mounting the filesystem
89 must be superuser or else have write permission on the mounted-on
90 directory.
91 In addition, the
92 .Va vfs.usermount
93 .Xr sysctl 3
94 variable must be set to 1 to permit file system mounting by ordinary users.
95 .Pp
96 Filenames are looked up in the upper layer and then in the
97 lower layer.
98 If a directory is found in the lower layer, and there is no entry
99 in the upper layer, then a
100 .Em shadow
101 directory will be created in the upper layer.
102 It will be owned by the user who originally did the union mount,
103 with mode
104 .Dq rwxrwxrwx
105 (0777) modified by the umask in effect at that time.
106 .Pp
107 If a file exists in the upper layer then there is no way to access
108 a file with the same name in the lower layer.
109 If necessary, a combination of loopback and union mounts can be made
110 which will still allow the lower files to be accessed by a different
111 pathname.
112 .Pp
113 Except in the case of a directory,
114 access to an object is granted via the normal filesystem access checks.
115 For directories, the current user must have access to both the upper
116 and lower directories (should they both exist).
117 .Pp
118 Requests to create or modify objects in
119 .Ar uniondir
120 are passed to the upper layer with the exception of a few special cases.
121 An attempt to open for writing a file which exists in the lower layer
122 causes a copy of the
123 .Em entire
124 file to be made to the upper layer, and then for the upper layer copy
125 to be opened.
126 Similarly, an attempt to truncate a lower layer file to zero length
127 causes an empty file to be created in the upper layer.
128 Any other operation which would ultimately require modification to
129 the lower layer fails with
130 .Er EROFS .
131 .Pp
132 The union filesystem manipulates the namespace, rather than
133 individual filesystems.
134 The union operation applies recursively down the directory tree
135 now rooted at
136 .Ar uniondir .
137 Thus any filesystems which are mounted under
138 .Ar uniondir
139 will take part in the union operation.
140 This differs from the
141 .Em union
142 option to
143 .Xr mount 8
144 which only applies the union operation to the mount point itself,
145 and then only for lookups.
146 .Sh EXAMPLES
147 The commands
148 .Bd -literal -offset indent
149 mount -t cd9660 -o ro /dev/cd0a /usr/src
150 mount -t union /var/obj /usr/src
151 .Ed
152 .Pp
153 mount the CD-ROM drive
154 .Pa /dev/cd0a
155 on
156 .Pa /usr/src
157 and then attaches
158 .Pa /var/obj
159 on top.
160 For most purposes the effect of this is to make the
161 source tree appear writable
162 even though it is stored on a CD-ROM.
163 .Pp
164 The command
165 .Bd -literal -offset indent
166 mount -t union -o -b /sys $HOME/sys
167 .Ed
168 .Pp
169 attaches the system source tree below the
170 .Pa sys
171 directory in the user's home directory.
172 This allows individual users to make private changes
173 to the source, and build new kernels, without those
174 changes becoming visible to other users.
175 Note that the files in the lower layer remain
176 accessible via
177 .Pa /sys .
178 .Sh SEE ALSO
179 .Xr intro 2 ,
180 .Xr mount 2 ,
181 .Xr unmount 2 ,
182 .Xr fstab 5 ,
183 .Xr mount 8 ,
184 .Xr mount_null 8
185 .Sh HISTORY
186 The
187 .Nm
188 command first appeared in
189 .Bx 4.4 .
190 It first worked in
191 .Fx Ns -(fill this in) .
192 .Sh BUGS
193 THIS FILESYSTEM TYPE IS NOT YET FULLY SUPPORTED (READ: IT DOESN'T WORK)
194 AND USING IT MAY, IN FACT, DESTROY DATA ON YOUR SYSTEM.  USE AT YOUR
195 OWN RISK.  BEWARE OF DOG.  SLIPPERY WHEN WET.
196 .Pp
197 This code also needs an owner in order to be less dangerous - serious
198 hackers can apply by sending mail to
199 .Aq Mt kernel@crater.dragonflybsd.org
200 and announcing
201 their intent to take it over.
202 .Pp
203 Without whiteout support from the filesystem backing the upper layer,
204 there is no way that delete and rename operations on lower layer
205 objects can be done.
206 .Er EROFS
207 is returned for this kind of operations along with any others
208 which would make modifications to the lower layer, such as
209 .Xr chmod 1 .
210 .Pp
211 Running
212 .Xr find 1
213 over a union tree has the side-effect of creating
214 a tree of shadow directories in the upper layer.