MAKEFS(8)

NAME
makefs - create a file system image from a directory tree

SYNOPSIS
makefs [-LrxZ] [-B endian] [-b free-blocks] [-d debug-mask] [-F mtree-specfile] [-f free-files] [-M minimum-size] [-m maximum-size] [-N userdb-dir] [-O offset] [-o fs-options] [-S sector-size] [-s image-size] [-T timestamp] [-t fs-type] image-file directory [extra-directory ...]

DESCRIPTION
The utility makefs creates a file system image into image-file from the directory tree directory. If any optional directory trees are passed in the extra-directory arguments, then the directory tree of each argument will be merged into the directory first before creating image-file. No special devices or privileges are required to perform this task.

The options are as follows:

-B endian
    Set the byte order of the image to endian. Valid byte orders are ‘4321’, ‘big’, or ‘be’ for big endian, and ‘1234’, ‘little’, or ‘le’ for little endian. Some file systems may have a fixed byte order; in those cases this argument will be ignored.

-b free-blocks
    Ensure that a minimum of free-blocks free blocks exist in the image. An optional ‘%’ suffix may be provided to indicate that free-blocks indicates a percentage of the calculated image size.

-d debug-mask | comma-separated-debug-option
    Enable various levels of debugging, depending upon which bits are set in debug-mask. The mask can also be set by specifying a comma separated list of debugging options. These are:
    debug_time
        Print the time it takes to perform each step.
    debug_walk_dir
        Print each directory as it gets processed.
    debug_walk_dir_node
        Print each file as it gets processed.
    debug_walk_dir_linkcheck
        Print file information for files that have a link count > 1.
    debug_dump_fsnodes
        Dump information about the filesystem nodes.
    debug_dump_fsnodes_verbose
        Enable more detail if debug_dump_fsnodes is enabled.
    debug_fs_parse_opts
        Print debugging information about specific filesystem option parsing.
    debug_fs_makefs
        Print nodes as they are created and enable buffer consistency checks.
    debug_fs_validate
        Enable file-system specific validation (ffs only).
    debug_fs_create_image
        Print image file creation stats (ffs only).
    debug_fs_size_dir
        Print directory size information (ffs only).
    debug_fs_size_dir_node
        Print directory size information per node (ffs only).
    debug_fs_size_dir_add_dirent
        Print directory size information as entries are added (ffs only).
    debug_fs_populate
        Print information at each directory population pass (ffs only).
    debug_fs_populate_dirbuf
        Dump the directory buffer (ffs only).
    debug_fs_populate_node
        Print information about each file during directory population (ffs only).
    debug_fs_write_file
        Print buffer information when writing files (ffs only).
    debug_fs_write_file_block
        Print block information when writing files (ffs only).
    debug_fs_make_dirbuf
        Print directory buffer information (ffs only).
    debug_fs_write_inode
        Print inode information (ffs only).
    debug_buf_bread
        Print block buffer information (ffs only).
    debug_buf_bwrite
        Print block write information (ffs only).
    debug_buf_getblk
        Print block allocation information (ffs only).
    debug_apply_specfile
        Print information about each directory in the specfile.
    debug_apply_specentry
        Print information about each entry in the specfile.
    debug_apply_speconly
        Debug the -x special file exclusion.

-F mtree-specfile
    Use mtree-specfile as an mtree(8) ‘specfile’ specification.

    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.

    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 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: type, mode, gname, or gid, and uname or uid, device (in the case of block or character devices), and link (in the case of symbolic links). If time isn't provided, the current time will be used. If flags isn't provided, the current file flags will be used. Missing regular file entries will be created as zero-length files.

-f free-files
    Ensure that a minimum of free-files free files (inodes) exist in the image. An optional ‘%’ suffix may be provided to indicate that free-files indicates a percentage of the calculated image size.

-L  All symbolic links are followed.

-M minimum-size
    Set the minimum size of the file system image to minimum-size.

-m maximum-size
    Set the maximum size of the file system image to maximum-size. An error will be raised if the target file system needs to be larger than this to accommodate the provided directory tree.

-N userdb-dir
    Use the user database text file master.passwd and group database text file group from userdb-dir, rather than using the results from the system's getpwnam(3) and getgrnam(3) (and related) library calls.

-O offset
    Instead of creating the file system at the beginning of the file, start at offset. Valid only for ffs and msdos.

-o fs-options
    Set file system specific options. fs-options is a comma separated list of options. Valid file system specific options are detailed below.

-r  When merging multiple directories replace duplicate files with the last found.

-S sector-size
    Set the file system sector size to sector-size. Defaults to 512 for most file systems, but is 2048 for cd9660 and udf for CD/DVD/BD optical media types.

-s image-size
    Set the size of the file system image to image-size. This is equivalent of setting both the minimum (-M) and the maximum (-m) sizes to image-size. For ffs and msdos the offset is not included on that size.

