1E2IMAGE(8) System Manager's Manual E2IMAGE(8)
2
3
4
6 e2image - Save critical ext2/ext3/ext4 filesystem metadata to a file
7
9 e2image [ -r|Q ] [ -f ] device image-file
10 e2image -I device image-file
11 e2image -ra [ -cfnp ] [ -o src_offset ] [ -O dest_offset ] src_fs [
12 dest_fs ]
13
15 The e2image program will save critical ext2, ext3, or ext4 filesystem
16 metadata located on device to a file specified by image-file. The
17 image file may be examined by dumpe2fs and debugfs, by using the -i
18 option to those programs. This can assist an expert in recovering cat‐
19 astrophically corrupted filesystems. In the future, e2fsck will be
20 enhanced to be able to use the image file to help recover a badly dam‐
21 aged filesystem.
22
23 When saving an e2image for debugging purposes, using either the -r or
24 -Q options, the filesystem must be unmounted or be mounted read/only,
25 in order for the image file to be in a consistent state. This require‐
26 ment can be overridden using the -f option, but the resulting image
27 file is very likely not going to be useful.
28
29 If image-file is -, then the output of e2image will be sent to standard
30 output, so that the output can be piped to another program, such as
31 gzip(1). (Note that this is currently only supported when creating a
32 raw image file using the -r option, since the process of creating a
33 normal image file, or QCOW2 image currently requires random access to
34 the file, which cannot be done using a pipe. This restriction will
35 hopefully be lifted in a future version of e2image.)
36
37 It is a very good idea to create image files for all of filesystems on
38 a system and save the partition layout (which can be generated using
39 the fdisk -l command) at regular intervals --- at boot time, and/or
40 every week or so. The image file should be stored on some filesystem
41 other than the filesystem whose data it contains, to ensure that this
42 data is accessible in the case where the filesystem has been badly dam‐
43 aged.
44
45 To save disk space, e2image creates the image file as a sparse file, or
46 in QCOW2 format. Hence, if the sparse image file needs to be copied to
47 another location, it should either be compressed first or copied using
48 the --sparse=always option to the GNU version of cp. This does not
49 apply to the QCOW2 image, which is not sparse.
50
51 The size of an ext2 image file depends primarily on the size of the
52 filesystems and how many inodes are in use. For a typical 10 gigabyte
53 filesystem, with 200,000 inodes in use out of 1.2 million inodes, the
54 image file will be approximately 35 megabytes; a 4 gigabyte filesystem
55 with 15,000 inodes in use out of 550,000 inodes will result in a 3
56 megabyte image file. Image files tend to be quite compressible; an
57 image file taking up 32 megabytes of space on disk will generally com‐
58 press down to 3 or 4 megabytes.
59
61 The -I option will cause e2image to install the metadata stored in the
62 image file back to the device. It can be used to restore the filesys‐
63 tem metadata back to the device in emergency situations.
64
65 WARNING!!!! The -I option should only be used as a desperation measure
66 when other alternatives have failed. If the filesystem has changed
67 since the image file was created, data will be lost. In general, you
68 should make a full image backup of the filesystem first, in case you
69 wish to try other recovery strategies afterwards.
70
72 The -r option will create a raw image file instead of a normal image
73 file. A raw image file differs from a normal image file in two ways.
74 First, the filesystem metadata is placed in the proper position so that
75 e2fsck, dumpe2fs, debugfs, etc. can be run directly on the raw image
76 file. In order to minimize the amount of disk space consumed by a raw
77 image file, the file is created as a sparse file. (Beware of copying
78 or compressing/decompressing this file with utilities that don't under‐
79 stand how to create sparse files; the file will become as large as the
80 filesystem itself!) Secondly, the raw image file also includes indi‐
81 rect blocks and directory blocks, which the standard image file does
82 not have, although this may change in the future.
83
84 Raw image files are sometimes used when sending filesystems to the
85 maintainer as part of bug reports to e2fsprogs. When used in this
86 capacity, the recommended command is as follows (replace hda1 with the
87 appropriate device):
88
89 e2image -r /dev/hda1 - | bzip2 > hda1.e2i.bz2
90
91 This will only send the metadata information, without any data blocks.
92 However, the filenames in the directory blocks can still reveal infor‐
93 mation about the contents of the filesystem that the bug reporter may
94 wish to keep confidential. To address this concern, the -s option can
95 be specified. This will cause e2image to scramble directory entries
96 and zero out any unused portions of the directory blocks before writing
97 the image file. However, the -s option will prevent analysis of prob‐
98 lems related to hash-tree indexed directories.
99
100 Note that this will work even if you substitute "/dev/hda1" for another
101 raw disk image, or QCOW2 image previously created by e2image.
102
104 The -Q option will create a QCOW2 image file instead of a normal, or
105 raw image file. A QCOW2 image contains all the information the raw
106 image does, however unlike the raw image it is not sparse. The QCOW2
107 image minimize the amount of disk space by storing data in special for‐
108 mat with pack data closely together, hence avoiding holes while still
109 minimizing size.
110
111 In order to send filesystem to the maintainer as a part of bug report
112 to e2fsprogs, use following commands (replace hda1 with the appropriate
113 device):
114
115 e2image -Q /dev/hda1 hda1.qcow2
116 bzip2 -z hda1.qcow2
117
118 This will only send the metadata information, without any data blocks.
119 However, the filenames in the directory blocks can still reveal infor‐
120 mation about the contents of the filesystem that the bug reporter may
121 wish to keep confidential. To address this concern, the -s option can
122 be specified. This will cause e2image to scramble directory entries
123 and zero out any unused portions of the directory blocks before writing
124 the image file. However, the -s option will prevent analysis of prob‐
125 lems related to hash-tree indexed directories.
126
127 Note that QCOW2 image created by e2image is regular QCOW2 image and can
128 be processed by tools aware of QCOW2 format such as for example qemu-
129 img.
130
131 You can convert a qcow2 image into a raw image with:
132
133 e2image -r hda1.qcow2 hda1.raw
134
135 This can be useful to write a qcow2 image containing all data to a
136 sparse image file where it can be loop mounted, or to a disk partition.
137 Note that this may not work with qcow2 images not generated by e2image.
138
140 Normally e2image only includes fs metadata, not regular file data. The
141 -a option can be specified to include all data. This will give an
142 image that is suitable to use to clone the entire FS or for backup pur‐
143 poses. Note that this option only works with the raw or QCOW2 formats.
144 The -p switch may be given to show progress. If the file system is
145 being cloned to a flash-based storage device (where reads are very fast
146 and where it is desirable to avoid unnecessary writes to reduce write
147 wear on the device), the -c option which cause e2image to try reading a
148 block from the destination to see if it is identical to the block which
149 e2image is about to copy. If the block is already the same, the write
150 can be skipped. The -n option will cause all of the writes to be no-
151 ops, and print the blocks that would have been written.
152
154 Normally a filesystem starts at the beginning of a partition, and
155 e2image is run on the partition. When working with image files, you
156 don't have the option of using the partition device, so you can specify
157 the offset where the filesystem starts directly with the -o option.
158 Similarly the -O option specifies the offset that should be seeked to
159 in the destination before writing the filesystem.
160
161 For example, if you have a dd image of a whole hard drive that contains
162 an ext2 fs in a partition starting at 1 MiB, you can clone that fs
163 with:
164
165 e2image -aro 1048576 img /dev/sda1
166
167 Or you can clone a fs into an image file, leaving room in the first MiB
168 for a partition table with:
169
170 e2image -arO 1048576 /dev/sda1 img
171
172 If you specify at least one offset, and only one file, an in-place move
173 will be performed, allowing you to safely move the filesystem from one
174 offset to another.
175
177 e2image was written by Theodore Ts'o (tytso@mit.edu).
178
180 e2image is part of the e2fsprogs package and is available from
181 http://e2fsprogs.sourceforge.net.
182
184 dumpe2fs(8), debugfs(8)
185
186
187
188
189E2fsprogs version 1.44.3 2018 E2IMAGE(8)