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