Copyright 2001 by Theodore Ts'o. All Rights Reserved.
This file may be copied under the terms of the GNU Public License.
e2image -I device image-file
e2image -ra [ -cfnp ] [ -o src_offset ] [ -O dest_offset ] src_fs [ dest_fs ]
When saving an e2image for debugging purposes, using either the -r or -Q options, the filesystem must be unmounted or be mounted read/only, in order for the image file to be in a consistent state. This requirement can be overriden using the -f option, but the resulting image file is very likely not going to be useful.
If image-file is -, then the output of e2image will be sent to standard output, so that the output can be piped to another program, such as gzip (1). (Note that this is currently only supported when creating a raw image file using the -r option, since the process of creating a normal image file, or QCOW2 image currently requires random access to the file, which cannot be done using a pipe. This restriction will hopefully be lifted in a future version of e2image .)
It is a very good idea to create image files for all of filesystems on a system and save the partition layout (which can be generated using the fdisk -l command) at regular intervals --- at boot time, and/or every week or so. The image file should be stored on some filesystem other than the filesystem whose data it contains, to ensure that this data is accessible in the case where the filesystem has been badly damaged.
To save disk space, e2image creates the image file as a sparse file, or in QCOW2 format. Hence, if the sparse image file needs to be copied to another location, it should either be compressed first or copied using the --sparse=always option to the GNU version of cp . This does not apply to the QCOW2 image, which is not sparse.
The size of an ext2 image file depends primarily on the size of the filesystems and how many inodes are in use. For a typical 10 gigabyte filesystem, with 200,000 inodes in use out of 1.2 million inodes, the image file will be approximately 35 megabytes; a 4 gigabyte filesystem with 15,000 inodes in use out of 550,000 inodes will result in a 3 megabyte image file. Image files tend to be quite compressible; an image file taking up 32 megabytes of space on disk will generally compress down to 3 or 4 megabytes.
The -I option will cause e2image to install the metadata stored in the image file back to the device. It can be used to restore the filesystem metadata back to the device in emergency situations.
WARNING!!!! The -I option should only be used as a desperation measure when other alternatives have failed. If the filesystem has changed since the image file was created, data will be lost. In general, you should make a full image backup of the filesystem first, in case you wish to try other recovery strategies afterwards.
Raw image files are sometimes used when sending filesystems to the maintainer as part of bug reports to e2fsprogs. When used in this capacity, the recommended command is as follows (replace hda1 with the appropriate device):
e2image -r /dev/hda1 - | bzip2 > hda1.e2i.bz2
This will only send the metadata information, without any data blocks. However, the filenames in the directory blocks can still reveal information about the contents of the filesystem that the bug reporter may wish to keep confidential. To address this concern, the -s option can be specified. This will cause e2image to scramble directory entries and zero out any unused portions of the directory blocks before writing the image file. However, the -s option will prevent analysis of problems related to hash-tree indexed directories.
Note that this will work even if you substitute "/dev/hda1" for another raw disk image, or QCOW2 image previously created by e2image .
In order to send filesystem to the maintainer as a part of bug report to e2fsprogs, use following commands (replace hda1 with the appropriate device):
\ e2image -Q /dev/hda1 hda1.qcow2
\ bzip2 -z hda1.qcow2
This will only send the metadata information, without any data blocks. However, the filenames in the directory blocks can still reveal information about the contents of the filesystem that the bug reporter may wish to keep confidential. To address this concern, the -s option can be specified. This will cause e2image to scramble directory entries and zero out any unused portions of the directory blocks before writing the image file. However, the -s option will prevent analysis of problems related to hash-tree indexed directories.
Note that QCOW2 image created by e2image is regular QCOW2 image and can be processed by tools aware of QCOW2 format such as for example qemu-img .
You can convert a qcow2 image into a raw image with:
\ e2image -r hda1.qcow2 hda1.raw
This can be useful to write a qcow2 image containing all data to a sparse image file where it can be loop mounted, or to a disk partition. Note that this may not work with qcow2 images not generated by e2image.
For example, if you have a dd image of a whole hard drive that contains an ext2 fs in a partition starting at 1 MiB, you can clone that fs with:
\ e2image -aro 1048576 img /dev/sda1
Or you can clone a fs into an image file, leaving room in the first MiB for a partition table with:
\ e2image -arO 1048576 /dev/sda1 img
If you specify at least one offset, and only one file, an in-place move will be performed, allowing you to safely move the filesystem from one offset to another.