xref: /netbsd-src/usr.sbin/makefs/makefs.8 (revision afab4e300d3a9fb07dd8c80daf53d0feb3345706)
1.\"	$NetBSD: makefs.8,v 1.71 2022/11/17 06:40:41 chs Exp $
2.\"
3.\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
4.\" All rights reserved.
5.\"
6.\" Written by Luke Mewburn for Wasabi Systems, Inc.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\"    must display the following acknowledgement:
18.\"      This product includes software developed for the NetBSD Project by
19.\"      Wasabi Systems, Inc.
20.\" 4. The name of Wasabi Systems, Inc. may not be used to endorse
21.\"    or promote products derived from this software without specific prior
22.\"    written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
28.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34.\" POSSIBILITY OF SUCH DAMAGE.
35.\"
36.Dd April 4, 2021
37.Dt MAKEFS 8
38.Os
39.Sh NAME
40.Nm makefs
41.Nd create a file system image from a directory tree
42.Sh SYNOPSIS
43.Nm
44.Op Fl LrxZ
45.Op Fl B Ar endian
46.Op Fl b Ar free-blocks
47.Op Fl d Ar debug-mask
48.Op Fl F Ar mtree-specfile
49.Op Fl f Ar free-files
50.Op Fl M Ar minimum-size
51.Op Fl m Ar maximum-size
52.Op Fl N Ar userdb-dir
53.Op Fl O Ar offset
54.Op Fl o Ar fs-options
55.Op Fl S Ar sector-size
56.Op Fl s Ar image-size
57.Op Fl T Ar timestamp
58.Op Fl t Ar fs-type
59.Ar image-file
60.Ar directory
61.Op Ar extra-directory ...
62.Sh DESCRIPTION
63The utility
64.Nm
65creates a file system image into
66.Ar image-file
67from the directory tree
68.Ar directory .
69If any optional directory trees are passed in the
70.Ar extra-directory
71arguments, then the directory tree of each argument will be merged
72into the
73.Ar directory
74first before creating
75.Ar image-file .
76No special devices or privileges are required to perform this task.
77.Pp
78The options are as follows:
79.Bl -tag -width flag
80.It Fl B Ar endian
81Set the byte order of the image to
82.Ar endian .
83Valid byte orders are
84.Ql 4321 ,
85.Ql big ,
86or
87.Ql be
88for big endian, and
89.Ql 1234 ,
90.Ql little ,
91or
92.Ql le
93for little endian.
94Some file systems may have a fixed byte order; in those cases this
95argument will be ignored.
96.It Fl b Ar free-blocks
97Ensure that a minimum of
98.Ar free-blocks
99free blocks exist in the image.
100An optional
101.Ql %
102suffix may be provided to indicate that
103.Ar free-blocks
104indicates a percentage of the calculated image size.
105.It Fl d Ar debug-mask
106Enable various levels of debugging, depending upon which bits are
107set in
108.Ar debug-mask .
109XXX: document these
110.It Fl F Ar mtree-specfile
111Use
112.Ar mtree-specfile
113as an
114.Xr mtree 8
115.Sq specfile
116specification.
117.Pp
118If a specfile entry exists in the underlying file system, its
119permissions and modification time will be used unless specifically
120overridden by the specfile.
121An error will be raised if the type of entry in the specfile
122conflicts with that of an existing entry.
123.Pp
124In the opposite case (where a specfile entry does not have an entry
125in the underlying file system) the following occurs:
126If the specfile entry is marked
127.Sy optional ,
128the specfile entry is ignored.
129Otherwise, the entry will be created in the image, and it is
130necessary to specify at least the following parameters in the
131specfile:
132.Sy type ,
133.Sy mode ,
134.Sy gname ,
135or
136.Sy gid ,
137and
138.Sy uname
139or
140.Sy uid ,
141.Sy device
142(in the case of block or character devices), and
143.Sy link
144(in the case of symbolic links).
145If
146.Sy time
147isn't provided, the current time will be used.
148If
149.Sy flags
150isn't provided, the current file flags will be used.
151Missing regular file entries will be created as zero-length files.
152.It Fl f Ar free-files
153Ensure that a minimum of
154.Ar free-files
155free files (inodes) exist in the image.
156An optional
157.Ql %
158suffix may be provided to indicate that
159.Ar free-files
160indicates a percentage of the calculated image size.
161.It Fl L
162All symbolic links are followed.
163.It Fl M Ar minimum-size
164Set the minimum size of the file system image to
165.Ar minimum-size .
166.It Fl m Ar maximum-size
167Set the maximum size of the file system image to
168.Ar maximum-size .
169An error will be raised if the target file system needs to be larger
170than this to accommodate the provided directory tree.
171.It Fl N Ar userdb-dir
172Use the user database text file
173.Pa master.passwd
174and group database text file
175.Pa group
176from
177.Ar userdb-dir ,
178rather than using the results from the system's
179.Xr getpwnam 3
180and
181.Xr getgrnam 3
182(and related) library calls.
183.It Fl O Ar offset
184Instead of creating the file system at the beginning of the file, start
185at offset.
186Valid only for
187.Sy ffs
188and
189.Sy msdos .
190.It Fl o Ar fs-options
191Set file system specific options.
192.Ar fs-options
193is a comma separated list of options.
194Valid file system specific options are detailed below.
195.It Fl r
196When merging multiple directories replace duplicate files with the last found.
197.It Fl S Ar sector-size
198Set the file system sector size to
199.Ar sector-size .
200Defaults to 512 for most file systems, but is 2048 for
201.Sy cd9660
202and
203.Sy udf
204for CD/DVD/BD optical media types.
205.It Fl s Ar image-size
206Set the size of the file system image to
207.Ar image-size .
208This is equivalent of setting both the minimum
209.Fl ( M )
210and the maximum
211.Fl ( m )
212sizes to
213.Ar image-size .
214For
215.Sy ffs
216and
217.Sy msdos
218the
219.Ar offset
220is not included on that size.
221.It Fl T Ar timestamp
222Specify a timestamp to be set for all file system files and directories
223created so that repeatable builds are possible.
224The
225.Ar timestamp
226can be a
227.Pa pathname ,
228where the timestamps are derived from that file, a parseable date
229for
230.Xr parsedate 3
231(this option is not yet available in the tools build), or an integer
232value interpreted as the number of seconds from the Epoch.
233Note that timestamps specified in an
234.Xr mtree 5
235spec file, override the default timestamp.
236When this option is enabled, file systems that regularly use
237.Xr localtime 3
238to convert times to the native format (such as udf and cd9660), use
239.Xr gmtime 3
240instead with the specified timestamps so that they are immune to
241timezone changes and get consistent timestamps.
242.It Fl t Ar fs-type
243Create an
244.Ar fs-type
245file system image.
246The following file system types are supported:
247.Bl -tag -width cd9660 -offset indent
248.It Sy cd9660
249ISO 9660 file system.
250.It Sy chfs
251Chip flash file system.
252.It Sy ffs
253BSD fast file system (default).
254.It Sy msdos
255FAT12, FAT16, or FAT32 file system.
256.It Sy udf
257ISO/Ecma UDF file system.
258.It Sy v7fs
2597th Edition(V7) file system.
260.El
261.It Fl x
262Exclude file system nodes not explicitly listed in the specfile.
263.It Fl Z
264Create a sparse file for
265.Sy ffs .
266This is useful for virtual machine images.
267.El
268.Pp
269Where sizes are specified, a decimal number of bytes is expected.
270Two or more numbers may be separated by an
271.Sq x
272to indicate a product.
273Each number may have one of the following optional suffixes:
274.Bl -tag -width 3n -offset indent -compact
275.It b
276Block; multiply by 512
277.It k
278Kibi; multiply by 1024 (1 KiB)
279.It m
280Mebi; multiply by 1048576 (1 MiB)
281.It g
282Gibi; multiply by 1073741824 (1 GiB)
283.It t
284Tebi; multiply by 1099511627776 (1 TiB)
285.It w
286Word; multiply by the number of bytes in an integer
287.El
288.\"
289.\"
290.Ss FFS-specific options
291.Sy ffs
292images have ffs-specific optional parameters that may be provided.
293Each of the options consists of a keyword, an equal sign
294.Pq Ql = ,
295and a value.
296The following keywords are supported:
297.Pp
298.Bl -tag -width optimization -offset indent -compact
299.It Sy avgfilesize
300Expected average file size.
301.It Sy avgfpdir
302Expected number of files per directory.
303.It Sy bsize
304Block size.
305.It Sy density
306Bytes per inode.
307.It Sy extattr
308UFS2 with extended attributes.
309.It Sy extent
310Maximum extent size.
311.It Sy fsize
312Fragment size.
313.It Sy label
314Label name of the image.
315.It Sy maxbpcg
316Maximum total number of blocks in a cylinder group.
317.It Sy maxbpg
318Maximum blocks per file in a cylinder group.
319.It Sy minfree
320Minimum % free.
321.It Sy optimization
322Optimization preference; one of
323.Ql space
324or
325.Ql time .
326.It Sy version
327UFS version.
3281 for FFS (default), 2 for UFS2.
329.El
330.Ss CD9660-specific options
331.Sy cd9660
332images have ISO9660-specific optional parameters that may be
333provided.
334The arguments consist of a keyword and, optionally, an equal sign
335.Pq Ql = ,
336and a value.
337The following keywords are supported:
338.Pp
339.Bl -tag -width omit-trailing-period -offset indent -compact
340.It Sy allow-deep-trees
341Allow the directory structure to exceed the maximum specified in
342the spec.
343.\" .It Sy allow-illegal-chars
344.\" Unknown
345.\" .It Sy allow-lowercase
346.\" Unknown
347.It Sy allow-max-name
348Allow 37 instead of 33 characters for filenames by omitting the
349version ID.
350.It Sy allow-multidot
351Allow multiple dots in a filename.
352.It Sy applicationid
353Application ID of the image.
354.It Sy archimedes
355Use the
356.Ql ARCHIMEDES
357extension to encode
358.Tn RISC OS
359metadata.
360.It Sy boot-load-segment
361Set load segment for the boot image.
362.It Sy bootimage
363Filename of a boot image in the format
364.Dq sysid;filename ,
365where
366.Dq sysid
367is one of
368.Ql efi ,
369.Ql i386 ,
370.Ql mac68k ,
371.Ql macppc ,
372or
373.Ql powerpc .
374.It Sy chrp-boot
375Write an MBR partition table to the image to allow older CHRP hardware to
376boot.
377.It Sy generic-bootimage
378Load a generic boot image into the first 32K of the cd9660 image.
379.It Sy hard-disk-boot
380Boot image is a hard disk image.
381.It Sy keep-bad-images
382Don't throw away images whose write was aborted due to an error.
383For debugging purposes.
384.It Sy label
385Label name of the image.
386.It Sy no-boot
387Boot image is not bootable.
388.It Sy no-emul-boot
389Boot image is a
390.Dq no emulation
391ElTorito image.
392.It Sy no-trailing-padding
393Do not pad the image (apparently Linux needs the padding).
394.\" .It Sy omit-trailing-period
395.\" Unknown
396.It Sy platformid
397Set platform ID of section header entry of the boot image.
398.It Sy preparer
399Preparer ID of the image.
400.It Sy publisher
401Publisher ID of the image.
402.It Sy rockridge
403Use RockRidge extensions (for longer filenames, etc.).
404.It Sy volumeid
405Volume set identifier of the image.
406.El
407.Ss CHFS-specific options
408.Sy chfs
409images have chfs-specific optional parameters that may be provided.
410Each of the options consists of a keyword, an equal sign
411.Pq Ql = ,
412and a value.
413The following keywords are supported:
414.Pp
415.Bl -tag -width optimization -offset indent -compact
416.It Sy pagesize
417Pagesize.
418.It Sy erasesize
419Erase block size of the media.
420.It Sy mediatype
421Type of the media.
422NOR: 0 or NAND: 1.
423.El
424.Ss msdos-specific options
425.Sy msdos
426images have MS-DOS-specific optional parameters that may be
427provided.
428The arguments consist of a keyword, an equal sign
429.Pq Ql = ,
430and a value.
431The following keywords are supported (see
432.Xr newfs_msdos 8
433for more details):
434.Pp
435.Bl -tag -width omit-trailing-period -offset indent -compact
436.It Cm backup_sector
437Location of the backup boot sector.
438.It Cm block_size
439Block size.
440.It Cm bootstrap
441Bootstrap file.
442.It Cm bytes_per_sector
443Bytes per sector.
444.It Cm create_size
445Create file size.
446.It Cm directory_entries
447Directory entries.
448.It Cm drive_heads
449Drive heads.
450.It Cm fat_type
451FAT type (12, 16, or 32).
452.It Cm floppy
453Preset drive parameters for standard format floppy disks
454(160, 180, 320, 360, 640, 720, 1200, 1232, 1440, or 2880).
455.It Cm hidden_sectors
456Hidden sectors.
457.It Cm info_sector
458Location of the info sector.
459.It Cm media_descriptor
460Media descriptor.
461.It Cm num_FAT
462Number of FATs.
463.It Cm OEM_string
464OEM string.
465.It Cm offset
466Offset in device.
467.It Cm reserved_sectors
468Reserved sectors.
469.It Cm sectors_per_cluster
470Sectors per cluster.
471.It Cm sectors_per_fat
472Sectors per FAT.
473.It Cm sectors_per_track
474Sectors per track.
475.It Cm size
476File System size.
477.It Cm volume_id
478Volume ID.
479.It Cm volume_label
480Volume Label.
481.El
482.Ss V7FS-specific options
483The following keywords are supported:
484.Pp
485.Bl -tag -width optimization -offset indent -compact
486.It Sy pdp
487PDP endian.
488.It Sy progress
489Display a progress meter for the file system construction and file
490population.
491.El
492.Ss UDF-specific options
493.Nm
494supports besides writing to image files also direct formatting of disc
495partitions and optical media.
496Optical media will auto configure settings.
497The following udf-specific optional parameters may be provided.
498Each of the options consists of a keyword, an equal sign
499.Pq Ql = ,
500and a value.
501The following keywords are supported:
502.Pp
503.Bl -tag -width optimization -offset indent -compact
504.It Sy disctype
505This can have the following values:
506.Bl -tag -width cdromXdvdromXbdromXXX -compact
507.It Sy cdrom , Sy dvdrom , Sy bdrom
508create a read-only fs
509.It Sy dvdram , Sy bdre , Sy disk
510create a rewritable fs without sparing for defective sectors
511.It Sy cdr , Sy dvdr , Sy bdr
512create a rewritable fs on once recordable media using a VAT
513.It Sy cdrw , Sy dvdrw
514create a rewritable fs with sparing for defective sectors
515.El
516The sectorsize is set for the selected media and the default maximum disc size
517is assumed unless overridden.
518For CD-ROM, DVD-ROM and BD-ROM images, the disc
519size is the minimum size needed.
520Note that the size estimator can
521under-estimate in some cases; specify extra free blocks if encountering this.
522.It Sy loglabel
523Set the logical volume label of the disc to the specified argument.
524.It Sy discid
525Set the physical volume label of the disc to the specified argument.
526Prepend the physical volume label with a volumeset label separated
527with a ':' if wanted.
528For strict conformance and interchange, don't set the volumeset label
529manually unless it has an unique hex number in the first 8 character
530positions.
531.It Sy minver
532Set the minimum UDF version to be used.
533Choose UDF version numbers from 0x102, 0x150, 0x200, 0x201, and 0x250.
534Version 0x260 is currently not supported
535in
536.Nm .
537.It Sy maxver
538Set the maximum UDF version to be used.
539Choose UDF version numbers from 0x102, 0x150, 0x200, 0x201, and 0x250.
540Version 0x260 is currently not supported
541in
542.Nm .
543.It Sy metaperc
544Set the minimum amount of free metadata space.
545This is only applicable on UDF 0x250 on rewritable media.
546.It Sy checksurface
547Check the surface of non error-free rewritable media for remapping.
548Note this is a destructive test and can take quite a while!
549.It Sy forceformat
550Force formatting on non-empty recordable media.
551.El
552.Sh SEE ALSO
553.Xr strsuftoll 3 ,
554.Xr installboot 8 ,
555.Xr mtree 8 ,
556.Xr newfs 8
557.Sh HISTORY
558The
559.Nm
560utility appeared in
561.Nx 1.6 .
562.Sh AUTHORS
563.An Luke Mewburn
564.Aq lukem@NetBSD.org
565(original program),
566.An Daniel Watt ,
567.An Walter Deignan ,
568.An Ryan Gabrys ,
569.An Alan Perez-Rathke ,
570.An Ram Vedam
571(cd9660 support),
572.An UCHIYAMA Yasushi
573(v7fs support),
574.An Tamas Toth
575(chfs support),
576.An Christos Zoulas
577(msdos support),
578.An Reinoud Zandijk
579(udf support).
580