blob: 8876e77f8a074348d614ef6c78c38671ce22bd94 [file] [log] [blame]
Theodore Ts'o348e43d2001-05-03 14:43:43 +00001.\" -*- 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
Theodore Ts'o4f858542009-05-30 12:34:28 -04007e2image \- Save critical ext2/ext3/ext4 filesystem metadata to a file
Theodore Ts'o348e43d2001-05-03 14:43:43 +00008.SH SYNOPSIS
9.B e2image
Theodore Ts'o6304baf2001-08-09 05:41:29 -040010[
Theodore Ts'od851ed32005-01-19 00:26:43 -050011.B \-rsI
Theodore Ts'o6304baf2001-08-09 05:41:29 -040012]
Theodore Ts'o348e43d2001-05-03 14:43:43 +000013.I device
14.I image-file
15.SH DESCRIPTION
Theodore Ts'o0edb4d82001-05-03 16:30:48 +000016The
Theodore Ts'o348e43d2001-05-03 14:43:43 +000017.B e2image
Theodore Ts'o4780e872012-05-27 22:03:39 -040018program will save critical ext2, ext3, or ext4 filesystem metadata located on
19.I device
20to a file specified by
Theodore Ts'o0edb4d82001-05-03 16:30:48 +000021.IR image-file .
Theodore Ts'o4780e872012-05-27 22:03:39 -040022The image file may be examined by
Theodore Ts'o0edb4d82001-05-03 16:30:48 +000023.B dumpe2fs
24and
25.BR debugfs ,
26by using the
27.B \-i
Theodore Ts'ob7c1d202005-06-20 08:26:50 -040028option to those programs. This can assist an expert in
29recovering catastrophically corrupted filesystems. In the future,
Theodore Ts'o0edb4d82001-05-03 16:30:48 +000030e2fsck will be enhanced to be able to use the image file to help
31recover a badly damaged filesystem.
32.PP
Theodore Ts'o4780e872012-05-27 22:03:39 -040033If
Theodore Ts'o1c1e0042001-08-09 06:04:32 -040034.I image-file
Theodore Ts'o4780e872012-05-27 22:03:39 -040035is \-, then the output of
Theodore Ts'o1c1e0042001-08-09 06:04:32 -040036.B e2image
Theodore Ts'o8ac59292004-03-08 14:18:56 -050037will be sent to standard output, so that the output can be piped to
Theodore Ts'o4780e872012-05-27 22:03:39 -040038another program, such as
39.BR gzip (1).
Theodore Ts'ob7c1d202005-06-20 08:26:50 -040040(Note that this is currently only supported when
Theodore Ts'o4780e872012-05-27 22:03:39 -040041creating a raw image file using the
Theodore Ts'o8ac59292004-03-08 14:18:56 -050042.B \-r
Lukas Czernerbf0449b2011-05-18 13:36:53 +020043option, since the process of creating a normal image file, or QCOW2
44image currently
Theodore Ts'ob7c1d202005-06-20 08:26:50 -040045requires random access to the file, which cannot be done using a
Theodore Ts'o8ac59292004-03-08 14:18:56 -050046pipe. This restriction will hopefully be lifted in a future version of
47.BR e2image .)
Theodore Ts'o1c1e0042001-08-09 06:04:32 -040048.PP
Theodore Ts'ob7c1d202005-06-20 08:26:50 -040049It is a very good idea to create image files for all of
50filesystems on a system and save the partition
Theodore Ts'o4780e872012-05-27 22:03:39 -040051layout (which can be generated using the
Theodore Ts'o11d1e612004-12-01 12:42:33 -050052.B fdisk \-l
Theodore Ts'ob7c1d202005-06-20 08:26:50 -040053command) at regular intervals --- at boot time, and/or every week or so.
Theodore Ts'od9781ce2005-06-26 22:16:21 -040054The image file should be stored on some filesystem other than
55the filesystem whose data it contains, to ensure that this data is
Theodore Ts'o0edb4d82001-05-03 16:30:48 +000056accessible in the case where the filesystem has been badly damaged.
57.PP
Theodore Ts'o4780e872012-05-27 22:03:39 -040058To save disk space,
Theodore Ts'o0edb4d82001-05-03 16:30:48 +000059.B e2image
Lukas Czernerbf0449b2011-05-18 13:36:53 +020060creates the image file as a sparse file, or in QCOW2 format.
61Hence, if the sparse image file
Theodore Ts'o0edb4d82001-05-03 16:30:48 +000062needs to be copied to another location, it should
Theodore Ts'o4780e872012-05-27 22:03:39 -040063either be compressed first or copied using the
Theodore Ts'o11d1e612004-12-01 12:42:33 -050064.B \-\-sparse=always
Theodore Ts'o4780e872012-05-27 22:03:39 -040065option to the GNU version of
Lukas Czernerbf0449b2011-05-18 13:36:53 +020066.BR cp .
67This does not apply to the QCOW2 image, which is not sparse.
Theodore Ts'o0edb4d82001-05-03 16:30:48 +000068.PP
69The size of an ext2 image file depends primarily on the size of the
70filesystems and how many inodes are in use. For a typical 10 gigabyte
71filesystem, with 200,000 inodes in use out of 1.2 million inodes, the
Theodore Ts'ob7c1d202005-06-20 08:26:50 -040072image file will be approximately 35 megabytes; a 4 gigabyte filesystem with
Theodore Ts'o0edb4d82001-05-03 16:30:48 +00007315,000 inodes in use out of 550,000 inodes will result in a 3 megabyte
74image file. Image files tend to be quite
Theodore Ts'o6304baf2001-08-09 05:41:29 -040075compressible; an image file taking up 32 megabytes of space on
Theodore Ts'o0edb4d82001-05-03 16:30:48 +000076disk will generally compress down to 3 or 4 megabytes.
Theodore Ts'o348e43d2001-05-03 14:43:43 +000077.PP
Theodore Ts'od851ed32005-01-19 00:26:43 -050078.SH RESTORING FILESYSTEM METADATA USING AN IMAGE FILE
79.PP
Theodore Ts'o4780e872012-05-27 22:03:39 -040080The
81.B \-I
Theodore Ts'od851ed32005-01-19 00:26:43 -050082option will cause e2image to install the metadata stored in the image
Theodore Ts'o4780e872012-05-27 22:03:39 -040083file back to the device. It can be used to restore the filesystem metadata
Theodore Ts'od851ed32005-01-19 00:26:43 -050084back to the device in emergency situations.
85.PP
86.B WARNING!!!!
87The
Theodore Ts'o4780e872012-05-27 22:03:39 -040088.B \-I
Theodore Ts'ob7c1d202005-06-20 08:26:50 -040089option should only be used as a desperation measure when other
Theodore Ts'od851ed32005-01-19 00:26:43 -050090alternatives have failed. If the filesystem has changed since the image
91file was created, data
92.B will
93be lost. In general, you should make a full image
94backup of the filesystem first, in case you wish to try other recovery
95strategies afterwards.
96.PP
97.SH RAW IMAGE FILES
Theodore Ts'o4780e872012-05-27 22:03:39 -040098The
Theodore Ts'od851ed32005-01-19 00:26:43 -050099.B \-r
Theodore Ts'o4780e872012-05-27 22:03:39 -0400100option will create a raw image file instead of a normal image file.
Theodore Ts'od851ed32005-01-19 00:26:43 -0500101A raw image file differs
102from a normal image file in two ways. First, the filesystem metadata is
103placed in the proper position so that e2fsck, dumpe2fs, debugfs,
Theodore Ts'o4780e872012-05-27 22:03:39 -0400104etc.\& can be run directly on the raw image file. In order to minimize
Theodore Ts'od851ed32005-01-19 00:26:43 -0500105the amount of disk space consumed by a raw image file, the file is
106created as a sparse file. (Beware of copying or
107compressing/decompressing this file with utilities that don't understand
108how to create sparse files; the file will become as large as the
109filesystem itself!) Secondly, the raw image file also includes indirect
110blocks and directory blocks, which the standard image file does not have,
111although this may change in the future.
112.PP
Theodore Ts'ob7c1d202005-06-20 08:26:50 -0400113Raw image files are sometimes used when sending filesystems to the maintainer
114as part of bug reports to e2fsprogs. When used in this capacity, the
115recommended command is as follows (replace hda1 with the appropriate device):
Theodore Ts'od851ed32005-01-19 00:26:43 -0500116.PP
117.br
Theodore Ts'o4780e872012-05-27 22:03:39 -0400118 \fBe2image \-r /dev/hda1 \- | bzip2 > hda1.e2i.bz2\fR
Theodore Ts'od851ed32005-01-19 00:26:43 -0500119.PP
Theodore Ts'o4780e872012-05-27 22:03:39 -0400120This will only send the metadata information, without any data blocks.
Theodore Ts'od851ed32005-01-19 00:26:43 -0500121However, the filenames in the directory blocks can still reveal
122information about the contents of the filesystem that the bug reporter
123may wish to keep confidential. To address this concern, the
124.B \-s
125option can be specified. This will cause
Theodore Ts'o4780e872012-05-27 22:03:39 -0400126.B e2image
Theodore Ts'od851ed32005-01-19 00:26:43 -0500127to scramble directory entries and zero out any unused portions
Theodore Ts'ob7c1d202005-06-20 08:26:50 -0400128of the directory blocks before writing the image file. However,
Theodore Ts'o4780e872012-05-27 22:03:39 -0400129the
Theodore Ts'ob7c1d202005-06-20 08:26:50 -0400130.B \-s
131option will prevent analysis of problems related to hash-tree indexed
132directories.
Theodore Ts'od851ed32005-01-19 00:26:43 -0500133.PP
Lukas Czerner92dcfb72011-05-18 14:20:47 +0200134Note that this will work even if you substitute "/dev/hda1" for another raw
135disk image, or QCOW2 image previously created by
136.BR e2image .
137.PP
Lukas Czernerbf0449b2011-05-18 13:36:53 +0200138.SH QCOW2 IMAGE FILES
139The
140.B \-Q
141option will create a QCOW2 image file instead of a normal, or raw image file.
142A QCOW2 image contains all the information the raw image does, however unlike
143the raw image it is not sparse. The QCOW2 image minimize the amount of disk
144space by storing data in special format with pack data closely together, hence
145avoiding holes while still minimizing size.
146.PP
147In order to send filesystem to the maintainer as a part of bug report to
148e2fsprogs, use following commands (replace hda1 with the appropriate device):
149.PP
150.br
151\ \fBe2image \-Q /dev/hda1 hda1.qcow2\fR
152.br
153\ \fBbzip2 -z hda1.qcow2\fR
154.PP
155This will only send the metadata information, without any data blocks.
156However, the filenames in the directory blocks can still reveal
157information about the contents of the filesystem that the bug reporter
158may wish to keep confidential. To address this concern, the
159.B \-s
160option can be specified. This will cause
161.B e2image
162to scramble directory entries and zero out any unused portions
163of the directory blocks before writing the image file. However, the
164.B \-s
165option will prevent analysis of problems related to hash-tree indexed
166directories.
167.PP
168Note that QCOW2 image created by
169.B e2image
170is regular QCOW2 image and can be processed by tools aware of QCOW2 format
171such as for example
172.BR qemu-img .
173.PP
Theodore Ts'o348e43d2001-05-03 14:43:43 +0000174.SH AUTHOR
Theodore Ts'o4780e872012-05-27 22:03:39 -0400175.B e2image
Theodore Ts'o348e43d2001-05-03 14:43:43 +0000176was written by Theodore Ts'o (tytso@mit.edu).
177.SH AVAILABILITY
178.B e2image
Theodore Ts'o4780e872012-05-27 22:03:39 -0400179is part of the e2fsprogs package and is available from
Theodore Ts'o348e43d2001-05-03 14:43:43 +0000180http://e2fsprogs.sourceforge.net.
181.SH SEE ALSO
182.BR dumpe2fs (8),
183.BR debugfs (8)
184