Manpage logo

e2fsimage - create and populate an ext2 filesystem image as non-root user

NAME  SYNOPSIS  DESCRIPTION  OPTIONS  DEVICES  USERS  BUGS  SEE ALSO  AUTHOR 

NAME

e2fsimage − create and populate an ext2 filesystem image as non-root user

SYNOPSIS

e2fsimage [-t fs-type] [-b block-size] [-L volume-label] [-f imgfile] [-d rootdir] [-u uid] [-g gid] [-D file] [-U file] [-P file] [-p] [-v] [-S] [-n] [-s size]

DESCRIPTION

e2fsimage creates an ext2 filesystem image by recursively copying the files from the existing directory structure rootdir to the image-file.

Supported filetypes are: regular files, directorys, hard-links, soft-links, block special devices, character special devices and fifos. Hard links are resolved to result in hard links in the image. The content (target) of softlinks is copied “ as-is ” and will not be resolved or altered in any way.

The usual way to create ext2 filesystem images for initial ramdisks, boot-floppys or bootable CDs is to create an image with eg.

At least the last 2 commands must be executed as root. In order to set the different ownerships (usually root) and to create the special device files root permissions are also needed.

Since all this results in a file that may belong to an ordinary user, this file can be created and filled with the filesystem structure by her. This application manages to create such an image as ordinary user without sudo or suid-root bit set. Of course suid-root programs in the filesystem image are possible by making them suid-user. When this files are copied, the user is set to root and there you have your suid-root program.
It is also not mandatory to have the rootdir on an ext2 filesystem.

OPTIONS

−t fs-type

Specify the filesystem type (i.e., ext2, ext3, ext4, etc.) that is to be created. See mke2fs(2).

−b block-size

Specify the size of blocks in bytes. Valid block-size values are 1024, 2048 and 4096 bytes per block. See mke2fs(2).

−L volume-label

Set the volume label for the filesystem to volume-label. The maximum length of the volume label is 16 bytes.

−d rootdir

The content of the filesystemimage is a recursive copy of rootdir. All files are copied while preserving all attributes but the uid/gid. They will usually be set to root.root. This can be overwritten with the -u and -g options respectively

−e pattern

Exclude files based upon pattern

−D devicefile

The devicefile contains all special devices to be created, see DEVICES.
The default filename is .DEVICES.

−U uidgidfile

The uidgidfile contains the uids and gids different from 0, see USERS.
The default filename is .UIDGID.

−P passwd

The password file in this parameter is used to convert user names to uids and gids. It tries to use the default in rootdir/etc/passwd, if it is omitted.

−G group

The group file in this parameter is used to convert group names to gids. It tries to use the default in rootdir/etc/group, if it is omitted.

−f imgfile

This is the target file for the filesystem image. An existing file will be overwritten as long as −n is not given.

−g gid

Change the default group id from 0 to gid. Until now there is only 1 gid for all files supported. If you need different gids for different files, take a look at USERS

−n

This option allows to reuse an existing filesystem image defined by −f The existing content is not modified by any means but there may not exist a file with the same name as a newly created one.

−p

Preserve original file owner. If this option is omitted all files in the image will belong to root. (This is usually what you want)

−s size

When the filesystem is created the size will be size Kbytes large. The default is 4096 kilo bytes.

−u uid

Change the default user-id from 0 to uid. Until now there is only 1 uid for all files supported. If you need different uids look at the section USERS

−v

Be more verbose.

−S

Skip unaccessible files and dirs.

DEVICES

Usually the devices are created using mknod by root. Obviously this would absurd the existence of e2fsimage to be a non-root tool. A device special file called .DEVICES can be placed in every directory (usually dev ) that will contain device special files. The format of this file is:

<name> <type> <major> <minor><mode> <uid> <gid> ]]]

name

the name of the file like ttyS0

type

Actually supported are c,u for character special devices, b for block special devices and p,f for fifos.

major minor.

This are the major and minor numbers of the device

mode

The access mode for the file like 0644. The default mode for devices is 0600 if mode is omitted.

uid

The uid of the device, 0 if omitted.

gid

The gid of the device, 0 if omitted.

A call to mknod like mknod -m 0600 ttyS1 c 4 65 would result in a line in dev/.DEVICES as "ttyS1 c 4 65 0600"

USERS

Every directory may contain a file named .UIDGID . This filename can be changed by using the -U option. The format of this file is:

<name> <uid><gid> ]

<name> <username><groupname> ]

If <name> is ".", then the owner and group information will be kept recursively for all files and directorys below. For a "chown 500 /home/user" one would write "user 500" to "home/.UIDGID and have such a directory "home/user" of course. For a "chown -R 500 /home/user" one would write a ". 500" to "home/user/.UIDGID". Userid information given in .UIDGID overrides user info in .DEVICES.

If the uid entry is not numeric it will be resolved by using passwd, provided by the option −P. In this case the gid is also taken from passwd , if the groupname is omitted. If the groupname is provided, the group file from -G is used to resolve the gid.

name

is the name of the file.

uid

is the numeric userid of the file.

gid

is the numeric groupid of the file. It will be zero if omitted.

username

is the user name of the file owner, resolved by passwd.

groupname

is the group name of the file, resolved by group.

BUGS

Bugs ?

SEE ALSO

mke2fs(8)

AUTHOR

This program was written by
Christian Hohnstaedt <[email protected]>
The project homepage is http://www.hohnstaedt.de/e2fsimage


Updated 2026-06-01 - jenkler.se | uex.se