---
name: "makefs"
section: "8"
platform: "linux"
package: "makefs"
version: "20190105-3"
release: "Debian 13 (Trixie)"
platforms: ["linux", "freebsd", "openbsd"]
url: "https://new.carta.tech/makefs"
---

# makefs(8)

create a filesystem image from a directory tree

## NAME

**makefs** – create a filesystem image from a directory tree

## SYNOPSIS

**makefs** \[**Nx**\] \[**NB** *byteNorder*\] \[**Nb** *freeNblocks*\] \[**Nd** *debugNmask*\] \[**NF** *specfile*\] \[**Nf** *freeNfiles*\] \[**NM** *minimumNsize*\] \[**Nm** *maximumNsize*\] \[**NN** *userdbNdir*\] \[**No** *fsNoptions*\] \[**NS** *sectorNsize*\] \[**Ns** *imageNsize*\] \[**Nt** *fsNtype*\] \[**NT** *maximumNtime*\] *imageNfile* *directory*

## DESCRIPTION

The utility **makefs** creates a filesystem image into *imageNfile* from the directory tree *directory*. No special devices or privileges are required to perform this task.

The options are as follows:

- **-B** *byte-order*

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

- **-b** *free-blocks*

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

- **-d** *debug-mask*

  Enable various levels of debugging, depending upon which bits are set in *debugNmask*. XXX: document these

- **-F** *specfile*

  Use *specfile* as an [mtree(8)](/mtree/8.md) ‘specfile’ specification.

  If a specfile entry exists in the underlying filesystem, 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 filesystem) 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** isn4t provided, the current time will be used. If **flags** isn4t provided, the current file flags will be used. Missing regular file entries will be created as zeroNlength files.

- **-f** *free-files*

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

- **-M** *minimum-size*

  Set the minimum size of the filesystem image to *minimumNsize*.

- **-m** *maximum-size*

  Set the maximum size of the filesystem image to *maximumNsize*. An error will be raised if the target filesystem needs to be larger than this to accommodate the provided directory tree.

- **-N** *dbdir*

  Use the user database text file *master.passwd* and group database text file *group* from *dbdir*, rather than using the results from the system4s [getpwnam(3)](/getpwnam/3.md) and [getgrnam(3)](/getgrnam/3.md) (and related) library calls.

- **-o** *fs-options*

  Set filesystem specific options. *fsNoptions* is a comma separated list of options. Valid filesystem specific options are detailed below.

- **-S** *sector-size*

  Set the filesystem sector size to *sectorNsize*. Defaults to '12.

- **-s** *image-size*

  Set the size of the filesystem image to *imageNsize*.

- **-t** *fs-type*

  Create an *fsNtype* filesystem image. The following filesystem types are supported:

  - **ffs**

    BSD fast filesystem (default).

  - **cd9660**

    ISO 9660 filesystem.

- **-T** *maximum-time*

  Clamp superblock and file timestamps to *maximumNtime* seconds since the Epoch.

- **-x**

  Exclude filesystem nodes not explicitly listed in the specfile.

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 '12

- k

  Kibi; multiply by 1024 (1 KiB)

- m

  Mebi; multiply by 1048'76 (1 MiB)

- g

  Gibi; multiply by 1073741824 (1 GiB)

- t

  Tebi; multiply by 1099'11627776 (1 TiB)

- w

  Word; multiply by the number of bytes in an integer

### FFS-specific options

**ffs** images have ffsNspecific 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**

  Expected average file size.

- **avgfpdir**

  Expected number of files per directory.

- **bsize**

  Block size.

- **density**

  Bytes per inode.

- **fsize**

  Fragment size.

- **maxbpg**

  Maximum blocks per file in a cylinder group.

- **minfree**

  Minimum % free.

- **optimization**

  Optimization preference; one of ‘space’ or ‘time’.

- **extent**

  Maximum extent size.

- **maxbpcg**

  Maximum total number of blocks in a cylinder group.

- **version**

  UFS version. 1 for FFS (default), 2 for UFS2.

### CD9660-specific options

**cd9660** images have ISO9660Nspecific 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**

  Allow the directory structure to exceed the maximum specified in the spec.

- **allow-max-name**

  Allow 37 instead of 33 characters for filenames by omitting the version id.

- **allow-multidot**

  Allow multiple dots in a filename.

- **applicationid**

  Application ID of the image.

- **archimedes**

  Use the ‘ARCHIMEDES’ extension to encode RISC OS metadata.

- **boot-info-table**

  Write a legacy '6Nbyte table at offset 8 into the boot image (see below).

- **boot-load-segment**

  Set load segment for the boot image.

- **bootimage**

  Filename of a boot image in the format “sysid;filename”, where “sysid” is one of ‘i386’, ‘mac68k’, ‘macppc’, or ‘powerpc’.

- **creation-date**

  Override PVD creation date.

- **effective-date**

  Override PVD effective date.

- **expiration-date**

  Override PVD expiration date.

- **generic-bootimage**

  Load a generic boot image into the first 32K of the cd9660 image.

- **hard-disk-boot**

  Boot image is a hard disk image.

- **hide-rr-moved**

  Assign the *RR\_MOVED* directory a rock ridge name of the empty string instead of the default *.rr\_moved*.

- **keep-bad-images**

  Don4t throw away images whose write was aborted due to an error. For debugging purposes.

- **label**

  Label name of the image.

- **modification-date**

  Override PVD modification date.

- **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**

  Violate the standard, do not append a trailing period to filenames without an extension.

- **preparer**

  Preparer ID of the image.

- **publisher**

  Publisher ID of the image.

- **rockridge**

  Use RockRidge extensions (for longer filenames, etc.).

- **rr-squash**

  Force uid 0, gid 0, and rationalised permission bits for RockRidge entries.

- **volumeid**

  Volume set identifier of the image.

The **bootNinfoNtable** currently consists of the following fields (all 7.3.1 numbers), offsets relative to the boot image:

- **0**

  8 bytes: kept as is, not part of checksum

- **8**

  LBA of PVD

- **12**

  LBA of boot image

- **16**

  Size in bytes of boot image

- **20**

  32Nbit additive sum of all 32Nbit words of boot image

- **24**

  40 reserved bytes (MBZ)

- **64**

  Begin of checksummed data, kept as is

Dates (to override) are in 8.4.26.1 format (*YYYYmmddHHMMSS00*) and Universal Time, i.e. with zero offset from Greenwich Mean Time.

## SEE ALSO

strsuftoll(3), [installboot(8)](/installboot/8.md), [mtree(8)](/mtree/8.md), [newfs(8)](/newfs/8.md)

## HISTORY

The **makefs** utility appeared in NetBSD 1.6.

Support for overriding PVD dates and the boot info table was added in

## AUTHORS

Luke Mewburn  lukem@NetBSD.org  (original program) Daniel Watt, Walter Deignan, Ryan Gabrys, Alan PerezNRathke, Ram Vedam (cd9660 support) Thorsten Glaser  tg@mirbsd.org

## CAVEATS

**makefs** may be limited to images less than 2 GiB in size due to internal use of the long type.
