2001-05-03 22:43:43 +08:00
|
|
|
.\" -*- nroff -*-
|
|
|
|
.\" Copyright 2001 by Theodore Ts'o. All Rights Reserved.
|
|
|
|
.\" This file may be copied under the terms of the GNU Public License.
|
2021-03-09 16:35:08 +08:00
|
|
|
.\"
|
2001-05-03 22:43:43 +08:00
|
|
|
.TH E2IMAGE 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
|
|
|
|
.SH NAME
|
2009-05-31 00:34:28 +08:00
|
|
|
e2image \- Save critical ext2/ext3/ext4 filesystem metadata to a file
|
2021-03-09 16:35:08 +08:00
|
|
|
|
2001-05-03 22:43:43 +08:00
|
|
|
.SH SYNOPSIS
|
|
|
|
.B e2image
|
2021-03-09 16:35:08 +08:00
|
|
|
.RB [ \-r | \-Q " [" \-af ]]
|
2019-12-06 01:57:35 +08:00
|
|
|
[
|
2019-03-07 00:52:13 +08:00
|
|
|
.B \-b
|
|
|
|
.I superblock
|
|
|
|
]
|
|
|
|
[
|
|
|
|
.B \-B
|
|
|
|
.I blocksize
|
|
|
|
]
|
2013-12-27 14:08:25 +08:00
|
|
|
[
|
2021-03-09 16:35:08 +08:00
|
|
|
.B \-cnps
|
2001-08-09 17:41:29 +08:00
|
|
|
]
|
2013-12-17 00:32:39 +08:00
|
|
|
[
|
|
|
|
.B \-o
|
2013-12-27 14:08:25 +08:00
|
|
|
.I src_offset
|
2013-12-17 00:32:39 +08:00
|
|
|
]
|
|
|
|
[
|
|
|
|
.B \-O
|
|
|
|
.I dest_offset
|
|
|
|
]
|
2021-03-09 16:35:08 +08:00
|
|
|
.I device
|
|
|
|
.I image-file
|
|
|
|
.br
|
|
|
|
.B e2image
|
|
|
|
.B \-I
|
|
|
|
.I device
|
|
|
|
.I image-file
|
|
|
|
|
2001-05-03 22:43:43 +08:00
|
|
|
.SH DESCRIPTION
|
2001-05-04 00:30:48 +08:00
|
|
|
The
|
2001-05-03 22:43:43 +08:00
|
|
|
.B e2image
|
2012-05-28 10:03:39 +08:00
|
|
|
program will save critical ext2, ext3, or ext4 filesystem metadata located on
|
|
|
|
.I device
|
|
|
|
to a file specified by
|
2001-05-04 00:30:48 +08:00
|
|
|
.IR image-file .
|
2012-05-28 10:03:39 +08:00
|
|
|
The image file may be examined by
|
2001-05-04 00:30:48 +08:00
|
|
|
.B dumpe2fs
|
|
|
|
and
|
|
|
|
.BR debugfs ,
|
|
|
|
by using the
|
|
|
|
.B \-i
|
2021-03-09 16:35:08 +08:00
|
|
|
option to those programs. This can assist an expert in recovering
|
|
|
|
catastrophically corrupted filesystems.
|
2001-05-04 00:30:48 +08:00
|
|
|
.PP
|
2021-03-09 16:35:08 +08:00
|
|
|
It is a very good idea to create image files for all filesystems on a
|
|
|
|
system and save the partition layout (which can be generated using the
|
2005-01-19 13:26:43 +08:00
|
|
|
.B fdisk \-l
|
2005-06-20 20:26:50 +08:00
|
|
|
command) at regular intervals --- at boot time, and/or every week or so.
|
2005-06-27 10:16:21 +08:00
|
|
|
The image file should be stored on some filesystem other than
|
|
|
|
the filesystem whose data it contains, to ensure that this data is
|
2005-01-19 13:26:43 +08:00
|
|
|
accessible in the case where the filesystem has been badly damaged.
|
|
|
|
.PP
|
2012-05-28 10:03:39 +08:00
|
|
|
To save disk space,
|
2005-01-19 13:26:43 +08:00
|
|
|
.B e2image
|
2021-03-09 16:35:08 +08:00
|
|
|
creates the image file as a sparse file, or in QCOW2 format. Hence, if
|
|
|
|
the sparse image file needs to be copied to another location, it should
|
2012-05-28 10:03:39 +08:00
|
|
|
either be compressed first or copied using the
|
2005-01-19 13:26:43 +08:00
|
|
|
.B \-\-sparse=always
|
2012-05-28 10:03:39 +08:00
|
|
|
option to the GNU version of
|
2021-03-09 16:35:08 +08:00
|
|
|
.BR cp (1).
|
2011-05-18 19:36:53 +08:00
|
|
|
This does not apply to the QCOW2 image, which is not sparse.
|
2005-01-19 13:26:43 +08:00
|
|
|
.PP
|
|
|
|
The size of an ext2 image file depends primarily on the size of the
|
2021-03-09 16:35:08 +08:00
|
|
|
filesystems and how many inodes are in use. For a typical 10 Gigabyte
|
|
|
|
filesystem, with 200,000 inodes in use out of 1.2 million inodes, the image
|
|
|
|
file will be approximately 35 Megabytes; a 4 Gigabyte filesystem with 15,000
|
|
|
|
inodes in use out of 550,000 inodes will result in a 3 Megabyte image file.
|
|
|
|
Image files tend to be quite compressible; an image file taking up 32 Megabytes
|
|
|
|
of space on disk will generally compress down to 3 or 4 Megabytes.
|
2005-01-19 13:26:43 +08:00
|
|
|
.PP
|
2021-03-09 16:35:08 +08:00
|
|
|
If
|
|
|
|
.I image-file
|
|
|
|
is
|
|
|
|
.BR \- ,
|
|
|
|
then the output of
|
|
|
|
.B e2image
|
|
|
|
will be sent to standard output, so that the output can be piped to
|
|
|
|
another program, such as
|
|
|
|
.BR gzip (1).
|
|
|
|
(Note that this is currently only supported when
|
|
|
|
creating a raw image file using the
|
|
|
|
.B \-r
|
|
|
|
option, since the process of creating a normal image file, or QCOW2
|
|
|
|
image currently
|
|
|
|
requires random access to the file, which cannot be done using a
|
|
|
|
pipe.
|
|
|
|
|
|
|
|
.SH OPTIONS
|
|
|
|
.TP
|
|
|
|
.B \-a
|
|
|
|
Include file data in the image file. Normally
|
|
|
|
.B e2image
|
|
|
|
only includes fs metadata, not regular file data. This option will
|
|
|
|
produce an image that is suitable to use to clone the entire FS or
|
|
|
|
for backup purposes. Note that this option only works with the
|
|
|
|
raw
|
|
|
|
.RI ( \-r )
|
|
|
|
or QCOW2
|
|
|
|
.RI ( \-Q )
|
|
|
|
formats. In conjunction with the
|
|
|
|
.B \-r
|
|
|
|
option it is possible to clone all and only the used blocks of one
|
|
|
|
filesystem to another device/image file.
|
|
|
|
.TP
|
|
|
|
.BI \-b " superblock"
|
|
|
|
Get image from partition with broken primary superblock by using
|
|
|
|
the superblock located at filesystem block number
|
|
|
|
.IR superblock .
|
|
|
|
The partition is copied as-is including broken primary superblock.
|
|
|
|
.TP
|
|
|
|
.BI \-B " blocksize"
|
|
|
|
Set the filesystem blocksize in bytes. Normally,
|
|
|
|
.B e2image
|
|
|
|
will search for the superblock at various different block sizes in an
|
|
|
|
attempt to find the appropriate blocksize. This search can be fooled in
|
|
|
|
some cases. This option forces e2fsck to only try locating the superblock
|
|
|
|
with a particular blocksize. If the superblock is not found, e2image will
|
|
|
|
terminate with a fatal error.
|
|
|
|
.TP
|
|
|
|
.BI \-c
|
|
|
|
Compare each block to be copied from the source
|
|
|
|
.I device
|
|
|
|
to the corresponding block in the target
|
|
|
|
.IR image-file .
|
|
|
|
If both are already the same, the write will be skipped. This is
|
|
|
|
useful if the file system is being cloned to a flash-based storage device
|
|
|
|
(where reads are very fast and where it is desirable to avoid unnecessary
|
|
|
|
writes to reduce write wear on the device).
|
|
|
|
.TP
|
|
|
|
.B \-f
|
|
|
|
Override the read-only requirement for the source filesystem when saving
|
|
|
|
the image file using the
|
|
|
|
.B \-r
|
|
|
|
and
|
|
|
|
.B \-Q
|
|
|
|
options. Normally, if the source filesystem is in use, the resulting image
|
|
|
|
file is very likely not going to be useful. In some cases where the source
|
|
|
|
filesystem is in constant use this may be better than no image at all.
|
|
|
|
.TP
|
2012-05-28 10:03:39 +08:00
|
|
|
.B \-I
|
2021-03-09 16:35:08 +08:00
|
|
|
install the metadata stored in the image file back to the device.
|
|
|
|
It can be used to restore the filesystem metadata back to the device
|
|
|
|
in emergency situations.
|
2004-07-29 09:07:53 +08:00
|
|
|
.PP
|
|
|
|
.B WARNING!!!!
|
|
|
|
The
|
2012-05-28 10:03:39 +08:00
|
|
|
.B \-I
|
2005-06-20 20:26:50 +08:00
|
|
|
option should only be used as a desperation measure when other
|
2004-07-29 09:07:53 +08:00
|
|
|
alternatives have failed. If the filesystem has changed since the image
|
|
|
|
file was created, data
|
|
|
|
.B will
|
2021-03-09 16:35:08 +08:00
|
|
|
be lost. In general, you should make another full image backup of the
|
|
|
|
filesystem first, in case you wish to try other recovery strategies afterward.
|
|
|
|
.TP
|
|
|
|
.B \-n
|
|
|
|
Cause all image writes to be skipped, and instead only print the block
|
|
|
|
numbers that would have been written.
|
|
|
|
.TP
|
|
|
|
.BI \-o " src_offset"
|
|
|
|
Specify offset of the image to be read from the start of the source
|
|
|
|
.I device
|
|
|
|
in bytes. See
|
|
|
|
.B OFFSETS
|
|
|
|
for more details.
|
|
|
|
.TP
|
|
|
|
.BI \-O " tgt_offset"
|
|
|
|
Specify offset of the image to be written from the start of the target
|
|
|
|
.I image-file
|
|
|
|
in bytes. See
|
|
|
|
.B OFFSETS
|
|
|
|
for more details.
|
|
|
|
.TP
|
|
|
|
.B \-p
|
|
|
|
Show progress of image-file creation.
|
|
|
|
.TP
|
|
|
|
.B \-Q
|
|
|
|
Create a QCOW2-format image file instead of a normal image file, suitable
|
|
|
|
for use by virtual machine images, and other tools that can use the
|
|
|
|
.B .qcow
|
|
|
|
image format. See
|
|
|
|
.B QCOW2 IMAGE FILES
|
|
|
|
below for details.
|
|
|
|
.TP
|
|
|
|
.B \-r
|
|
|
|
Create a raw image file instead of a normal image file. See
|
|
|
|
.B RAW IMAGE FILES
|
|
|
|
below for details.
|
|
|
|
.TP
|
|
|
|
.B \-s
|
|
|
|
Scramble directory entries and zero out unused portions of the directory
|
|
|
|
blocks in the written image file to avoid revealing information about
|
|
|
|
the contents of the filesystem. However, this will prevent analysis of
|
|
|
|
problems related to hash-tree indexed directories.
|
|
|
|
|
2005-01-19 13:26:43 +08:00
|
|
|
.SH RAW IMAGE FILES
|
2012-05-28 10:03:39 +08:00
|
|
|
The
|
2001-08-09 17:41:29 +08:00
|
|
|
.B \-r
|
2021-03-09 16:35:08 +08:00
|
|
|
option will create a raw image file, which differs
|
2001-08-09 17:41:29 +08:00
|
|
|
from a normal image file in two ways. First, the filesystem metadata is
|
2021-03-09 16:35:08 +08:00
|
|
|
placed in the same relative offset within
|
|
|
|
.I image-file
|
|
|
|
as it is in the
|
|
|
|
.I device
|
|
|
|
so that
|
|
|
|
.BR debugfs (8),
|
|
|
|
.BR dumpe2fs (8),
|
|
|
|
.BR e2fsck (8),
|
|
|
|
.BR losetup (8),
|
|
|
|
etc. and can be run directly on the raw image file. In order to minimize
|
|
|
|
the amount of disk space consumed by the raw image file, it is
|
2001-08-09 17:41:29 +08:00
|
|
|
created as a sparse file. (Beware of copying or
|
|
|
|
compressing/decompressing this file with utilities that don't understand
|
|
|
|
how to create sparse files; the file will become as large as the
|
|
|
|
filesystem itself!) Secondly, the raw image file also includes indirect
|
2021-03-09 16:35:08 +08:00
|
|
|
blocks and directory blocks, which the standard image file does not have.
|
2001-08-09 17:41:29 +08:00
|
|
|
.PP
|
2005-06-20 20:26:50 +08:00
|
|
|
Raw image files are sometimes used when sending filesystems to the maintainer
|
|
|
|
as part of bug reports to e2fsprogs. When used in this capacity, the
|
2021-03-09 16:35:08 +08:00
|
|
|
recommended command is as follows (replace
|
|
|
|
.B hda1
|
|
|
|
with the appropriate device for your system):
|
2001-05-04 00:30:48 +08:00
|
|
|
.PP
|
2005-01-19 13:26:43 +08:00
|
|
|
.br
|
2012-05-28 10:03:39 +08:00
|
|
|
\fBe2image \-r /dev/hda1 \- | bzip2 > hda1.e2i.bz2\fR
|
2001-05-04 00:30:48 +08:00
|
|
|
.PP
|
2012-05-28 10:03:39 +08:00
|
|
|
This will only send the metadata information, without any data blocks.
|
2005-01-19 13:26:43 +08:00
|
|
|
However, the filenames in the directory blocks can still reveal
|
|
|
|
information about the contents of the filesystem that the bug reporter
|
|
|
|
may wish to keep confidential. To address this concern, the
|
|
|
|
.B \-s
|
2021-03-09 16:35:08 +08:00
|
|
|
option can be specified to scramble the filenames in the image.
|
2001-05-03 22:43:43 +08:00
|
|
|
.PP
|
2021-03-09 16:35:08 +08:00
|
|
|
Note that this will work even if you substitute
|
|
|
|
.B /dev/hda1
|
|
|
|
for another raw
|
2011-05-18 20:20:47 +08:00
|
|
|
disk image, or QCOW2 image previously created by
|
|
|
|
.BR e2image .
|
2021-03-09 16:35:08 +08:00
|
|
|
|
2011-05-18 19:36:53 +08:00
|
|
|
.SH QCOW2 IMAGE FILES
|
|
|
|
The
|
|
|
|
.B \-Q
|
|
|
|
option will create a QCOW2 image file instead of a normal, or raw image file.
|
|
|
|
A QCOW2 image contains all the information the raw image does, however unlike
|
2021-03-09 16:35:08 +08:00
|
|
|
the raw image it is not sparse. The QCOW2 image minimize the amount of space
|
|
|
|
used by the image by storing it in special format which packs data closely
|
|
|
|
together, hence avoiding holes while still minimizing size.
|
2011-05-18 19:36:53 +08:00
|
|
|
.PP
|
|
|
|
In order to send filesystem to the maintainer as a part of bug report to
|
2021-03-09 16:35:08 +08:00
|
|
|
e2fsprogs, use following commands (replace
|
|
|
|
.B hda1
|
|
|
|
with the appropriate device for your system):
|
2011-05-18 19:36:53 +08:00
|
|
|
.PP
|
|
|
|
.br
|
|
|
|
\ \fBe2image \-Q /dev/hda1 hda1.qcow2\fR
|
|
|
|
.br
|
|
|
|
\ \fBbzip2 -z hda1.qcow2\fR
|
|
|
|
.PP
|
|
|
|
This will only send the metadata information, without any data blocks.
|
2021-03-09 16:35:08 +08:00
|
|
|
As described for
|
|
|
|
.B RAW IMAGE FILES
|
|
|
|
the
|
2011-05-18 19:36:53 +08:00
|
|
|
.B \-s
|
2021-03-09 16:35:08 +08:00
|
|
|
option can be specified to scramble the filesystem names in the image.
|
2011-05-18 19:36:53 +08:00
|
|
|
.PP
|
2021-03-09 16:35:08 +08:00
|
|
|
Note that the QCOW2 image created by
|
2011-05-18 19:36:53 +08:00
|
|
|
.B e2image
|
2021-03-09 16:35:08 +08:00
|
|
|
is a regular QCOW2 image and can be processed by tools aware of QCOW2 format
|
2011-05-18 19:36:53 +08:00
|
|
|
such as for example
|
|
|
|
.BR qemu-img .
|
|
|
|
.PP
|
2021-03-09 16:35:08 +08:00
|
|
|
You can convert a .qcow2 image into a raw image with:
|
2013-01-16 04:31:23 +08:00
|
|
|
.PP
|
|
|
|
.br
|
|
|
|
\ \fBe2image \-r hda1.qcow2 hda1.raw\fR
|
|
|
|
.br
|
|
|
|
.PP
|
2021-03-09 16:35:08 +08:00
|
|
|
This can be useful to write a QCOW2 image containing all data to a
|
2013-01-16 04:31:23 +08:00
|
|
|
sparse image file where it can be loop mounted, or to a disk partition.
|
2021-03-09 16:35:08 +08:00
|
|
|
Note that this may not work with QCOW2 images not generated by e2image.
|
|
|
|
|
2013-12-17 00:32:39 +08:00
|
|
|
.SH OFFSETS
|
|
|
|
Normally a filesystem starts at the beginning of a partition, and
|
|
|
|
.B e2image
|
|
|
|
is run on the partition. When working with image files, you don't
|
|
|
|
have the option of using the partition device, so you can specify
|
|
|
|
the offset where the filesystem starts directly with the
|
|
|
|
.B \-o
|
|
|
|
option. Similarly the
|
|
|
|
.B \-O
|
|
|
|
option specifies the offset that should be seeked to in the destination
|
|
|
|
before writing the filesystem.
|
|
|
|
.PP
|
|
|
|
For example, if you have a
|
|
|
|
.B dd
|
|
|
|
image of a whole hard drive that contains an ext2 fs in a partition
|
2021-03-09 16:35:08 +08:00
|
|
|
starting at 1 MiB, you can clone that image to a block device with:
|
2013-12-17 00:32:39 +08:00
|
|
|
.PP
|
|
|
|
.br
|
|
|
|
\ \fBe2image \-aro 1048576 img /dev/sda1\fR
|
|
|
|
.br
|
|
|
|
.PP
|
2021-03-09 16:35:08 +08:00
|
|
|
Or you can clone a filesystem from a block device into an image file,
|
|
|
|
leaving room in the first MiB for a partition table with:
|
2013-12-17 00:32:39 +08:00
|
|
|
.PP
|
|
|
|
.br
|
|
|
|
\ \fBe2image -arO 1048576 /dev/sda1 img\fR
|
|
|
|
.br
|
|
|
|
.PP
|
2013-12-17 00:33:19 +08:00
|
|
|
If you specify at least one offset, and only one file, an in-place
|
|
|
|
move will be performed, allowing you to safely move the filesystem
|
|
|
|
from one offset to another.
|
2021-03-09 16:35:08 +08:00
|
|
|
|
2001-05-03 22:43:43 +08:00
|
|
|
.SH AUTHOR
|
2012-05-28 10:03:39 +08:00
|
|
|
.B e2image
|
2001-05-03 22:43:43 +08:00
|
|
|
was written by Theodore Ts'o (tytso@mit.edu).
|
2021-03-09 16:35:08 +08:00
|
|
|
|
2001-05-03 22:43:43 +08:00
|
|
|
.SH AVAILABILITY
|
|
|
|
.B e2image
|
2012-05-28 10:03:39 +08:00
|
|
|
is part of the e2fsprogs package and is available from
|
2001-05-03 22:43:43 +08:00
|
|
|
http://e2fsprogs.sourceforge.net.
|
2021-03-09 16:35:08 +08:00
|
|
|
|
2001-05-03 22:43:43 +08:00
|
|
|
.SH SEE ALSO
|
|
|
|
.BR dumpe2fs (8),
|
|
|
|
.BR debugfs (8)
|
2021-03-09 16:35:08 +08:00
|
|
|
.BR e2fsck (8)
|