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