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