1.\"	$MirOS: src/usr.sbin/makefs/makefs.8,v 1.14 2010/03/07 00:46:22 tg Exp $
2.\"	$NetBSD: makefs.8,v 1.32 2009/01/20 20:47:25 bjh21 Exp $
3.\"
4.\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
5.\" All rights reserved.
6.\"
7.\" Written by Luke Mewburn for Wasabi Systems, Inc.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. All advertising materials mentioning features or use of this software
18.\"    must display the following acknowledgement:
19.\"      This product includes software developed for the NetBSD Project by
20.\"      Wasabi Systems, Inc.
21.\" 4. The name of Wasabi Systems, Inc. may not be used to endorse
22.\"    or promote products derived from this software without specific prior
23.\"    written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35.\" POSSIBILITY OF SUCH DAMAGE.
36.\"-
37.\" Copyright (c) 2008, 2009
38.\"	Thorsten “mirabilos” Glaser <tg@mirbsd.org>
39.\"-
40.\" Try to make GNU groff and AT&T nroff more compatible
41.\" * ` generates ‘ in gnroff, so use \`
42.\" * ' generates ’ in gnroff, \' generates ´, so use \*(aq
43.\" * - generates ‐ in gnroff, \- generates −, so .tr it to -
44.\"   thus use - for hyphens and \- for minus signs and option dashes
45.\" * ~ is size-reduced and placed atop in groff, so use \*(TI
46.\" * ^ is size-reduced and placed atop in groff, so use \*(ha
47.\" * \(en does not work in nroff, so use \*(en
48.\" The section after the "doc" macropackage has been loaded contains
49.\" additional code to convene between the UCB mdoc macropackage (and
50.\" its variant as BSD mdoc in groff) and the GNU mdoc macropackage.
51.\"
52.ie \n(.g \{\
53.	if \*[.T]ascii .tr \-\N'45'
54.	if \*[.T]latin1 .tr \-\N'45'
55.	if \*[.T]utf8 .tr \-\N'45'
56.	ds <= \[<=]
57.	ds >= \[>=]
58.	ds Rq \[rq]
59.	ds Lq \[lq]
60.	ds sL \(aq
61.	ds sR \(aq
62.	if \*[.T]utf8 .ds sL `
63.	if \*[.T]ps .ds sL `
64.	if \*[.T]utf8 .ds sR '
65.	if \*[.T]ps .ds sR '
66.	ds aq \(aq
67.	ds TI \(ti
68.	ds ha \(ha
69.	ds en \(en
70.\}
71.el \{\
72.	ds aq '
73.	ds TI ~
74.	ds ha ^
75.	ds en \(em
76.\}
77.\"
78.\" Implement .Dd with the Mdocdate RCS keyword
79.\"
80.rn Dd xD
81.de Dd
82.ie \\$1$Mdocdate: \{\
83.	xD \\$2 \\$3, \\$4
84.\}
85.el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8
86..
87.\"
88.\" .Dd must come before definition of .Mx, because when called
89.\" with -mandoc, it might implement .Mx itself, but we want to
90.\" use our own definition. And .Dd must come *first*, always.
91.\"
92.Dd $Mdocdate: March 7 2010 $
93.\"
94.\" Check which macro package we use
95.\"
96.ie \n(.g \{\
97.	ie d volume-ds-1 .ds tT gnu
98.	el .ds tT bsd
99.\}
100.el .ds tT ucb
101.\"
102.\" Implement .Mx (MirBSD)
103.\"
104.ie "\*(tT"gnu" \{\
105.	eo
106.	de Mx
107.	nr curr-font \n[.f]
108.	nr curr-size \n[.ps]
109.	ds str-Mx \f[\n[curr-font]]\s[\n[curr-size]u]
110.	ds str-Mx1 \*[Tn-font-size]\%MirOS\*[str-Mx]
111.	if !\n[arg-limit] \
112.	if \n[.$] \{\
113.	ds macro-name Mx
114.	parse-args \$@
115.	\}
116.	if (\n[arg-limit] > \n[arg-ptr]) \{\
117.	nr arg-ptr +1
118.	ie (\n[type\n[arg-ptr]] == 2) \
119.	as str-Mx1 \~\*[arg\n[arg-ptr]]
120.	el \
121.	nr arg-ptr -1
122.	\}
123.	ds arg\n[arg-ptr] "\*[str-Mx1]
124.	nr type\n[arg-ptr] 2
125.	ds space\n[arg-ptr] "\*[space]
126.	nr num-args (\n[arg-limit] - \n[arg-ptr])
127.	nr arg-limit \n[arg-ptr]
128.	if \n[num-args] \
129.	parse-space-vector
130.	print-recursive
131..
132.	ec
133.	ds sP \s0
134.	ds tN \*[Tn-font-size]
135.\}
136.el \{\
137.	de Mx
138.	nr cF \\n(.f
139.	nr cZ \\n(.s
140.	ds aa \&\f\\n(cF\s\\n(cZ
141.	if \\n(aC==0 \{\
142.		ie \\n(.$==0 \&MirOS\\*(aa
143.		el .aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
144.	\}
145.	if \\n(aC>\\n(aP \{\
146.		nr aP \\n(aP+1
147.		ie \\n(C\\n(aP==2 \{\
148.			as b1 \&MirOS\ #\&\\*(A\\n(aP\\*(aa
149.			ie \\n(aC>\\n(aP \{\
150.				nr aP \\n(aP+1
151.				nR
152.			\}
153.			el .aZ
154.		\}
155.		el \{\
156.			as b1 \&MirOS\\*(aa
157.			nR
158.		\}
159.	\}
160..
161.\}
162.\"-
163.Dt MAKEFS 8
164.Os
165.Sh NAME
166.Nm makefs
167.Nd create a file system image from a directory tree
168.Sh SYNOPSIS
169.Nm
170.Op Fl x
171.Op Fl B Ar byte-order
172.Op Fl b Ar free-blocks
173.Op Fl d Ar debug-mask
174.Op Fl F Ar specfile
175.Op Fl f Ar free-files
176.Op Fl M Ar minimum-size
177.Op Fl m Ar maximum-size
178.Op Fl N Ar userdb-dir
179.Op Fl o Ar fs-options
180.Op Fl S Ar sector-size
181.Op Fl s Ar image-size
182.Op Fl t Ar fs-type
183.Ar image-file
184.Ar directory
185.Sh DESCRIPTION
186The utility
187.Nm
188creates a file system image into
189.Ar image-file
190from the directory tree
191.Ar directory .
192No special devices or privileges are required to perform this task.
193.Pp
194The options are as follows:
195.Bl -tag -width flag
196.It Fl B Ar byte-order
197Set the byte order of the image to
198.Ar byte-order .
199Valid byte orders are
200.Ql 4321 ,
201.Ql big ,
202or
203.Ql be
204for big endian, and
205.Ql 1234 ,
206.Ql little ,
207or
208.Ql le
209for little endian.
210Some file systems may have a fixed byte order; in those cases this
211argument will be ignored.
212.It Fl b Ar free-blocks
213Ensure that a minimum of
214.Ar free-blocks
215free blocks exist in the image.
216An optional
217.Ql %
218suffix may be provided to indicate that
219.Ar free-blocks
220indicates a percentage of the calculated image size.
221.It Fl d Ar debug-mask
222Enable various levels of debugging, depending upon which bits are
223set in
224.Ar debug-mask .
225XXX: document these
226.It Fl F Ar specfile
227Use
228.Ar specfile
229as an
230.Xr mtree 8
231.Sq specfile
232specification.
233.Pp
234If a specfile entry exists in the underlying file system, its
235permissions and modification time will be used unless specifically
236overridden by the specfile.
237An error will be raised if the type of entry in the specfile
238conflicts with that of an existing entry.
239.Pp
240In the opposite case (where a specfile entry does not have an entry
241in the underlying file system) the following occurs:
242If the specfile entry is marked
243.Sy optional ,
244the specfile entry is ignored.
245Otherwise, the entry will be created in the image, and it is
246necessary to specify at least the following parameters in the
247specfile:
248.Sy type ,
249.Sy mode ,
250.Sy gname ,
251or
252.Sy gid ,
253and
254.Sy uname
255or
256.Sy uid ,
257.Sy device
258(in the case of block or character devices), and
259.Sy link
260(in the case of symbolic links).
261If
262.Sy time
263isn't provided, the current time will be used.
264If
265.Sy flags
266isn't provided, the current file flags will be used.
267Missing regular file entries will be created as zero-length files.
268.It Fl f Ar free-files
269Ensure that a minimum of
270.Ar free-files
271free files (inodes) exist in the image.
272An optional
273.Ql %
274suffix may be provided to indicate that
275.Ar free-files
276indicates a percentage of the calculated image size.
277.It Fl M Ar minimum-size
278Set the minimum size of the file system image to
279.Ar minimum-size .
280.It Fl m Ar maximum-size
281Set the maximum size of the file system image to
282.Ar maximum-size .
283An error will be raised if the target file system needs to be larger
284than this to accommodate the provided directory tree.
285.It Fl N Ar dbdir
286Use the user database text file
287.Pa master.passwd
288and group database text file
289.Pa group
290from
291.Ar dbdir ,
292rather than using the results from the system's
293.Xr getpwnam 3
294and
295.Xr getgrnam 3
296(and related) library calls.
297.It Fl o Ar fs-options
298Set file system specific options.
299.Ar fs-options
300is a comma separated list of options.
301Valid file system specific options are detailed below.
302.It Fl S Ar sector-size
303Set the file system sector size to
304.Ar sector-size .
305.\" XXX: next line also true for cd9660?
306Defaults to 512.
307.It Fl s Ar image-size
308Set the size of the file system image to
309.Ar image-size .
310.It Fl t Ar fs-type
311Create an
312.Ar fs-type
313file system image.
314The following file system types are supported:
315.Bl -tag -width cd9660 -offset indent
316.It Sy ffs
317BSD fast file system (default).
318.It Sy cd9660
319ISO 9660 file system.
320.El
321.It Fl x
322Exclude file system nodes not explicitly listed in the specfile.
323.El
324.Pp
325Where sizes are specified, a decimal number of bytes is expected.
326Two or more numbers may be separated by an
327.Dq x
328to indicate a product.
329Each number may have one of the following optional suffixes:
330.Bl -tag -width 3n -offset indent -compact
331.It b
332Block; multiply by 512
333.It k
334Kibi; multiply by 1024 (1 KiB)
335.It m
336Mebi; multiply by 1048576 (1 MiB)
337.It g
338Gibi; multiply by 1073741824 (1 GiB)
339.It t
340Tebi; multiply by 1099511627776 (1 TiB)
341.It w
342Word; multiply by the number of bytes in an integer
343.El
344.\"
345.\"
346.Ss FFS-specific options
347.Sy ffs
348images have ffs-specific optional parameters that may be provided.
349Each of the options consists of a keyword, an equal sign
350.Pq Ql = ,
351and a value.
352The following keywords are supported:
353.Pp
354.Bl -tag -width optimization -offset indent -compact
355.It Sy avgfilesize
356Expected average file size.
357.It Sy avgfpdir
358Expected number of files per directory.
359.It Sy bsize
360Block size.
361.It Sy density
362Bytes per inode.
363.It Sy fsize
364Fragment size.
365.It Sy maxbpg
366Maximum blocks per file in a cylinder group.
367.It Sy minfree
368Minimum % free.
369.It Sy optimization
370Optimization preference; one of
371.Ql space
372or
373.Ql time .
374.It Sy extent
375Maximum extent size.
376.It Sy maxbpcg
377Maximum total number of blocks in a cylinder group.
378.It Sy version
379UFS version.
3801 for FFS (default), 2 for UFS2.
381.El
382.Ss CD9660-specific options
383.Sy cd9660
384images have ISO9660-specific optional parameters that may be
385provided.
386The arguments consist of a keyword and, optionally, an equal sign
387.Pq Ql = ,
388and a value.
389The following keywords are supported:
390.Pp
391.Bl -tag -width omit-trailing-period -offset indent -compact
392.It Sy allow\-deep\-trees
393Allow the directory structure to exceed the maximum specified in
394the spec.
395.\" .It Sy allow\-illegal\-chars
396.\" Unknown
397.\" .It Sy allow\-lowercase
398.\" Unknown
399.It Sy allow\-max\-name
400Allow 37 instead of 33 characters for filenames by omitting the
401version id.
402.It Sy allow\-multidot
403Allow multiple dots in a filename.
404.It Sy applicationid
405Application ID of the image.
406.It Sy archimedes
407Use the
408.Ql ARCHIMEDES
409extension to encode
410.Tn RISC OS
411metadata.
412.It Sy boot\-info\-table
413Write a legacy 56-byte table at offset 8 into the boot image
414.Pq see below .
415.It Sy boot\-load\-segment
416Set load segment for the boot image.
417.It Sy bootimage
418Filename of a boot image in the format
419.Dq sysid;filename ,
420where
421.Dq sysid
422is one of
423.Ql i386 ,
424.Ql mac68k ,
425.Ql macppc ,
426or
427.Ql powerpc .
428.It Sy creation\-date
429Override PVD creation date.
430.It Sy effective\-date
431Override PVD effective date.
432.It Sy expiration\-date
433Override PVD expiration date.
434.It Sy generic\-bootimage
435Load a generic boot image into the first 32K of the cd9660 image.
436.It Sy hard\-disk\-boot
437Boot image is a hard disk image.
438.It Sy hide\-rr\-moved
439Assign the
440.Pa RR_MOVED
441directory a rock ridge name of the empty string instead of the default
442.Pa .rr_moved .
443.It Sy keep\-bad\-images
444Don't throw away images whose write was aborted due to an error.
445For debugging purposes.
446.It Sy label
447Label name of the image.
448.It Sy modification\-date
449Override PVD modification date.
450.It Sy no\-boot
451Boot image is not bootable.
452.It Sy no\-emul\-boot
453Boot image is a
454.Dq no emulation
455ElTorito image.
456.It Sy no\-trailing\-padding
457Do not pad the image (apparently Linux needs the padding).
458.It Sy omit\-trailing\-period
459Violate the standard, do not append a trailing period to
460filenames without an extension.
461.It Sy preparer
462Preparer ID of the image.
463.It Sy publisher
464Publisher ID of the image.
465.It Sy rockridge
466Use RockRidge extensions (for longer filenames, etc.).
467.It Sy rr\-squash
468Force uid 0, gid 0, and rationalised permission bits for RockRidge entries.
469.It Sy volumeid
470Volume set identifier of the image.
471.El
472.Pp
473The
474.Sy boot\-info\-table
475currently consists of the following fields (all 7.3.1 numbers),
476offsets relative to the boot image:
477.Bl -tag -width XXX -offset indent -compact
478.It Sy 0
4798 bytes: kept as is, not part of checksum
480.It Sy 8
481LBA of PVD
482.It Sy 12
483LBA of boot image
484.It Sy 16
485Size in bytes of boot image
486.It Sy 20
48732-bit additive sum of all 32-bit words of boot image
488.It Sy 24
48940 reserved bytes (MBZ)
490.It Sy 64
491Begin of checksummed data, kept as is
492.El
493.Pp
494Dates (to override) are in 8.4.26.1 format
495.Pq Ar YYYYmmddHHMMSS00
496and Universal Time, i.e. with zero offset from Greenwich Mean Time.
497.Sh SEE ALSO
498.Xr strsuftoll 3 ,
499.Xr installboot 8 ,
500.Xr mtree 8 ,
501.Xr newfs 8
502.Sh HISTORY
503The
504.Nm
505utility appeared in
506.Nx 1.6 .
507.Pp
508Support for overriding PVD dates and the boot info table was added in
509.Mx 11 .
510.Sh AUTHORS
511.An Luke Mewburn
512.Aq lukem@NetBSD.org
513(original program)
514.An Daniel Watt ,
515.An Walter Deignan ,
516.An Ryan Gabrys ,
517.An Alan Perez-Rathke ,
518.An Ram Vedam
519(cd9660 support)
520.An Thorsten Glaser Aq tg@mirbsd.org
521.Sh CAVEATS
522.Nm
523may be limited to images less than 2 GiB in size
524due to internal use of the long type.
525