Skip to content
modular initramfs creation tool
Shell C Perl
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



geninit - modular initramfs creation utility


Usage: geninit [ options ]


geninit is a tool for creating cpio archives to be used as an initial ramfs during system bootstrap. It features a modular design, making it easy to tailor the image to the system's hardware and software needs.


-b basedir

Specify a base directory other than /. This is reserved for usage during a chroot. geninit will attempt to use as much as possible from the guest system, drawing only from the host system when necessary.

-c config-file

Use an alterate config file. Defaults to /etc/geninit.conf.

-g imagename

Specify the absolute path of the generated initramfs image. If unspecified, a dry-run will be performed and no image will be created.

-H builder

Display the help message for a builder. A list of available builders can be generated with the -L option.


Display the help message and quit.

-k kernel

Specify an alternate kernel version to create an image for. The kernel can be specified as an exact version (such as 2.6.38-ARCH), or provided as a path to the kernel bzImage itself. By default, this is the currently loaded kernel.


List all available builders for use in the builders array in the config file.

-p preset

Specify a preset file to drive image creation. This is any file named with a .preset extension in /etc/geninit.d. An example preset file is packaged with geninit for explanatory purpose.

-S builders

A comma delimited list of builders to skip during image creation.


Save the temporary workspace after the build process. This is useful for debugging purposes.

-t path

Specify an alterate version to the temporary directory used as a workspace. This needs to be a writeable directory with a minimum of 20mb free.

-z compression

Override the compression method specified by the config file. geninit supports compression via gzip, bzip2, lzma, and xz. You can also use none to disable compression. Please note that your kernel must support your method and choice and your kernel will not be checked for this support! If in doubt, gzip is a safe choice.



Perform a dry run against the currently loaded kernel. Although a temporary workspace is created, no bootable image is generated from this operation.

geninit -k /boot/vmlinuz26 -g /boot/initramfs-ARCH

Create an image for the kernel located at /boot/vmlinuz26 called /boot/initramfs-ARCH, described by the default config file.

geninit -b /mnt -p kernel26

Build an image, or images, as described in /mnt/etc/geninit.d/kernel26.preset.


Builders are bash scripts that are parsed during build time in order to add functionality to the image. They are sourced from the appropriate config file, and parsed in array index order. Builders may draw in an additional hookscript for use at runtime.

At a minimum, builders must define a function called build, which contains instructions on what geninit should add to the image. See the BUILDER API section for documentation on the available methods for adding files. Additionally, a builder should also include a helpmsg function, which describes the features and/or functionality provided by the builder. This is called via geninit's -H option.


Hooks are executed during the bootstrap process in order to facilitate finding and/or mounting of the root device. They run under Busybox's almquist shell. Because hooks are run as a child process of init, they are unable to directly export variables affecting their parent. If you need to communicate back with init, you may write environment variable declarations on file descriptor pointed to by the FDINIT environment variable, which will be picked back up into the environment of init, e.g.

  echo 'root=/dev/foo' >&$FDINIT

Note that FDINIT is also available for any rescue shell that may be invoked during bootstrap.


geninit features a small API intended for use by builders. These are base directory aware functions with error checking and are the recommended method of adding files to the cpio image from builders. Leading path components, if not already created, will be added implicitly. If, for some reason, you need to override the base directory and specify a truly absolute path, you can prefix a source argument with a '@'.

add_binary source [path]

Add a binary file, specified by the absolute path to its source. Unless specified, the path on the image will be the same as the source. Files will be scanned for library dependencies which will also be added to the image.

add_dir path [mode]

Add a directory, specified by its absolute path on the image. Unless specified, the permissions of the directory will be 755.

add_driver_classes class...

Add one or more classifications of modules to the image, specified as a directory relative to /lib/modules/KERNELVERSION/kernel, e.g. 'drivers/scsi' or 'crypto'. Modules can be filtered by name by adding glob (including extended glob) patterns to the MODFILTER array prior to calling add_driver_classes. This filter is cleared after the parsing of each hook, although you are free to call unset from within the builder, if desired.

Additionally, if the autodetect builder is used as part of image generation, only the intersection of the autodetect module list and the results of the add_driver_classes call will be added to the resulting image.

add_file source [path]

Add a plain file, specified by the absolute path to its source. Unless specified, the path on the image will be the same as the source. No type checking of the file is done.

add_module module_name

Add a kernel module to the image, specified by its name (with or without extension). Modules will be scanned for dependencies and firmware which will also be added to the image.

add_path_to_file file

Add all leading path components to a file to the image.

add_pipe path [mode]

Add a FIFO device to the image, specified by its absolute path. Unless specified, the permissions of the FIFO will be 644.

add_symlink target link

Add a symlink to the image, located at the absolute path specified by link, and pointing to the path specified by target.

use_hookscript [script]

Indicate that a script should be added to be run during bootstrap. Unless specified, geninit will look for a script by the same name as the builder.



Default config file


Location of geninit preset files


Builder API file


Location of builders


Location of hookscripts


Dave Reisner <>

Something went wrong with that request. Please try again.