-T timestamp
    Specify a timestamp to be set for all file system files and directories created so that repeatable builds are possible. The timestamp can be a pathname, where the timestamps are derived from that file, a parseable date for parsedate(3) (this option is not yet available in the tools build), or an integer value interpreted as the number of seconds from the Epoch. Note that timestamps specified in an mtree(5) spec file, override the default timestamp. When this option is enabled, file systems that regularly use localtime(3) to convert times to the native format (such as udf and cd9660), use gmtime(3) instead with the specified timestamps so that they are immune to timezone changes and get consistent timestamps.

-t fs-type
    Create an fs-type file system image. The following file system types are supported:

    cd9660
        ISO 9660 file system.

    chfs
        Chip flash file system.

    ffs BSD fast file system (default).

    msdos
        FAT12, FAT16, or FAT32 file system.

    udf ISO/Ecma UDF file system.

    v7fs
        7th Edition(V7) file system.

-x  Exclude file system nodes not explicitly listed in the specfile. Repeating this flag causes makefs to print a warning for each missing system nodes and exit with an error code if there are any missing.

-Z  Create a sparse file for ffs. This is useful for virtual machine images.

Where sizes are specified, a decimal number of bytes is expected. Two or more numbers may be separated by an ‘x’ to indicate a product. Each number may have one of the following optional suffixes:
b   Block; multiply by 512
k   Kibi; multiply by 1024 (1 KiB)
m   Mebi; multiply by 1048576 (1 MiB)
g   Gibi; multiply by 1073741824 (1 GiB)
t   Tebi; multiply by 1099511627776 (1 TiB)
w   Word; multiply by the number of bytes in an integer

  FFS-specific fs-options
ffs images have ffs-specific optional parameters that may be provided. Each of the options consists of a keyword, an equal sign (‘=’), and a value. The following keywords are supported:

avgfilesize=num, a=num
    Expected average file size. Range: 1..2147483647.
avgfpdir=num, n=num
    Expected number of files per directory. Range: 1..2147483647.
bsize=num, b=num
    Block size. Range: 1..2147483647.
density=num, d=num
    Bytes per inode. Range: 1..2147483647.
extattr=num, e=num
    UFS2 with extended attributes. One of: 0 to disable, or 1 to enable.
extent=num, x=num
    Maximum extent size. Range: 1..2147483647.
fsize=num, f=num
    Fragment size. Range: 1..2147483647.
label=str, l=str
    Label name of the image. Range: 1..32 characters.
maxbpcg=num, g=num
    Maximum total number of blocks in a cylinder group. Range: 1..2147483647.
maxbpg=num, M=num
    Maximum blocks per file in a cylinder group. Range: 1..2147483647.
minfree=num, m=num
    Minimum % free. Range: 0..99.
optimization=str, o=str
    Optimization preference; one of ‘space’ or ‘time’.
version=num, v=num
    File system format version, compatible with the -O option of newfs(8). One of: 0 for FFSv1 with the old level 1 format, 1 for FFSv1 (default, level 4), or 2 for FFSv2 (UFS2).

  CD9660-specific fs-options
cd9660 images have ISO9660-specific optional parameters that may be provided. The arguments consist of a keyword and, optionally, an equal sign (‘=’), and a value. The following keywords are supported:

allow-deep-trees, D
    Allow the directory structure to exceed the maximum specified in the spec.
allow-illegal-chars, i
    Allow illegal characters in filenames.
allow-lowercase
    Allow lowercase characters in filenames.
allow-max-name, a
    Allow 37 instead of 33 characters for filenames by omitting the version ID.
allow-multidot, m
    Allow multiple dots in a filename.
applicationid=str, A=str
    Application ID of the image.
archimedes
    Use the ‘ARCHIMEDES’ extension to encode RISC OS metadata.
boot-load-segment=str
    Set load segment for the boot image.
bootimage=str, B=str
    Filename of a boot image in the format “sysid;filename”, where “sysid” is one of ‘efi’, ‘i386’, ‘mac68k’, ‘macppc’, or ‘powerpc’.
bootimagedir=str
    Boot image directory.
chrp-boot, C
    Write an MBR partition table to the image to allow older CHRP hardware to boot.
follow-symlinks, S
    Resolve symlinks in pathnames.
generic-bootimage=str, G=str
    Load a generic boot image into the first 32K of the cd9660 image.
hard-disk-boot
    Boot image is a hard disk image.
help, h
    Show help message.
isolevel=num, l=num
    ISO9660 level. Range: 1..3.
keep-bad-images, K
    Don't throw away images whose write was aborted due to an error. For debugging purposes.
label=str, L=str
    Label name of the image.
no-boot
    Boot image is not bootable.
no-emul-boot
    Boot image is a “no emulation” ElTorito image.
no-trailing-padding
    Do not pad the image (apparently Linux needs the padding).
omit-trailing-period
    Omit trailing periods in filenames.
platformid=str
    Set platform ID of section header entry of the boot image.
preparer=str, p=str
    Preparer ID of the image.
publisher=str, P=str
    Publisher ID of the image.
rockridge, R
    Use RockRidge extensions (for longer filenames, etc.).
verbose=num, v=num
    Verbose level. Range: 0..2.
volumeid=str, V=str
    Volume set identifier of the image.

  CHFS-specific fs-options
