Manual browser: makefs(8)

MAKEFS(8) System Manager's Manual MAKEFS(8)


makefscreate a file system image from a directory tree


makefs [-rxZ] [-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 fs-type] image-file directory [extra-directory ...]


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
Enable various levels of debugging, depending upon which bits are set in debug-mask. XXX: document these
-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.
-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 filesystem 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.
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.
-s image-size
Set the size of the file system image to image-size.
-t fs-type
Create an fs-type file system image. The following file system types are supported:
BSD fast file system (default).
ISO 9660 file system.
Chip flash file system.
FAT12, FAT16, or FAT32 file system.
7th Edition(V7) file system.
ISO/Ecma UDF file system.
Exclude file system nodes not explicitly listed in the specfile.
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:

Block; multiply by 512
Kibi; multiply by 1024 (1 KiB)
Mebi; multiply by 1048576 (1 MiB)
Gibi; multiply by 1073741824 (1 GiB)
Tebi; multiply by 1099511627776 (1 TiB)
Word; multiply by the number of bytes in an integer

FFS-specific 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:

Expected average file size.
Expected number of files per directory.
Block size.
Bytes per inode.
Fragment size.
Label name of the image.
Maximum blocks per file in a cylinder group.
Minimum % free.
Optimization preference; one of ‘space’ or ‘time’.
Maximum extent size.
Maximum total number of blocks in a cylinder group.
UFS version. 1 for FFS (default), 2 for UFS2.

CD9660-specific 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 the directory structure to exceed the maximum specified in the spec.
Allow 37 instead of 33 characters for filenames by omitting the version id.
Allow multiple dots in a filename.
Application ID of the image.
Use the ‘ARCHIMEDES’ extension to encode RISC OS metadata.
Write an MBR partition table to the image to allow older CHRP hardware to boot.
Set load segment for the boot image.
Filename of a boot image in the format “sysid;filename”, where “sysid” is one of ‘i386’, ‘mac68k’, ‘macppc’, or ‘powerpc’.
Load a generic boot image into the first 32K of the cd9660 image.
Boot image is a hard disk image.
Don't throw away images whose write was aborted due to an error. For debugging purposes.
Label name of the image.
Boot image is not bootable.
Boot image is a “no emulation” ElTorito image.
Do not pad the image (apparently Linux needs the padding).
Preparer ID of the image.
Publisher ID of the image.
Use RockRidge extensions (for longer filenames, etc.).
Volume set identifier of the image.

CHFS-specific 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:

Erase block size of the media.
Type of the media. NOR: 0 or NAND: 1.

msdos-specific options

See newfs_msdos(8) for fs specific options.

V7FS-specific options

The following keywords are supported:

PDP endian.
Display a progress meter for the file system construction and file population.

UDF-specific options

udf images have udf-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:

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
When an optical media is selected here, the sectorsize and the default disc size is assumed unless given explicitly. For rom images the disc size is the minimum needed.
Set the logical volume label of the disc to the specified argument.
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.
Set the minimum UDF version to be used. Choose UDF version numbers from 0x102, 0x150, 0x200, and 0x201. Versions 0x250 and 0x260 are currently not supported in makefs.


The makefs utility appeared in NetBSD 1.6.


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).
August 6, 2013 NetBSD 7.0