1.\" $NetBSD: makefs.8,v 1.67 2021/04/03 14:10:56 simonb 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 . 200.\" XXX: next line also true for cd9660? 201Defaults to 512. 202.It Fl s Ar image-size 203Set the size of the file system image to 204.Ar image-size . 205This is equivalent of setting both the minimum 206.Fl ( M ) 207and the maximum 208.Fl ( m ) 209sizes to 210.Ar image-size . 211For 212.Sy ffs 213and 214.Sy msdos 215the 216.Ar offset 217is not included on that size. 218.It Fl T Ar timestamp 219Specify a timestamp to be set for all file system files and directories 220created so that repeatable builds are possible. 221The 222.Ar timestamp 223can be a 224.Pa pathname , 225where the timestamps are derived from that file, a parseable date 226for 227.Xr parsedate 3 228(this option is not yet available in the tools build), or an integer 229value interpreted as the number of seconds from the Epoch. 230Note that timestamps specified in an 231.Xr mtree 5 232spec file, override the default timestamp. 233When this option is enabled, file systems that regularly use 234.Xr localtime 3 235to convert times to the native format (such as udf and cd9660), use 236.Xr gmtime 3 237instead with the specified timestamps so that they are immune to 238timezone changes and get consistent timestamps. 239.It Fl t Ar fs-type 240Create an 241.Ar fs-type 242file system image. 243The following file system types are supported: 244.Bl -tag -width cd9660 -offset indent 245.It Sy cd9660 246ISO 9660 file system. 247.It Sy chfs 248Chip flash file system. 249.It Sy ffs 250BSD fast file system (default). 251.It Sy msdos 252FAT12, FAT16, or FAT32 file system. 253.It Sy udf 254ISO/Ecma UDF file system. 255.It Sy v7fs 2567th Edition(V7) file system. 257.El 258.It Fl x 259Exclude file system nodes not explicitly listed in the specfile. 260.It Fl Z 261Create a sparse file for 262.Sy ffs . 263This is useful for virtual machine images. 264.El 265.Pp 266Where sizes are specified, a decimal number of bytes is expected. 267Two or more numbers may be separated by an 268.Sq x 269to indicate a product. 270Each number may have one of the following optional suffixes: 271.Bl -tag -width 3n -offset indent -compact 272.It b 273Block; multiply by 512 274.It k 275Kibi; multiply by 1024 (1 KiB) 276.It m 277Mebi; multiply by 1048576 (1 MiB) 278.It g 279Gibi; multiply by 1073741824 (1 GiB) 280.It t 281Tebi; multiply by 1099511627776 (1 TiB) 282.It w 283Word; multiply by the number of bytes in an integer 284.El 285.\" 286.\" 287.Ss FFS-specific options 288.Sy ffs 289images have ffs-specific optional parameters that may be provided. 290Each of the options consists of a keyword, an equal sign 291.Pq Ql = , 292and a value. 293The following keywords are supported: 294.Pp 295.Bl -tag -width optimization -offset indent -compact 296.It Sy avgfilesize 297Expected average file size. 298.It Sy avgfpdir 299Expected number of files per directory. 300.It Sy bsize 301Block size. 302.It Sy density 303Bytes per inode. 304.It Sy extent 305Maximum extent size. 306.It Sy fsize 307Fragment size. 308.It Sy label 309Label name of the image. 310.It Sy maxbpcg 311Maximum total number of blocks in a cylinder group. 312.It Sy maxbpg 313Maximum blocks per file in a cylinder group. 314.It Sy minfree 315Minimum % free. 316.It Sy optimization 317Optimization preference; one of 318.Ql space 319or 320.Ql time . 321.It Sy version 322UFS version. 3231 for FFS (default), 2 for UFS2. 324.El 325.Ss CD9660-specific options 326.Sy cd9660 327images have ISO9660-specific optional parameters that may be 328provided. 329The arguments consist of a keyword and, optionally, an equal sign 330.Pq Ql = , 331and a value. 332The following keywords are supported: 333.Pp 334.Bl -tag -width omit-trailing-period -offset indent -compact 335.It Sy allow-deep-trees 336Allow the directory structure to exceed the maximum specified in 337the spec. 338.\" .It Sy allow-illegal-chars 339.\" Unknown 340.\" .It Sy allow-lowercase 341.\" Unknown 342.It Sy allow-max-name 343Allow 37 instead of 33 characters for filenames by omitting the 344version ID. 345.It Sy allow-multidot 346Allow multiple dots in a filename. 347.It Sy applicationid 348Application ID of the image. 349.It Sy archimedes 350Use the 351.Ql ARCHIMEDES 352extension to encode 353.Tn RISC OS 354metadata. 355.It Sy boot-load-segment 356Set load segment for the boot image. 357.It Sy bootimage 358Filename of a boot image in the format 359.Dq sysid;filename , 360where 361.Dq sysid 362is one of 363.Ql efi , 364.Ql i386 , 365.Ql mac68k , 366.Ql macppc , 367or 368.Ql powerpc . 369.It Sy chrp-boot 370Write an MBR partition table to the image to allow older CHRP hardware to 371boot. 372.It Sy generic-bootimage 373Load a generic boot image into the first 32K of the cd9660 image. 374.It Sy hard-disk-boot 375Boot image is a hard disk image. 376.It Sy keep-bad-images 377Don't throw away images whose write was aborted due to an error. 378For debugging purposes. 379.It Sy label 380Label name of the image. 381.It Sy no-boot 382Boot image is not bootable. 383.It Sy no-emul-boot 384Boot image is a 385.Dq no emulation 386ElTorito image. 387.It Sy no-trailing-padding 388Do not pad the image (apparently Linux needs the padding). 389.\" .It Sy omit-trailing-period 390.\" Unknown 391.It Sy platformid 392Set platform ID of section header entry of the boot image. 393.It Sy preparer 394Preparer ID of the image. 395.It Sy publisher 396Publisher ID of the image. 397.It Sy rockridge 398Use RockRidge extensions (for longer filenames, etc.). 399.It Sy volumeid 400Volume set identifier of the image. 401.El 402.Ss CHFS-specific options 403.Sy chfs 404images have chfs-specific optional parameters that may be provided. 405Each of the options consists of a keyword, an equal sign 406.Pq Ql = , 407and a value. 408The following keywords are supported: 409.Pp 410.Bl -tag -width optimization -offset indent -compact 411.It Sy pagesize 412Pagesize. 413.It Sy erasesize 414Erase block size of the media. 415.It Sy mediatype 416Type of the media. 417NOR: 0 or NAND: 1. 418.El 419.Ss msdos-specific options 420.Sy msdos 421images have MS-DOS-specific optional parameters that may be 422provided. 423The arguments consist of a keyword, an equal sign 424.Pq Ql = , 425and a value. 426The following keywords are supported (see 427.Xr newfs_msdos 8 428for more details): 429.Pp 430.Bl -tag -width omit-trailing-period -offset indent -compact 431.It Cm backup_sector 432Location of the backup boot sector. 433.It Cm block_size 434Block size. 435.It Cm bootstrap 436Bootstrap file. 437.It Cm bytes_per_sector 438Bytes per sector. 439.It Cm create_size 440Create file size. 441.It Cm directory_entries 442Directory entries. 443.It Cm drive_heads 444Drive heads. 445.It Cm fat_type 446FAT type (12, 16, or 32). 447.It Cm floppy 448Preset drive parameters for standard format floppy disks 449(160, 180, 320, 360, 640, 720, 1200, 1232, 1440, or 2880). 450.It Cm hidden_sectors 451Hidden sectors. 452.It Cm info_sector 453Location of the info sector. 454.It Cm media_descriptor 455Media descriptor. 456.It Cm num_FAT 457Number of FATs. 458.It Cm OEM_string 459OEM string. 460.It Cm offset 461Offset in device. 462.It Cm reserved_sectors 463Reserved sectors. 464.It Cm sectors_per_cluster 465Sectors per cluster. 466.It Cm sectors_per_fat 467Sectors per FAT. 468.It Cm sectors_per_track 469Sectors per track. 470.It Cm size 471File System size. 472.It Cm volume_id 473Volume ID. 474.It Cm volume_label 475Volume Label. 476.El 477.Ss V7FS-specific options 478The following keywords are supported: 479.Pp 480.Bl -tag -width optimization -offset indent -compact 481.It Sy pdp 482PDP endian. 483.It Sy progress 484Display a progress meter for the file system construction and file 485population. 486.El 487.Ss UDF-specific options 488.Sy udf 489images have udf-specific optional parameters that may be provided. 490Each of the options consists of a keyword, an equal sign 491.Pq Ql = , 492and a value. 493The following keywords are supported: 494.Pp 495.Bl -tag -width optimization -offset indent -compact 496.It Sy disctype 497This can have the following values: 498.Bl -tag -width cdromXdvdromXbdromXXX -compact 499.It Sy cdrom , Sy dvdrom , Sy bdrom 500create a read-only fs 501.It Sy dvdram , Sy bdre , Sy disk 502create a rewritable fs without sparing for defective sectors 503.It Sy cdr , Sy dvdr , Sy bdr 504create a rewritable fs on once recordable media using a VAT 505.It Sy cdrw , Sy dvdrw 506create a rewritable fs with sparing for defective sectors 507.El 508When an optical media is selected here, the sectorsize and the default disc 509size is assumed unless given explicitly. 510For rom images the disc size is the minimum needed. 511.It Sy loglabel 512Set the logical volume label of the disc to the specified argument. 513.It Sy discid 514Set the physical volume label of the disc to the specified argument. 515Prepend the physical volume label with a volumeset label separated 516with a ':' if wanted. 517For strict conformance and interchange, don't set the volumeset label 518manually unless it has an unique hex number in the first 8 character 519positions. 520.It Sy minver 521Set the minimum UDF version to be used. 522Choose UDF version numbers from 0x102, 0x150, 0x200, and 0x201. 523Versions 0x250 and 0x260 are currently not supported 524in 525.Nm . 526.El 527.Sh SEE ALSO 528.Xr strsuftoll 3 , 529.Xr installboot 8 , 530.Xr mtree 8 , 531.Xr newfs 8 532.Sh HISTORY 533The 534.Nm 535utility appeared in 536.Nx 1.6 . 537.Sh AUTHORS 538.An Luke Mewburn 539.Aq lukem@NetBSD.org 540(original program), 541.An Daniel Watt , 542.An Walter Deignan , 543.An Ryan Gabrys , 544.An Alan Perez-Rathke , 545.An Ram Vedam 546(cd9660 support), 547.An UCHIYAMA Yasushi 548(v7fs support), 549.An Tamas Toth 550(chfs support), 551.An Christos Zoulas 552(msdos support), 553.An Reinoud Zandijk 554(udf support). 555