chfs images have chfs-specific optional parameters that may be provided. Each of the options consists of a keyword, an equal sign (‘=’), and a value. The following keywords are supported:

erasesize=num, e=num
    Erase block size of the media. Range: 1..2147483647.
mediatype=num, m=num
    Type of the media. One of: 0 for NOR, or 1 for NAND.
pagesize=num, p=num
    Pagesize. Range: 1..2147483647.

  msdos-specific fs-options
msdos images have MS-DOS-specific optional parameters that may be provided. The arguments consist of a keyword, an equal sign (‘=’), and a value. The following keywords are supported (see newfs_msdos(8) for more details):

backup_sector=num, k=num
    Location of the backup boot sector. Range: 1..65535.
block_size=num, b=num
    Block size. Range: 1..4294967295.
bootstrap=str, B=str
    Bootstrap file.
bytes_per_sector=num, S=num
    Bytes per sector. Range: 1..65535.
create_size=num, C=num
    Create file size. Range: 0..18446744073709551615.
directory_entries=num, e=num
    Directory entries. Range: 1..65535.
drive_heads=num, h=num
    Drive heads. Range: 1..65535.
fat_type=num, F=num
    FAT type. One of: 12, 16, or 32.
floppy=str, f=str
    Preset drive parameters for standard format floppy disks. One of: 160, 180, 320, 360, 640, 720, 1200, 1232, 1440, or 2880.
hidden_sectors=num, o=num
    Hidden sectors. Range: 0..4294967295.
info_sector=num, i=num
    Location of the info sector. Range: 1..65535.
media_descriptor=num, m=num
    Media descriptor. Range: 0..255.
no_create, N
    Don't create file system, print params only.
num_FAT=num, n=num
    Number of FATs. Range: 1..255.
OEM_string=str, O=str
    OEM string.
offset=num, @=num
    Offset in device. Range: 0..18446744073709551615.
reserved_sectors=num, r=num
    Reserved sectors. Range: 1..65535.
sectors_per_cluster=num, c=num
    Sectors per cluster. Range: 1..255.
sectors_per_fat=num, a=num
    Sectors per FAT. Range: 1..4294967295.
sectors_per_track=num, u=num
    Sectors per track. Range: 1..65535.
size=num, s=num
    File System size. Range: 1..4294967295.
utf8
    Use UTF8 names.
volume_id=num, I=num
    Volume ID. Range: 1..4294967295.
volume_label=str, L=str
    Volume Label.

  V7FS-specific fs-options
The following keywords are supported:

pdp, p
    PDP endian.
progress, P
    Display a progress meter for the file system construction and file population.

  UDF-specific fs-options
makefs supports besides writing to image files also direct formatting of disc partitions and optical media. Optical media will auto configure settings. The following udf-specific optional parameters may be provided. Each of the options consists of a keyword, an equal sign (‘=’), and a value. The following keywords are supported:

checksurface, c
    Check the surface of non error-free rewritable media for remapping. Note this is a destructive test and can take quite a while!
discid=str, P=str
    Set the physical volume label of the disc to the specified argument. Prepend the physical volume label with a volumeset label separated with a ':' if wanted. For strict conformance and interchange, don't set the volumeset label manually unless it has an unique hex number in the first 8 character positions.
disctype=str, T=str
    This can have the following values:
    cdrom, dvdrom, bdrom
        create a read-only fs
    dvdram, bdre, disk
        create a rewritable fs without sparing for defective sectors
    cdr, dvdr, bdr
        create a rewritable fs on once recordable media using a VAT
    cdrw, dvdrw
        create a rewritable fs with sparing for defective sectors
    The sectorsize is set for the selected media and the default maximum disc size is assumed unless overridden. For CD-ROM, DVD-ROM and BD-ROM images, the disc size is the minimum size needed. Note that the size estimator can under-estimate in some cases; specify extra free blocks if encountering this.
forceformat, F
    Force formatting on non-empty recordable media.
loglabel=str, L=str
    Set the logical volume label of the disc to the specified argument.
maxver=str, V=str
    Set the maximum UDF version to be used. Choose UDF version numbers from 0x102, 0x150, 0x200, 0x201, and 0x250. Version 0x260 is currently not supported in makefs.
metaperc=num, p=num
    Set the minimum amount of free metadata space. This is only applicable on UDF 0x250 on rewritable media. Range: 1..99.
minver=str, v=str
    Set the minimum UDF version to be used. Choose UDF version numbers from 0x102, 0x150, 0x200, 0x201, and 0x250. Version 0x260 is currently not supported in makefs.
tz=num, t=num
    Timezone, in hours. Range: -24..24.

SEE ALSO
strsuftoll(3), installboot(8), mtree(8), newfs(8)

HISTORY
The makefs utility appeared in NetBSD 1.6.

AUTHORS
Luke Mewburn (original program), Daniel Watt, Walter Deignan, Ryan Gabrys, Alan Perez-Rathke, Ram Vedam (cd9660 support), UCHIYAMA Yasushi (v7fs support), Tamas Toth (chfs support), Christos Zoulas (msdos support), Reinoud Zandijk (udf support).