Whamcloud - gitweb
e2fsck: no parent lookup in disconnected dir
[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 file system metadata to a file
8
9 .SH SYNOPSIS
10 .B e2image
11 .RB [ \-r | \-Q " [" \-af ]]
12 [
13 .B \-b
14 .I superblock
15 ]
16 [
17 .B \-B
18 .I blocksize
19 ]
20 [
21 .B \-cnps
22 ]
23 [
24 .B \-o
25 .I src_offset
26 ]
27 [
28 .B \-O
29 .I dest_offset
30 ]
31 .I device
32 .I image-file
33 .br
34 .B e2image
35 .B \-I
36 .I device
37 .I image-file
38
39 .SH DESCRIPTION
40 The
41 .B e2image
42 program will save critical ext2, ext3, or ext4 file system metadata located on
43 .I device
44 to a file specified by
45 .IR image-file .
46 The image file may be examined by
47 .B dumpe2fs
48 and
49 .BR  debugfs ,
50 by using the
51 .B \-i
52 option to those programs.  This can assist an expert in recovering
53 catastrophically corrupted file systems.
54 .PP
55 It is a very good idea to create image files for all file systems on a
56 system and save the partition layout (which can be generated using the
57 .B fdisk \-l
58 command) at regular intervals --- at boot time, and/or every week or so.
59 The image file should be stored on some file system other than
60 the file system whose data it contains, to ensure that this data is
61 accessible in the case where the file system has been badly damaged.
62 .PP
63 To save disk space,
64 .B e2image
65 creates the image file as a sparse file, or in QCOW2 format.  Hence, if
66 the sparse image file needs to be copied to another location, it should
67 either be compressed first or copied using the
68 .B \-\-sparse=always
69 option to the GNU version of
70 .BR cp (1).
71 This does not apply to the QCOW2 image, which is not sparse.
72 .PP
73 The size of an ext2 image file depends primarily on the size of the
74 file systems and how many inodes are in use.  For a typical 10 Gigabyte
75 file system, with 200,000 inodes in use out of 1.2 million inodes, the image
76 file will be approximately 35 Megabytes; a 4 Gigabyte file system with 15,000
77 inodes in use out of 550,000 inodes will result in a 3 Megabyte image file.
78 Image files tend to be quite compressible; an image file taking up 32 Megabytes
79 of space on disk will generally compress down to 3 or 4 Megabytes.
80 .PP
81 If
82 .I image-file
83 is
84 .BR \- ,
85 then the output of
86 .B e2image
87 will be sent to standard output, so that the output can be piped to
88 another program, such as
89 .BR gzip (1).
90 (Note that this is currently only supported when
91 creating a raw image file using the
92 .B \-r
93 option, since the process of creating a normal image file, or QCOW2
94 image currently
95 requires random access to the file, which cannot be done using a
96 pipe.
97
98 .SH OPTIONS
99 .TP
100 .B \-a
101 Include file data in the image file.  Normally
102 .B e2image
103 only includes fs metadata, not regular file data.  This option will
104 produce an image that is suitable to use to clone the entire FS or
105 for backup purposes.  Note that this option only works with the
106 raw
107 .RI ( \-r )
108 or QCOW2
109 .RI ( \-Q )
110 formats.  In conjunction with the
111 .B \-r
112 option it is possible to clone all and only the used blocks of one
113 file system to another device/image file.
114 .TP
115 .BI \-b " superblock"
116 Get image from partition with broken primary superblock by using
117 the superblock located at file system block number
118 .IR superblock .
119 The partition is copied as-is including broken primary superblock.
120 .TP
121 .BI \-B " blocksize"
122 Set the file system blocksize in bytes.  Normally,
123 .B e2image
124 will search for the superblock at various different block sizes in an
125 attempt to find the appropriate blocksize. This search can be fooled in
126 some cases.  This option forces e2fsck to only try locating the superblock
127 with a particular blocksize. If the superblock is not found, e2image will
128 terminate with a fatal error.
129 .TP
130 .BI \-c
131 Compare each block to be copied from the source
132 .I device
133 to the corresponding block in the target
134 .IR image-file .
135 If both are already the same, the write will be skipped.  This is
136 useful if the file system is being cloned to a flash-based storage device
137 (where reads are very fast and where it is desirable to avoid unnecessary
138 writes to reduce write wear on the device).
139 .TP
140 .B \-f
141 Override the read-only requirement for the source file system when saving
142 the image file using the
143 .B \-r
144 and
145 .B \-Q
146 options.  Normally, if the source file system is in use, the resulting image
147 file is very likely not going to be useful. In some cases where the source
148 file system is in constant use this may be better than no image at all.
149 .TP
150 .B \-I
151 install the metadata stored in the image file back to the device.
152 It can be used to restore the file system metadata back to the device
153 in emergency situations.
154 .PP
155 .B WARNING!!!!
156 The
157 .B \-I
158 option should only be used as a desperation measure when other
159 alternatives have failed.  If the file system has changed since the image
160 file was created, data
161 .B will
162 be lost.  In general, you should make another full image backup of the
163 file system first, in case you wish to try other recovery strategies afterward.
164 .TP
165 .B \-n
166 Cause all image writes to be skipped, and instead only print the block
167 numbers that would have been written.
168 .TP
169 .BI \-o " src_offset"
170 Specify offset of the image to be read from the start of the source
171 .I device
172 in bytes.  See
173 .B OFFSETS
174 for more details.
175 .TP
176 .BI \-O " tgt_offset"
177 Specify offset of the image to be written from the start of the target
178 .I image-file
179 in bytes.  See
180 .B OFFSETS
181 for more details.
182 .TP
183 .B \-p
184 Show progress of image-file creation.
185 .TP
186 .B \-Q
187 Create a QCOW2-format image file instead of a normal image file, suitable
188 for use by virtual machine images, and other tools that can use the
189 .B .qcow
190 image format. See
191 .B QCOW2 IMAGE FILES
192 below for details.
193 .TP
194 .B \-r
195 Create a raw image file instead of a normal image file.  See
196 .B RAW IMAGE FILES
197 below for details.
198 .TP
199 .B \-s
200 Scramble directory entries and zero out unused portions of the directory
201 blocks in the written image file to avoid revealing information about
202 the contents of the file system.  However, this will prevent analysis of
203 problems related to hash-tree indexed directories.
204
205 .SH RAW IMAGE FILES
206 The
207 .B \-r
208 option will create a raw image file, which differs
209 from a normal image file in two ways.  First, the file system metadata is
210 placed in the same relative offset within
211 .I image-file
212 as it is in the
213 .I device
214 so that
215 .BR debugfs (8),
216 .BR dumpe2fs (8),
217 .BR e2fsck (8),
218 .BR losetup (8),
219 etc. and can be run directly on the raw image file.  In order to minimize
220 the amount of disk space consumed by the raw image file, it is
221 created as a sparse file.  (Beware of copying or
222 compressing/decompressing this file with utilities that don't understand
223 how to create sparse files; the file will become as large as the
224 file system itself!)  Secondly, the raw image file also includes indirect
225 blocks and directory blocks, which the standard image file does not have.
226 .PP
227 Raw image files are sometimes used when sending file systems to the maintainer
228 as part of bug reports to e2fsprogs.  When used in this capacity, the
229 recommended command is as follows (replace
230 .B hda1
231 with the appropriate device for your system):
232 .PP
233 .br
234         \fBe2image \-r /dev/hda1 \- | bzip2 > hda1.e2i.bz2\fR
235 .PP
236 This will only send the metadata information, without any data blocks.
237 However, the filenames in the directory blocks can still reveal
238 information about the contents of the file system that the bug reporter
239 may wish to keep confidential.  To address this concern, the
240 .B \-s
241 option can be specified to scramble the filenames in the image.
242 .PP
243 Note that this will work even if you substitute
244 .B /dev/hda1
245 for another raw
246 disk image, or QCOW2 image previously created by
247 .BR e2image .
248
249 .SH QCOW2 IMAGE FILES
250 The
251 .B \-Q
252 option will create a QCOW2 image file instead of a normal, or raw image file.
253 A QCOW2 image contains all the information the raw image does, however unlike
254 the raw image it is not sparse. The QCOW2 image minimize the amount of space
255 used by the image by storing it in special format which packs data closely
256 together, hence avoiding holes while still minimizing size.
257 .PP
258 In order to send file system to the maintainer as a part of bug report to
259 e2fsprogs, use following commands (replace
260 .B hda1
261 with the appropriate device for your system):
262 .PP
263 .br
264 \       \fBe2image \-Q /dev/hda1 hda1.qcow2\fR
265 .br
266 \       \fBbzip2 -z hda1.qcow2\fR
267 .PP
268 This will only send the metadata information, without any data blocks.
269 As described for
270 .B RAW IMAGE FILES
271 the
272 .B \-s
273 option can be specified to scramble the file system names in the image.
274 .PP
275 Note that the QCOW2 image created by
276 .B e2image
277 is a regular QCOW2 image and can be processed by tools aware of QCOW2 format
278 such as for example
279 .BR qemu-img .
280 .PP
281 You can convert a .qcow2 image into a raw image with:
282 .PP
283 .br
284 \       \fBe2image \-r hda1.qcow2 hda1.raw\fR
285 .br
286 .PP
287 This can be useful to write a QCOW2 image containing all data to a
288 sparse image file where it can be loop mounted, or to a disk partition.
289 Note that this may not work with QCOW2 images not generated by e2image.
290
291 .SH OFFSETS
292 Normally a file system starts at the beginning of a partition, and
293 .B e2image
294 is run on the partition.  When working with image files, you don't
295 have the option of using the partition device, so you can specify
296 the offset where the file system starts directly with the
297 .B \-o
298 option.  Similarly the
299 .B \-O
300 option specifies the offset that should be seeked to in the destination
301 before writing the file system.
302 .PP
303 For example, if you have a
304 .B dd
305 image of a whole hard drive that contains an ext2 fs in a partition
306 starting at 1 MiB, you can clone that image to a block device with:
307 .PP
308 .br
309 \       \fBe2image \-aro 1048576 img /dev/sda1\fR
310 .br
311 .PP
312 Or you can clone a file system from a block device into an image file,
313 leaving room in the first MiB for a partition table with:
314 .PP
315 .br
316 \       \fBe2image -arO 1048576 /dev/sda1 img\fR
317 .br
318 .PP
319 If you specify at least one offset, and only one file, an in-place
320 move will be performed, allowing you to safely move the file system
321 from one offset to another.
322
323 .SH AUTHOR
324 .B e2image
325 was written by Theodore Ts'o (tytso@mit.edu).
326
327 .SH AVAILABILITY
328 .B e2image
329 is part of the e2fsprogs package and is available from
330 http://e2fsprogs.sourceforge.net.
331
332 .SH SEE ALSO
333 .BR dumpe2fs (8),
334 .BR debugfs (8)
335 .BR e2fsck (8)