aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/makefs/makefs.8
blob: 464583eab3a1bba3ad9ace4d2170721bf9255204 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
.\"	$NetBSD: makefs.8,v 1.33 2011/05/22 21:51:39 christos Exp $
.\"
.\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
.\" All rights reserved.
.\"
.\" Written by Luke Mewburn for Wasabi Systems, Inc.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"      This product includes software developed for the NetBSD Project by
.\"      Wasabi Systems, Inc.
.\" 4. The name of Wasabi Systems, Inc. may not be used to endorse
.\"    or promote products derived from this software without specific prior
.\"    written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd August 5, 2022
.Dt MAKEFS 8
.Os
.Sh NAME
.Nm makefs
.Nd create a file system image from a directory tree or a mtree manifest
.Sh SYNOPSIS
.Nm
.Op Fl DxZ
.Op Fl B Ar endian
.Op Fl b Ar free-blocks
.Op Fl d Ar debug-mask
.Op Fl F Ar mtree-specfile
.Op Fl f Ar free-files
.Op Fl M Ar minimum-size
.Op Fl m Ar maximum-size
.Op Fl N Ar userdb-dir
.Op Fl O Ar offset
.Op Fl o Ar fs-options
.Op Fl R Ar roundup-size
.Op Fl S Ar sector-size
.Op Fl s Ar image-size
.Op Fl T Ar timestamp
.Op Fl t Ar fs-type
.Ar image-file
.Ar directory | manifest
.Op Ar extra-directory ...
.Sh DESCRIPTION
The utility
.Nm
creates a file system image into
.Ar image-file
from the directory tree
.Ar directory
or from the mtree manifest
.Ar manifest .
If any optional directory trees are passed in the
.Ar extra-directory
arguments, then the directory tree of each argument will be merged
into the
.Ar directory
or
.Ar manifest
first before creating
.Ar image-file .
No special devices or privileges are required to perform this task.
.Pp
The options are as follows:
.Bl -tag -width flag
.It Fl B Ar endian
Set the byte order of the image to
.Ar endian .
Valid byte orders are
.Ql 4321 ,
.Ql big ,
or
.Ql be
for big endian, and
.Ql 1234 ,
.Ql little ,
or
.Ql le
for little endian.
Some file systems may have a fixed byte order; in those cases this
argument will be ignored.
.It Fl b Ar free-blocks
Ensure that a minimum of
.Ar free-blocks
free blocks exist in the image.
An optional
.Ql %
suffix may be provided to indicate that
.Ar free-blocks
indicates a percentage of the calculated image size.
.It Fl D
Treat duplicate paths in an mtree manifest as warnings not error.
.It Fl d Ar debug-mask
Enable various levels of debugging, depending upon which bits are
set in
.Ar debug-mask .
XXX: document these
.It Fl F Ar mtree-specfile
.Em This is almost certainly not the option you are looking for.
To create an image from a list of files in an mtree format manifest,
specify it as the last argument on the command line, not as a the
argument to
.Fl F .
.Pp
Use
.Ar mtree-specfile
as an
.Xr mtree 8
.Sq specfile
specification.
This option has no effect when the image is created from a mtree manifest
rather than a directory.
.Pp
If a specfile entry exists in the underlying file system, its
permissions and modification time will be used unless specifically
overridden by the specfile.
An error will be raised if the type of entry in the specfile
conflicts with that of an existing entry.
.Pp
In the opposite case (where a specfile entry does not have an entry
in the underlying file system) the following occurs:
If the specfile entry is marked
.Sy optional ,
the specfile entry is ignored.
Otherwise, the entry will be created in the image, and it is
necessary to specify at least the following parameters in the
specfile:
.Sy type ,
.Sy mode ,
.Sy gname ,
or
.Sy gid ,
and
.Sy uname
or
.Sy uid ,
and
.Sy link
(in the case of symbolic links).
If
.Sy time
is not provided, the current time will be used.
If
.Sy flags
is not provided, the current file flags will be used.
Missing regular file entries will be created as zero-length files.
.It Fl f Ar free-files
Ensure that a minimum of
.Ar free-files
free files (inodes) exist in the image.
An optional
.Ql %
suffix may be provided to indicate that
.Ar free-files
indicates a percentage of the calculated image size.
.It Fl M Ar minimum-size
Set the minimum size of the file system image to
.Ar minimum-size .
.It Fl m Ar maximum-size
Set the maximum size of the file system image to
.Ar maximum-size .
An error will be raised if the target file system needs to be larger
than this to accommodate the provided directory tree.
.It Fl N Ar userdb-dir
Use the user database text file
.Pa master.passwd
and group database text file
.Pa group
from
.Ar userdb-dir ,
rather than using the results from the system's
.Xr getpwnam 3
and
.Xr getgrnam 3
(and related) library calls.
.It Fl O Ar offset
Instead of creating the filesystem at the beginning of the file, start
at offset.
Valid only for
.Sy ffs
and
.Sy msdos .
.It Fl o Ar fs-options
Set file system specific options.
.Ar fs-options
is a comma separated list of options.
Valid file system specific options are detailed below.
.It Fl p
Deprecated.
See the
.Fl Z
flag.
.It Fl R Ar roundup-size
Round the image up to
.Ar roundup-size .
.Ar roundup-size
should be a multiple of the file system block size.
This option only applies to the
.Sy ffs
file system type.
.It Fl S Ar sector-size
Set the file system sector size to
.Ar sector-size .
.\" XXX: next line also true for cd9660?
Defaults to 512.
.It Fl s Ar image-size
Set the size of the file system image to
.Ar image-size .
This is equivalent to setting both the minimum
.Fl ( M )
and the maximum
.Fl ( m )
sizes to the same value.
For
.Sy ffs
and
.Sy msdos
the
.Ar image-size
does not include the
.Ar offset .
.Ar offset
is not included in that size.
.It Fl T Ar timestamp
Specify a timestamp to be set for all filesystem files and directories
created so that repeatable builds are possible.
The
.Ar timestamp
can be a
.Pa pathname ,
where the timestamps are derived from that file, or an integer
value interpreted as the number of seconds from the Epoch.
Note that timestamps specified in an
.Xr mtree 5
spec file, override the default timestamp.
.It Fl t Ar fs-type
Create an
.Ar fs-type
file system image.
The following file system types are supported:
.Bl -tag -width cd9660 -offset indent
.It Sy ffs
BSD fast file system (default).
.It Sy cd9660
ISO 9660 file system.
.It Sy msdos
FAT12, FAT16, or FAT32 file system.
.It Sy zfs
ZFS pool containing one or more file systems.
.El
.It Fl x
Exclude file system nodes not explicitly listed in the specfile.
.It Fl Z
Create a sparse file for
.Sy ffs .
This is useful for virtual machine images.
.El
.Pp
Where sizes are specified, a decimal number of bytes is expected.
Two or more numbers may be separated by an
.Dq x
to indicate a product.
Each number may have one of the following optional suffixes:
.Bl -tag -width 3n -offset indent -compact
.It b
Block; multiply by 512
.It k
Kibi; multiply by 1024 (1 KiB)
.It m
Mebi; multiply by 1048576 (1 MiB)
.It g
Gibi; multiply by 1073741824 (1 GiB)
.It t
Tebi; multiply by 1099511627776 (1 TiB)
.It w
Word; multiply by the number of bytes in an integer
.El
.\"
.\"
.Ss FFS-specific options
.Sy ffs
images have ffs-specific optional parameters that may be provided.
Each of the options consists of a keyword, an equal sign
.Pq Ql = ,
and a value.
The following keywords are supported:
.Pp
.Bl -tag -width optimization -offset indent -compact
.It Sy avgfilesize
Expected average file size.
.It Sy avgfpdir
Expected number of files per directory.
.It Sy bsize
Block size.
.It Sy density
Bytes per inode. If unset, will allocate the minimum number of inodes to
represent the filesystem if no free space has been requested (free blocks
or minimum size set); otherwise the larger of the newfs defaults or what
is required by the free inode parameters if set.
.It Sy fsize
Fragment size.
.It Sy label
Label name of the image.
.It Sy maxbpg
Maximum blocks per file in a cylinder group.
.It Sy minfree
Minimum % free.
.It Sy optimization
Optimization preference; one of
.Ql space
or
.Ql time .
.It Sy extent
Maximum extent size.
.It Sy maxbpcg
Maximum total number of blocks in a cylinder group.
.It Sy version
UFS version.
1 for FFS (default), 2 for UFS2.
.It Sy softupdates
0 for disable (default), 1 for enable
.El
.Ss CD9660-specific options
.Sy cd9660
images have ISO9660-specific optional parameters that may be
provided.
The arguments consist of a keyword and, optionally, an equal sign
.Pq Ql = ,
and a value.
The following keywords are supported:
.Pp
.Bl -tag -width omit-trailing-period -offset indent -compact
.It Sy allow-deep-trees
Allow the directory structure to exceed the maximum specified in
the spec.
.It Sy allow-illegal-chars
Allow illegal characters in filenames.
This option is not implemented.
.It Sy allow-lowercase
Allow lowercase characters in filenames.
This option is not implemented.
.It Sy allow-max-name
Allow 37 instead of 33 characters for filenames by omitting the
version id.
.It Sy allow-multidot
Allow multiple dots in a filename.
.It Sy applicationid
Application ID of the image.
.It Sy archimedes
Use the
.Ql ARCHIMEDES
extension to encode
.Tn RISC OS
metadata.
.It Sy bootimagedir
Boot image directory.
This option is not implemented.
.It Sy chrp-boot
Write an MBR partition table to the image to allow older CHRP hardware to
boot.
.It Sy boot-load-segment
Set load segment for the boot image.
.It Sy bootimage
Filename of a boot image in the format
.Dq sysid;filename ,
where
.Dq sysid
is one of
.Ql efi ,
.Ql i386 ,
.Ql mac68k ,
.Ql macppc ,
or
.Ql powerpc .
.It Sy generic-bootimage
Load a generic boot image into the first 32K of the cd9660 image.
.It Sy hard-disk-boot
Boot image is a hard disk image.
.It Sy isolevel
An integer representing the ISO 9660 interchange level where
.Dq level
is either
.Ql 1
or
.Ql 2 .
.Dq level
.Ql 3
is not implemented.
.It Sy keep-bad-images
Do not discard images whose write was aborted due to an error.
For debugging purposes.
.It Sy label
Label name of the image.
.It Sy no-boot
Boot image is not bootable.
.It Sy no-emul-boot
Boot image is a
.Dq no emulation
ElTorito image.
.It Sy no-trailing-padding
Do not pad the image (apparently Linux needs the padding).
.It Sy omit-trailing-period
Omit trailing periods in filenames.
.It Sy platformid
Set platform ID of section header entry of the boot image.
.It Sy preparer
Preparer ID of the image.
.It Sy publisher
Publisher ID of the image.
.It Sy rockridge
Use RockRidge extensions (for longer filenames, etc.).
.It Sy verbose
Turns on verbose output.
.It Sy volumeid
Volume set identifier of the image.
.El
.Ss msdos-specific options
.Sy msdos
images have MS-DOS-specific optional parameters that may be
provided.
The arguments consist of a keyword, an equal sign
.Pq Ql = ,
and a value.
The following keywords are supported (see
.Xr newfs_msdos 8
for more details):
.Pp
.Bl -tag -width omit-trailing-period -offset indent -compact
.It Cm backup_sector
Location of the backup boot sector.
.It Cm block_size
Block size.
.It Cm bootstrap
Bootstrap file.
.It Cm bytes_per_sector
Bytes per sector.
.It Cm create_size
Create file size.
.It Cm directory_entries
Directory entries.
.It Cm drive_heads
Drive heads.
.It Cm fat_type
FAT type (12, 16, or 32).
.It Cm floppy
Preset drive parameters for standard format floppy disks
(160, 180, 320, 360, 640, 720, 1200, 1232, 1440, or 2880).
.It Cm hidden_sectors
Hidden sectors.
.It Cm info_sector
Location of the info sector.
.It Cm media_descriptor
Media descriptor.
.It Cm num_FAT
Number of FATs.
.It Cm OEM_string
OEM string.
.It Cm offset
Offset in device.
This option will be ignored if
.Fl O
is set to a positive number.
.It Cm reserved_sectors
Reserved sectors.
.It Cm sectors_per_cluster
Sectors per cluster.
.It Cm sectors_per_fat
Sectors per FAT.
.It Cm sectors_per_track
Sectors per track.
.It Cm size
File System size.
.It Cm volume_id
Volume ID.
.It Cm volume_label
Volume Label.
.El
.Ss zfs-specific options
Note: ZFS support is currently considered experimental.
Do not use it for anything critical.
.Pp
The image created by
.Nm
contains a ZFS pool with a single vdev of type
.Ql disk .
The root dataset is always created implicitly and contains the entire input
directory tree unless additional datasets are specified using the options
described below.
.Pp
The arguments consist of a keyword, an equal sign
.Pq Ql = ,
and a value.
The following keywords are supported:
.Pp
.Bl -tag -width omit-trailing-period -offset indent -compact
.It ashift
The base-2 logarithm of the minimum block size.
Typical values are 9 (512B blocks) and 12 (4KB blocks).
The default value is 12.
.It bootfs
The name of the bootable dataset for the pool.
Specifying this option causes the
.Ql bootfs
property to be set in the created pool.
.It mssize
The size of metaslabs in the created pool.
By default,
.Nm
allocates large (up to 512MB) metaslabs with the expectation that
the image will be auto-expanded upon first use.
This option allows the default heuristic to be overridden.
.It poolname
The name of the ZFS pool.
This option must be specified.
.It rootpath
An implicit path prefix added to dataset mountpoints.
By default it is
.Pa /<poolname> .
For creating bootable pools, the
.Va rootpath
should be set to
.Pa / .
At least one dataset must have a mountpoint equal to
.Va rootpath .
.It fs
Create an additional dataset.
This option may be specified multiple times.
The argument value must be of the form
.Ar <dataset>[;<prop1=v1>[;<prop2=v2>[;...]]] ,
where
.Ar dataset
is the name of the dataset and must belong to the pool's namespace.
For example, with a pool name of
.Ql test
all dataset names must be prefixed by
.Ql test/ .
A dataset must exist at each level of the pool's namespace.
For example, to create
.Ql test/foo/bar ,
.Ql test/foo
must be created as well.
.Pp
The dataset mountpoints determine how the datasets are populated with
files from the staged directory tree.
Conceptually, all datasets are mounted before any are populated with files.
The root of the staged directory tree is mapped to
.Va rootpath .
.Pp
Dataset properties, as described in
.Xr zfsprops 8 ,
may be specified following the dataset name.
The following properties may be set for a dataset:
.Pp
.Bl -tag -compact -offset indent
.It atime
.It canmount
.It exec
.It mountpoint
.It setuid
.El
.El
.Sh SEE ALSO
.Xr mtree 5 ,
.Xr mtree 8 ,
.Xr newfs 8 ,
.Xr zfsconcepts 8 ,
.Xr zfsprops 8 ,
.Xr zpoolprops 8
.Sh HISTORY
The
.Nm
utility appeared in
.Nx 1.6 .
It was ported to
.Fx
and first appeared in
.Fx 8.0 .
.Sh AUTHORS
.An Luke Mewburn
.Aq Mt lukem@NetBSD.org
(original program),
.An Daniel Watt ,
.An Walter Deignan ,
.An Ryan Gabrys ,
.An Alan Perez-Rathke ,
.An Ram Vedam
(cd9660 support),
.An Christos Zoulas
(msdos support),
.An Mark Johnston
(zfs support).