The e2image command in Linux is used to create an image of an ext2, ext3, or ext4 file system. This image can be used for backup or recovery purposes. The command creates a file that contains a copy of the file system’s data, which can be restored to a disk or partition using the e2image command.
If you encounter the below error while running the command e2image:
e2image: command not found
you may try installing the below package as per your choice of distribution:
Distribution | Command |
---|---|
Debian | apt-get install e2fsprogs |
Ubuntu | apt-get install e2fsprogs |
Alpine | apk add e2fsprogs |
Arch Linux | pacman -S e2fsprogs |
Kali Linux | apt-get install e2fsprogs |
CentOS | yum install e2fsprogs |
Fedora | dnf install e2fsprogs |
OS X | brew install e2fsprogs |
Raspbian | apt-get install e2fsprogs |
e2image Command Examples
1. Write metadata located on device to a specific file:
# e2image /dev/sdXN path/to/image_file
2. Print metadata located on device to stdout:
# e2image /dev/sdXN -
3. Restore the filesystem metadata back to the device:
# e2image -I /dev/sdXN path/to/image_file
4. Create a large raw sparse file with metadata at proper offsets:
# e2image -r /dev/sdXN path/to/image_file
5. Create a QCOW2 image file instead of a normal or raw image file:
# e2image -Q /dev/sdXN path/to/image_file