1.\" $NetBSD: makefs.8,v 1.73 2024/10/27 18:35:52 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 October 27, 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 | comma-separated-debug-option 106Enable various levels of debugging, depending upon which bits are 107set in 108.Ar debug-mask . 109The mask can also be set by specifying a comma separated list of debugging 110options. 111These are: 112.Bl -tag -width X -offset indent -compact 113.It Ar debug_time 114Print the time it takes to perform each step. 115.It Ar debug_walk_dir 116Print each directory as it gets processed. 117.It Ar debug_walk_dir_node 118Print each file as it gets processed. 119.It Ar debug_walk_dir_linkcheck 120Print file information for files that have a link count > 1. 121.It Ar debug_dump_fsnodes 122Dump information about the filesystem nodes. 123.It Ar debug_dump_fsnodes_verbose 124Enable more detail if 125.Dv debug_dump_fsnodes 126is enabled. 127.It Ar debug_fs_parse_opts 128Print debugging information about specific filesystem option parsing. 129.It Ar debug_fs_makefs 130Print nodes as they are created and enable buffer consistency checks. 131.It Ar debug_fs_validate 132Enable file-system specific validation (ffs only). 133.It Ar debug_fs_create_image 134Print image file creation stats (ffs only). 135.It Ar debug_fs_size_dir 136Print directory size information (ffs only). 137.It Ar debug_fs_size_dir_node 138Print directory size information per node (ffs only). 139.It Ar debug_fs_size_dir_add_dirent 140Print directory size information as entries are added (ffs only). 141.It Ar debug_fs_populate 142Print information at each directory population pass (ffs only). 143.It Ar debug_fs_populate_dirbuf 144Dump the directory buffer (ffs only). 145.It Ar debug_fs_populate_node 146Print information about each file during directory population (ffs only). 147.It Ar debug_fs_write_file 148Print buffer informaion when writing files (ffs only). 149.It Ar debug_fs_write_file_block 150Print block information when writing files (ffs only). 151.It Ar debug_fs_make_dirbuf 152Print directory buffer information (ffs only). 153.It Ar debug_fs_write_inode 154Print inode information (ffs only). 155.It Ar debug_buf_bread 156Print block buffer information (ffs only). 157.It Ar debug_buf_bwrite 158Print block write information (ffs only). 159.It Ar debug_buf_getblk 160Print block allocaion information (ffs only). 161.It Ar debug_apply_specfile 162Print information about each directory in the specfile. 163.It Ar debug_apply_specentry 164Print information about each entry in the specfile. 165.It Ar debug_apply_speconly 166Debug the 167.Fl x 168special file exclusion. 169.El 170.It Fl F Ar mtree-specfile 171Use 172.Ar mtree-specfile 173as an 174.Xr mtree 8 175.Sq specfile 176specification. 177.Pp 178If a specfile entry exists in the underlying file system, its 179permissions and modification time will be used unless specifically 180overridden by the specfile. 181An error will be raised if the type of entry in the specfile 182conflicts with that of an existing entry. 183.Pp 184In the opposite case (where a specfile entry does not have an entry 185in the underlying file system) the following occurs: 186If the specfile entry is marked 187.Sy optional , 188the specfile entry is ignored. 189Otherwise, the entry will be created in the image, and it is 190necessary to specify at least the following parameters in the 191specfile: 192.Sy type , 193.Sy mode , 194.Sy gname , 195or 196.Sy gid , 197and 198.Sy uname 199or 200.Sy uid , 201.Sy device 202(in the case of block or character devices), and 203.Sy link 204(in the case of symbolic links). 205If 206.Sy time 207isn't provided, the current time will be used. 208If 209.Sy flags 210isn't provided, the current file flags will be used. 211Missing regular file entries will be created as zero-length files. 212.It Fl f Ar free-files 213Ensure that a minimum of 214.Ar free-files 215free files (inodes) exist in the image. 216An optional 217.Ql % 218suffix may be provided to indicate that 219.Ar free-files 220indicates a percentage of the calculated image size. 221.It Fl L 222All symbolic links are followed. 223.It Fl M Ar minimum-size 224Set the minimum size of the file system image to 225.Ar minimum-size . 226.It Fl m Ar maximum-size 227Set the maximum size of the file system image to 228.Ar maximum-size . 229An error will be raised if the target file system needs to be larger 230than this to accommodate the provided directory tree. 231.It Fl N Ar userdb-dir 232Use the user database text file 233.Pa master.passwd 234and group database text file 235.Pa group 236from 237.Ar userdb-dir , 238rather than using the results from the system's 239.Xr getpwnam 3 240and 241.Xr getgrnam 3 242(and related) library calls. 243.It Fl O Ar offset 244Instead of creating the file system at the beginning of the file, start 245at offset. 246Valid only for 247.Sy ffs 248and 249.Sy msdos . 250.It Fl o Ar fs-options 251Set file system specific options. 252.Ar fs-options 253is a comma separated list of options. 254Valid file system specific options are detailed below. 255.It Fl r 256When merging multiple directories replace duplicate files with the last found. 257.It Fl S Ar sector-size 258Set the file system sector size to 259.Ar sector-size . 260Defaults to 512 for most file systems, but is 2048 for 261.Sy cd9660 262and 263.Sy udf 264for CD/DVD/BD optical media types. 265.It Fl s Ar image-size 266Set the size of the file system image to 267.Ar image-size . 268This is equivalent of setting both the minimum 269.Fl ( M ) 270and the maximum 271.Fl ( m ) 272sizes to 273.Ar image-size . 274For 275.Sy ffs 276and 277.Sy msdos 278the 279.Ar offset 280is not included on that size. 281.It Fl T Ar timestamp 282Specify a timestamp to be set for all file system files and directories 283created so that repeatable builds are possible. 284The 285.Ar timestamp 286can be a 287.Pa pathname , 288where the timestamps are derived from that file, a parseable date 289for 290.Xr parsedate 3 291(this option is not yet available in the tools build), or an integer 292value interpreted as the number of seconds from the Epoch. 293Note that timestamps specified in an 294.Xr mtree 5 295spec file, override the default timestamp. 296When this option is enabled, file systems that regularly use 297.Xr localtime 3 298to convert times to the native format (such as udf and cd9660), use 299.Xr gmtime 3 300instead with the specified timestamps so that they are immune to 301timezone changes and get consistent timestamps. 302.It Fl t Ar fs-type 303Create an 304.Ar fs-type 305file system image. 306The following file system types are supported: 307.Bl -tag -width cd9660 -offset indent 308.It Sy cd9660 309ISO 9660 file system. 310.It Sy chfs 311Chip flash file system. 312.It Sy ffs 313BSD fast file system (default). 314.It Sy msdos 315FAT12, FAT16, or FAT32 file system. 316.It Sy udf 317ISO/Ecma UDF file system. 318.It Sy v7fs 3197th Edition(V7) file system. 320.El 321.It Fl x 322Exclude file system nodes not explicitly listed in the specfile. 323Repeating this flag causes 324.Nm 325to print a warning for each missing system nodes and exit with an error code 326if there are any missing. 327.It Fl Z 328Create a sparse file for 329.Sy ffs . 330This is useful for virtual machine images. 331.El 332.Pp 333Where sizes are specified, a decimal number of bytes is expected. 334Two or more numbers may be separated by an 335.Sq x 336to indicate a product. 337Each number may have one of the following optional suffixes: 338.Bl -tag -width 3n -offset indent -compact 339.It b 340Block; multiply by 512 341.It k 342Kibi; multiply by 1024 (1 KiB) 343.It m 344Mebi; multiply by 1048576 (1 MiB) 345.It g 346Gibi; multiply by 1073741824 (1 GiB) 347.It t 348Tebi; multiply by 1099511627776 (1 TiB) 349.It w 350Word; multiply by the number of bytes in an integer 351.El 352.\" 353.\" 354.Ss FFS-specific options 355.Sy ffs 356images have ffs-specific optional parameters that may be provided. 357Each of the options consists of a keyword, an equal sign 358.Pq Ql = , 359and a value. 360The following keywords are supported: 361.Pp 362.Bl -tag -width optimization -offset indent -compact 363.It Sy avgfilesize 364Expected average file size. 365.It Sy avgfpdir 366Expected number of files per directory. 367.It Sy bsize 368Block size. 369.It Sy density 370Bytes per inode. 371.It Sy extattr 372UFS2 with extended attributes. 373.It Sy extent 374Maximum extent size. 375.It Sy fsize 376Fragment size. 377.It Sy label 378Label name of the image. 379.It Sy maxbpcg 380Maximum total number of blocks in a cylinder group. 381.It Sy maxbpg 382Maximum blocks per file in a cylinder group. 383.It Sy minfree 384Minimum % free. 385.It Sy optimization 386Optimization preference; one of 387.Ql space 388or 389.Ql time . 390.It Sy version 391UFS version. 3921 for FFS (default), 2 for UFS2. 393.El 394.Ss CD9660-specific options 395.Sy cd9660 396images have ISO9660-specific optional parameters that may be 397provided. 398The arguments consist of a keyword and, optionally, an equal sign 399.Pq Ql = , 400and a value. 401The following keywords are supported: 402.Pp 403.Bl -tag -width omit-trailing-period -offset indent -compact 404.It Sy allow-deep-trees 405Allow the directory structure to exceed the maximum specified in 406the spec. 407.\" .It Sy allow-illegal-chars 408.\" Unknown 409.\" .It Sy allow-lowercase 410.\" Unknown 411.It Sy allow-max-name 412Allow 37 instead of 33 characters for filenames by omitting the 413version ID. 414.It Sy allow-multidot 415Allow multiple dots in a filename. 416.It Sy applicationid 417Application ID of the image. 418.It Sy archimedes 419Use the 420.Ql ARCHIMEDES 421extension to encode 422.Tn RISC OS 423metadata. 424.It Sy boot-load-segment 425Set load segment for the boot image. 426.It Sy bootimage 427Filename of a boot image in the format 428.Dq sysid;filename , 429where 430.Dq sysid 431is one of 432.Ql efi , 433.Ql i386 , 434.Ql mac68k , 435.Ql macppc , 436or 437.Ql powerpc . 438.It Sy chrp-boot 439Write an MBR partition table to the image to allow older CHRP hardware to 440boot. 441.It Sy generic-bootimage 442Load a generic boot image into the first 32K of the cd9660 image. 443.It Sy hard-disk-boot 444Boot image is a hard disk image. 445.It Sy keep-bad-images 446Don't throw away images whose write was aborted due to an error. 447For debugging purposes. 448.It Sy label 449Label name of the image. 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 459.\" Unknown 460.It Sy platformid 461Set platform ID of section header entry of the boot image. 462.It Sy preparer 463Preparer ID of the image. 464.It Sy publisher 465Publisher ID of the image. 466.It Sy rockridge 467Use RockRidge extensions (for longer filenames, etc.). 468.It Sy volumeid 469Volume set identifier of the image. 470.El 471.Ss CHFS-specific options 472.Sy chfs 473images have chfs-specific optional parameters that may be provided. 474Each of the options consists of a keyword, an equal sign 475.Pq Ql = , 476and a value. 477The following keywords are supported: 478.Pp 479.Bl -tag -width optimization -offset indent -compact 480.It Sy pagesize 481Pagesize. 482.It Sy erasesize 483Erase block size of the media. 484.It Sy mediatype 485Type of the media. 486NOR: 0 or NAND: 1. 487.El 488.Ss msdos-specific options 489.Sy msdos 490images have MS-DOS-specific optional parameters that may be 491provided. 492The arguments consist of a keyword, an equal sign 493.Pq Ql = , 494and a value. 495The following keywords are supported (see 496.Xr newfs_msdos 8 497for more details): 498.Pp 499.Bl -tag -width omit-trailing-period -offset indent -compact 500.It Cm backup_sector 501Location of the backup boot sector. 502.It Cm block_size 503Block size. 504.It Cm bootstrap 505Bootstrap file. 506.It Cm bytes_per_sector 507Bytes per sector. 508.It Cm create_size 509Create file size. 510.It Cm directory_entries 511Directory entries. 512.It Cm drive_heads 513Drive heads. 514.It Cm fat_type 515FAT type (12, 16, or 32). 516.It Cm floppy 517Preset drive parameters for standard format floppy disks 518(160, 180, 320, 360, 640, 720, 1200, 1232, 1440, or 2880). 519.It Cm hidden_sectors 520Hidden sectors. 521.It Cm info_sector 522Location of the info sector. 523.It Cm media_descriptor 524Media descriptor. 525.It Cm num_FAT 526Number of FATs. 527.It Cm OEM_string 528OEM string. 529.It Cm offset 530Offset in device. 531.It Cm reserved_sectors 532Reserved sectors. 533.It Cm sectors_per_cluster 534Sectors per cluster. 535.It Cm sectors_per_fat 536Sectors per FAT. 537.It Cm sectors_per_track 538Sectors per track. 539.It Cm size 540File System size. 541.It Cm volume_id 542Volume ID. 543.It Cm volume_label 544Volume Label. 545.El 546.Ss V7FS-specific options 547The following keywords are supported: 548.Pp 549.Bl -tag -width optimization -offset indent -compact 550.It Sy pdp 551PDP endian. 552.It Sy progress 553Display a progress meter for the file system construction and file 554population. 555.El 556.Ss UDF-specific options 557.Nm 558supports besides writing to image files also direct formatting of disc 559partitions and optical media. 560Optical media will auto configure settings. 561The following udf-specific optional parameters may be provided. 562Each of the options consists of a keyword, an equal sign 563.Pq Ql = , 564and a value. 565The following keywords are supported: 566.Pp 567.Bl -tag -width optimization -offset indent -compact 568.It Sy disctype 569This can have the following values: 570.Bl -tag -width cdromXdvdromXbdromXXX -compact 571.It Sy cdrom , Sy dvdrom , Sy bdrom 572create a read-only fs 573.It Sy dvdram , Sy bdre , Sy disk 574create a rewritable fs without sparing for defective sectors 575.It Sy cdr , Sy dvdr , Sy bdr 576create a rewritable fs on once recordable media using a VAT 577.It Sy cdrw , Sy dvdrw 578create a rewritable fs with sparing for defective sectors 579.El 580The sectorsize is set for the selected media and the default maximum disc size 581is assumed unless overridden. 582For CD-ROM, DVD-ROM and BD-ROM images, the disc 583size is the minimum size needed. 584Note that the size estimator can 585under-estimate in some cases; specify extra free blocks if encountering this. 586.It Sy loglabel 587Set the logical volume label of the disc to the specified argument. 588.It Sy discid 589Set the physical volume label of the disc to the specified argument. 590Prepend the physical volume label with a volumeset label separated 591with a ':' if wanted. 592For strict conformance and interchange, don't set the volumeset label 593manually unless it has an unique hex number in the first 8 character 594positions. 595.It Sy minver 596Set the minimum UDF version to be used. 597Choose UDF version numbers from 0x102, 0x150, 0x200, 0x201, and 0x250. 598Version 0x260 is currently not supported 599in 600.Nm . 601.It Sy maxver 602Set the maximum UDF version to be used. 603Choose UDF version numbers from 0x102, 0x150, 0x200, 0x201, and 0x250. 604Version 0x260 is currently not supported 605in 606.Nm . 607.It Sy metaperc 608Set the minimum amount of free metadata space. 609This is only applicable on UDF 0x250 on rewritable media. 610.It Sy checksurface 611Check the surface of non error-free rewritable media for remapping. 612Note this is a destructive test and can take quite a while! 613.It Sy forceformat 614Force formatting on non-empty recordable media. 615.El 616.Sh SEE ALSO 617.Xr strsuftoll 3 , 618.Xr installboot 8 , 619.Xr mtree 8 , 620.Xr newfs 8 621.Sh HISTORY 622The 623.Nm 624utility appeared in 625.Nx 1.6 . 626.Sh AUTHORS 627.An Luke Mewburn 628.Aq lukem@NetBSD.org 629(original program), 630.An Daniel Watt , 631.An Walter Deignan , 632.An Ryan Gabrys , 633.An Alan Perez-Rathke , 634.An Ram Vedam 635(cd9660 support), 636.An UCHIYAMA Yasushi 637(v7fs support), 638.An Tamas Toth 639(chfs support), 640.An Christos Zoulas 641(msdos support), 642.An Reinoud Zandijk 643(udf support). 644