Whamcloud - gitweb
Merge branch 'maint' into next
[tools/e2fsprogs.git] / misc / e2image.8.in
1 .\" -*- nroff -*-
2 .\" Copyright 2001 by Theodore Ts'o.  All Rights Reserved.
3 .\" This file may be copied under the terms of the GNU Public License.
4 .\" 
5 .TH E2IMAGE 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
6 .SH NAME
7 e2image \- Save critical ext2/ext3/ext4 filesystem metadata to a file
8 .SH SYNOPSIS
9 .B e2image
10 [
11 .B \-rsIQa
12 ]
13 .I device
14 .I image-file
15 .SH DESCRIPTION
16 The
17 .B e2image
18 program will save critical ext2, ext3, or ext4 filesystem metadata located on
19 .I device
20 to a file specified by
21 .IR image-file .
22 The image file may be examined by
23 .B dumpe2fs
24 and
25 .BR  debugfs ,
26 by using the
27 .B \-i
28 option to those programs.  This can assist an expert in
29 recovering catastrophically corrupted filesystems.  In the future,
30 e2fsck will be enhanced to be able to use the image file to help
31 recover a badly damaged filesystem.
32 .PP
33 When saving an e2image for debugging purposes, using either the
34 .B \-r
35 or
36 .B \-Q
37 options, the filesystem must be unmounted or be mounted read/only, in order
38 for the image file to be in a consistent state.  This requirement can be
39 overriden using the
40 .B -f
41 option, but the resulting image file is very likely not going to be useful.
42 .PP
43 If
44 .I image-file
45 is \-, then the output of
46 .B e2image
47 will be sent to standard output, so that the output can be piped to
48 another program, such as
49 .BR gzip (1).
50 (Note that this is currently only supported when
51 creating a raw image file using the
52 .B \-r
53 option, since the process of creating a normal image file, or QCOW2
54 image currently
55 requires random access to the file, which cannot be done using a
56 pipe.  This restriction will hopefully be lifted in a future version of
57 .BR e2image .)
58 .PP
59 It is a very good idea to create image files for all of
60 filesystems on a system and save the partition
61 layout (which can be generated using the
62 .B fdisk \-l
63 command) at regular intervals --- at boot time, and/or every week or so.
64 The image file should be stored on some filesystem other than
65 the filesystem whose data it contains, to ensure that this data is
66 accessible in the case where the filesystem has been badly damaged.
67 .PP
68 To save disk space,
69 .B e2image
70 creates the image file as a sparse file, or in QCOW2 format.
71 Hence, if the sparse image file
72 needs to be copied to another location, it should
73 either be compressed first or copied using the
74 .B \-\-sparse=always
75 option to the GNU version of
76 .BR cp .
77 This does not apply to the QCOW2 image, which is not sparse.
78 .PP
79 The size of an ext2 image file depends primarily on the size of the
80 filesystems and how many inodes are in use.  For a typical 10 gigabyte
81 filesystem, with 200,000 inodes in use out of 1.2 million inodes, the
82 image file will be approximately 35 megabytes; a 4 gigabyte filesystem with
83 15,000 inodes in use out of 550,000 inodes will result in a 3 megabyte
84 image file.  Image files tend to be quite
85 compressible; an image file taking up 32 megabytes of space on
86 disk will generally compress down to 3 or 4 megabytes.
87 .PP
88 .SH RESTORING FILESYSTEM METADATA USING AN IMAGE FILE
89 .PP
90 The
91 .B \-I
92 option will cause e2image to install the metadata stored in the image
93 file back to the device.  It can be used to restore the filesystem metadata
94 back to the device in emergency situations.
95 .PP
96 .B WARNING!!!!
97 The
98 .B \-I
99 option should only be used as a desperation measure when other
100 alternatives have failed.  If the filesystem has changed since the image
101 file was created, data
102 .B will
103 be lost.  In general, you should make a full image
104 backup of the filesystem first, in case you wish to try other recovery
105 strategies afterwards.
106 .PP
107 .SH RAW IMAGE FILES
108 The
109 .B \-r
110 option will create a raw image file instead of a normal image file.
111 A raw image file differs
112 from a normal image file in two ways.  First, the filesystem metadata is
113 placed in the proper position so that e2fsck, dumpe2fs, debugfs,
114 etc.\& can be run directly on the raw image file.  In order to minimize
115 the amount of disk space consumed by a raw image file, the file is
116 created as a sparse file.  (Beware of copying or
117 compressing/decompressing this file with utilities that don't understand
118 how to create sparse files; the file will become as large as the
119 filesystem itself!)  Secondly, the raw image file also includes indirect
120 blocks and directory blocks, which the standard image file does not have,
121 although this may change in the future.
122 .PP
123 Raw image files are sometimes used when sending filesystems to the maintainer
124 as part of bug reports to e2fsprogs.  When used in this capacity, the
125 recommended command is as follows (replace hda1 with the appropriate device):
126 .PP
127 .br
128         \fBe2image \-r /dev/hda1 \- | bzip2 > hda1.e2i.bz2\fR
129 .PP
130 This will only send the metadata information, without any data blocks.
131 However, the filenames in the directory blocks can still reveal
132 information about the contents of the filesystem that the bug reporter
133 may wish to keep confidential.  To address this concern, the
134 .B \-s
135 option can be specified.  This will cause
136 .B e2image
137 to scramble directory entries and zero out any unused portions
138 of the directory blocks before writing the image file.  However,
139 the
140 .B \-s
141 option will prevent analysis of problems related to hash-tree indexed
142 directories.
143 .PP
144 Note that this will work even if you substitute "/dev/hda1" for another raw
145 disk image, or QCOW2 image previously created by
146 .BR e2image .
147 .PP
148 .SH QCOW2 IMAGE FILES
149 The
150 .B \-Q
151 option will create a QCOW2 image file instead of a normal, or raw image file.
152 A QCOW2 image contains all the information the raw image does, however unlike
153 the raw image it is not sparse. The QCOW2 image minimize the amount of disk
154 space by storing data in special format with pack data closely together, hence
155 avoiding holes while still minimizing size.
156 .PP
157 In order to send filesystem to the maintainer as a part of bug report to
158 e2fsprogs, use following commands (replace hda1 with the appropriate device):
159 .PP
160 .br
161 \       \fBe2image \-Q /dev/hda1 hda1.qcow2\fR
162 .br
163 \       \fBbzip2 -z hda1.qcow2\fR
164 .PP
165 This will only send the metadata information, without any data blocks.
166 However, the filenames in the directory blocks can still reveal
167 information about the contents of the filesystem that the bug reporter
168 may wish to keep confidential.  To address this concern, the
169 .B \-s
170 option can be specified.  This will cause
171 .B e2image
172 to scramble directory entries and zero out any unused portions
173 of the directory blocks before writing the image file.  However, the
174 .B \-s
175 option will prevent analysis of problems related to hash-tree indexed
176 directories.
177 .PP
178 Note that QCOW2 image created by
179 .B e2image
180 is regular QCOW2 image and can be processed by tools aware of QCOW2 format
181 such as for example
182 .BR qemu-img .
183 .PP
184 You can convert a qcow2 image into a raw image with:
185 .PP
186 .br
187 \       \fBe2image \-r hda1.qcow2 hda1.raw\fR
188 .br
189 .PP
190 This can be useful to write a qcow2 image containing all data to a
191 sparse image file where it can be loop mounted, or to a disk partition.
192 Note that this may not work with qcow2 images not generated by e2image.
193 .PP
194 .SH INCLUDING DATA
195 Normally
196 .B e2image
197 only includes fs metadata, not regular file data.  The
198 .B \-a
199 option can be specified to include all data.  This will
200 give an image that is suitable to use to clone the entire FS or
201 for backup purposes.  Note that this option only works with the
202 raw or QCOW2 formats.
203 .PP
204 .SH AUTHOR
205 .B e2image
206 was written by Theodore Ts'o (tytso@mit.edu).
207 .SH AVAILABILITY
208 .B e2image
209 is part of the e2fsprogs package and is available from
210 http://e2fsprogs.sourceforge.net.
211 .SH SEE ALSO
212 .BR dumpe2fs (8),
213 .BR debugfs (8)
214