e2image - Linux


e2image is a command used to create ext2/3/4 filesystem images from a provided directory or device, enabling easy backup, distribution, and deployment of filesystems.


e2image [options] <device|directory> <image_file>


  • -C, –checksum: Calculate the checksum of the filesystem after creation.
  • -d, –dry-run: Display the filesystem image that would be created without actually writing it to a file.
  • -a, –all: Preserve all file extended attributes during image creation.
  • -s, –swap: Create a swapfile image instead of a filesystem image.
  • -b, –bits: Specify the number of bits for block size, valid values are 1024, 2048, and 4096. Default: 1024.
  • -i, –inode-size: Specify the size of the inode structure in bytes, valid values are 128, 256, and 512. Default: 128.
  • -l, –label: Label the created filesystem with the specified name.
  • -F, –force: Force the creation of the image file even if it already exists.
  • -h, –help: Display usage information.


Create a filesystem image from a directory:

e2image -a -b 2048 /home/user /home/user-image.img

Create a swapfile image of 4GB:

e2image -s -F /dev/sda1 /swapfile.img

Create an ext4 filesystem image with a custom label:

e2image -C -F -i 256 /dev/sdc1 /my-ext4-image.img

Common Issues

  • Incorrect block size: Ensure the specified block size is valid and supported by the target filesystem.
  • Insufficient privileges: Ensure you have root privileges or sufficient permissions to access the input device or directory.
  • Corrupted input: If the input filesystem or device is corrupted, the image creation may fail.


  • mkinitcpio: Integrate the created image into an initramfs using mkinitcpio -g /path/to/image.img.
  • Cloud deployments: Use e2image to create filesystem images for cloud platforms such as AWS or Azure.
  • Bootloader configuration: Configure bootloaders like GRUB or LILO to boot from the created image using root=/dev/disk/by-label/<label>.

Related Commands

  • mke2fs: Create a new ext2/3/4 filesystem on a specified device.
  • dd: Write the image file to a new device for deployment.
  • mount: Mount the created filesystem image for access.