1.\" $NetBSD: makefs.8,v 1.72 2024/05/08 15:57:56 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 May 8, 2024 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. 263Repeating this flag causes 264.Nm 265to print a warning for each missing system nodes and exit with an error code 266if there are any missing. 267.It Fl Z 268Create a sparse file for 269.Sy ffs . 270This is useful for virtual machine images. 271.El 272.Pp 273Where sizes are specified, a decimal number of bytes is expected. 274Two or more numbers may be separated by an 275.Sq x 276to indicate a product. 277Each number may have one of the following optional suffixes: 278.Bl -tag -width 3n -offset indent -compact 279.It b 280Block; multiply by 512 281.It k 282Kibi; multiply by 1024 (1 KiB) 283.It m 284Mebi; multiply by 1048576 (1 MiB) 285.It g 286Gibi; multiply by 1073741824 (1 GiB) 287.It t 288Tebi; multiply by 1099511627776 (1 TiB) 289.It w 290Word; multiply by the number of bytes in an integer 291.El 292.\" 293.\" 294.Ss FFS-specific options 295.Sy ffs 296images have ffs-specific optional parameters that may be provided. 297Each of the options consists of a keyword, an equal sign 298.Pq Ql = , 299and a value. 300The following keywords are supported: 301.Pp 302.Bl -tag -width optimization -offset indent -compact 303.It Sy avgfilesize 304Expected average file size. 305.It Sy avgfpdir 306Expected number of files per directory. 307.It Sy bsize 308Block size. 309.It Sy density 310Bytes per inode. 311.It Sy extattr 312UFS2 with extended attributes. 313.It Sy extent 314Maximum extent size. 315.It Sy fsize 316Fragment size. 317.It Sy label 318Label name of the image. 319.It Sy maxbpcg 320Maximum total number of blocks in a cylinder group. 321.It Sy maxbpg 322Maximum blocks per file in a cylinder group. 323.It Sy minfree 324Minimum % free. 325.It Sy optimization 326Optimization preference; one of 327.Ql space 328or 329.Ql time . 330.It Sy version 331UFS version. 3321 for FFS (default), 2 for UFS2. 333.El 334.Ss CD9660-specific options 335.Sy cd9660 336images have ISO9660-specific optional parameters that may be 337provided. 338The arguments consist of a keyword and, optionally, an equal sign 339.Pq Ql = , 340and a value. 341The following keywords are supported: 342.Pp 343.Bl -tag -width omit-trailing-period -offset indent -compact 344.It Sy allow-deep-trees 345Allow the directory structure to exceed the maximum specified in 346the spec. 347.\" .It Sy allow-illegal-chars 348.\" Unknown 349.\" .It Sy allow-lowercase 350.\" Unknown 351.It Sy allow-max-name 352Allow 37 instead of 33 characters for filenames by omitting the 353version ID. 354.It Sy allow-multidot 355Allow multiple dots in a filename. 356.It Sy applicationid 357Application ID of the image. 358.It Sy archimedes 359Use the 360.Ql ARCHIMEDES 361extension to encode 362.Tn RISC OS 363metadata. 364.It Sy boot-load-segment 365Set load segment for the boot image. 366.It Sy bootimage 367Filename of a boot image in the format 368.Dq sysid;filename , 369where 370.Dq sysid 371is one of 372.Ql efi , 373.Ql i386 , 374.Ql mac68k , 375.Ql macppc , 376or 377.Ql powerpc . 378.It Sy chrp-boot 379Write an MBR partition table to the image to allow older CHRP hardware to 380boot. 381.It Sy generic-bootimage 382Load a generic boot image into the first 32K of the cd9660 image. 383.It Sy hard-disk-boot 384Boot image is a hard disk image. 385.It Sy keep-bad-images 386Don't throw away images whose write was aborted due to an error. 387For debugging purposes. 388.It Sy label 389Label name of the image. 390.It Sy no-boot 391Boot image is not bootable. 392.It Sy no-emul-boot 393Boot image is a 394.Dq no emulation 395ElTorito image. 396.It Sy no-trailing-padding 397Do not pad the image (apparently Linux needs the padding). 398.\" .It Sy omit-trailing-period 399.\" Unknown 400.It Sy platformid 401Set platform ID of section header entry of the boot image. 402.It Sy preparer 403Preparer ID of the image. 404.It Sy publisher 405Publisher ID of the image. 406.It Sy rockridge 407Use RockRidge extensions (for longer filenames, etc.). 408.It Sy volumeid 409Volume set identifier of the image. 410.El 411.Ss CHFS-specific options 412.Sy chfs 413images have chfs-specific optional parameters that may be provided. 414Each of the options consists of a keyword, an equal sign 415.Pq Ql = , 416and a value. 417The following keywords are supported: 418.Pp 419.Bl -tag -width optimization -offset indent -compact 420.It Sy pagesize 421Pagesize. 422.It Sy erasesize 423Erase block size of the media. 424.It Sy mediatype 425Type of the media. 426NOR: 0 or NAND: 1. 427.El 428.Ss msdos-specific options 429.Sy msdos 430images have MS-DOS-specific optional parameters that may be 431provided. 432The arguments consist of a keyword, an equal sign 433.Pq Ql = , 434and a value. 435The following keywords are supported (see 436.Xr newfs_msdos 8 437for more details): 438.Pp 439.Bl -tag -width omit-trailing-period -offset indent -compact 440.It Cm backup_sector 441Location of the backup boot sector. 442.It Cm block_size 443Block size. 444.It Cm bootstrap 445Bootstrap file. 446.It Cm bytes_per_sector 447Bytes per sector. 448.It Cm create_size 449Create file size. 450.It Cm directory_entries 451Directory entries. 452.It Cm drive_heads 453Drive heads. 454.It Cm fat_type 455FAT type (12, 16, or 32). 456.It Cm floppy 457Preset drive parameters for standard format floppy disks 458(160, 180, 320, 360, 640, 720, 1200, 1232, 1440, or 2880). 459.It Cm hidden_sectors 460Hidden sectors. 461.It Cm info_sector 462Location of the info sector. 463.It Cm media_descriptor 464Media descriptor. 465.It Cm num_FAT 466Number of FATs. 467.It Cm OEM_string 468OEM string. 469.It Cm offset 470Offset in device. 471.It Cm reserved_sectors 472Reserved sectors. 473.It Cm sectors_per_cluster 474Sectors per cluster. 475.It Cm sectors_per_fat 476Sectors per FAT. 477.It Cm sectors_per_track 478Sectors per track. 479.It Cm size 480File System size. 481.It Cm volume_id 482Volume ID. 483.It Cm volume_label 484Volume Label. 485.El 486.Ss V7FS-specific options 487The following keywords are supported: 488.Pp 489.Bl -tag -width optimization -offset indent -compact 490.It Sy pdp 491PDP endian. 492.It Sy progress 493Display a progress meter for the file system construction and file 494population. 495.El 496.Ss UDF-specific options 497.Nm 498supports besides writing to image files also direct formatting of disc 499partitions and optical media. 500Optical media will auto configure settings. 501The following udf-specific optional parameters may be provided. 502Each of the options consists of a keyword, an equal sign 503.Pq Ql = , 504and a value. 505The following keywords are supported: 506.Pp 507.Bl -tag -width optimization -offset indent -compact 508.It Sy disctype 509This can have the following values: 510.Bl -tag -width cdromXdvdromXbdromXXX -compact 511.It Sy cdrom , Sy dvdrom , Sy bdrom 512create a read-only fs 513.It Sy dvdram , Sy bdre , Sy disk 514create a rewritable fs without sparing for defective sectors 515.It Sy cdr , Sy dvdr , Sy bdr 516create a rewritable fs on once recordable media using a VAT 517.It Sy cdrw , Sy dvdrw 518create a rewritable fs with sparing for defective sectors 519.El 520The sectorsize is set for the selected media and the default maximum disc size 521is assumed unless overridden. 522For CD-ROM, DVD-ROM and BD-ROM images, the disc 523size is the minimum size needed. 524Note that the size estimator can 525under-estimate in some cases; specify extra free blocks if encountering this. 526.It Sy loglabel 527Set the logical volume label of the disc to the specified argument. 528.It Sy discid 529Set the physical volume label of the disc to the specified argument. 530Prepend the physical volume label with a volumeset label separated 531with a ':' if wanted. 532For strict conformance and interchange, don't set the volumeset label 533manually unless it has an unique hex number in the first 8 character 534positions. 535.It Sy minver 536Set the minimum UDF version to be used. 537Choose UDF version numbers from 0x102, 0x150, 0x200, 0x201, and 0x250. 538Version 0x260 is currently not supported 539in 540.Nm . 541.It Sy maxver 542Set the maximum UDF version to be used. 543Choose UDF version numbers from 0x102, 0x150, 0x200, 0x201, and 0x250. 544Version 0x260 is currently not supported 545in 546.Nm . 547.It Sy metaperc 548Set the minimum amount of free metadata space. 549This is only applicable on UDF 0x250 on rewritable media. 550.It Sy checksurface 551Check the surface of non error-free rewritable media for remapping. 552Note this is a destructive test and can take quite a while! 553.It Sy forceformat 554Force formatting on non-empty recordable media. 555.El 556.Sh SEE ALSO 557.Xr strsuftoll 3 , 558.Xr installboot 8 , 559.Xr mtree 8 , 560.Xr newfs 8 561.Sh HISTORY 562The 563.Nm 564utility appeared in 565.Nx 1.6 . 566.Sh AUTHORS 567.An Luke Mewburn 568.Aq lukem@NetBSD.org 569(original program), 570.An Daniel Watt , 571.An Walter Deignan , 572.An Ryan Gabrys , 573.An Alan Perez-Rathke , 574.An Ram Vedam 575(cd9660 support), 576.An UCHIYAMA Yasushi 577(v7fs support), 578.An Tamas Toth 579(chfs support), 580.An Christos Zoulas 581(msdos support), 582.An Reinoud Zandijk 583(udf support). 584