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