486 lines
12 KiB
HTML
486 lines
12 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of E2IMAGE</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>E2IMAGE</H1>
|
|
Section: Maintenance Commands (8)<BR>Updated: January 2020<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
e2image - Save critical ext2/ext3/ext4 filesystem metadata to a file
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>e2image</B>
|
|
|
|
[
|
|
<B>-r|-Q</B>
|
|
|
|
]
|
|
[
|
|
<B>-f</B>
|
|
|
|
]
|
|
[
|
|
<B>-b</B>
|
|
|
|
<I>superblock</I>
|
|
|
|
]
|
|
[
|
|
<B>-B</B>
|
|
|
|
<I>blocksize</I>
|
|
|
|
]
|
|
<I>device</I>
|
|
|
|
<I>image-file</I>
|
|
|
|
<BR>
|
|
|
|
<B>e2image</B>
|
|
|
|
<B>-I</B>
|
|
|
|
<I>device</I>
|
|
|
|
<I>image-file</I>
|
|
|
|
<BR>
|
|
|
|
<B>e2image</B>
|
|
|
|
<B>-ra</B>
|
|
|
|
[
|
|
<B>-cfnp</B>
|
|
|
|
]
|
|
[
|
|
<B>-o</B>
|
|
|
|
<I>src_offset</I>
|
|
|
|
]
|
|
[
|
|
<B>-O</B>
|
|
|
|
<I>dest_offset</I>
|
|
|
|
]
|
|
<I>src_fs</I>
|
|
|
|
[
|
|
<I>dest_fs</I>
|
|
|
|
]
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The
|
|
<B>e2image</B>
|
|
|
|
program will save critical ext2, ext3, or ext4 filesystem metadata located on
|
|
<I>device</I>
|
|
|
|
to a file specified by
|
|
<I>image-file</I>.
|
|
|
|
The image file may be examined by
|
|
<B>dumpe2fs</B>
|
|
|
|
and
|
|
<B>debugfs</B>,
|
|
|
|
by using the
|
|
<B>-i</B>
|
|
|
|
option to those programs. This can assist an expert in
|
|
recovering catastrophically corrupted filesystems. In the future,
|
|
e2fsck will be enhanced to be able to use the image file to help
|
|
recover a badly damaged filesystem.
|
|
<P>
|
|
|
|
When saving an e2image for debugging purposes, using either the
|
|
<B>-r</B>
|
|
|
|
or
|
|
<B>-Q</B>
|
|
|
|
options, the filesystem must be unmounted or be mounted read/only, in order
|
|
for the image file to be in a consistent state. This requirement can be
|
|
overridden using the
|
|
<B>-f</B>
|
|
|
|
option, but the resulting image file is very likely not going to be useful.
|
|
<P>
|
|
|
|
If
|
|
<I>image-file</I>
|
|
|
|
is -, then the output of
|
|
<B>e2image</B>
|
|
|
|
will be sent to standard output, so that the output can be piped to
|
|
another program, such as
|
|
<B><A HREF="/cgi-bin/man/man2html?1+gzip">gzip</A></B>(1).
|
|
|
|
(Note that this is currently only supported when
|
|
creating a raw image file using the
|
|
<B>-r</B>
|
|
|
|
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. This restriction will hopefully be lifted in a future version of
|
|
<B>e2image</B>.)
|
|
|
|
<P>
|
|
|
|
It is a very good idea to create image files for all of
|
|
filesystems on a system and save the partition
|
|
layout (which can be generated using the
|
|
<B>fdisk -l</B>
|
|
|
|
command) at regular intervals --- at boot time, and/or every week or so.
|
|
The image file should be stored on some filesystem other than
|
|
the filesystem whose data it contains, to ensure that this data is
|
|
accessible in the case where the filesystem has been badly damaged.
|
|
<P>
|
|
|
|
To save disk space,
|
|
<B>e2image</B>
|
|
|
|
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
|
|
either be compressed first or copied using the
|
|
<B>--sparse=always</B>
|
|
|
|
option to the GNU version of
|
|
<B>cp</B>.
|
|
|
|
This does not apply to the QCOW2 image, which is not sparse.
|
|
<P>
|
|
|
|
The size of an ext2 image file depends primarily on the size of the
|
|
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.
|
|
<P>
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RESTORING FILESYSTEM METADATA USING AN IMAGE FILE</H2>
|
|
|
|
<P>
|
|
|
|
The
|
|
<B>-I</B>
|
|
|
|
option will cause e2image to 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.
|
|
<P>
|
|
|
|
<B>WARNING!!!!</B>
|
|
|
|
The
|
|
<B>-I</B>
|
|
|
|
option should only be used as a desperation measure when other
|
|
alternatives have failed. If the filesystem has changed since the image
|
|
file was created, data
|
|
<B>will</B>
|
|
|
|
be lost. In general, you should make a full image
|
|
backup of the filesystem first, in case you wish to try other recovery
|
|
strategies afterwards.
|
|
<P>
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H2>RAW IMAGE FILES</H2>
|
|
|
|
The
|
|
<B>-r</B>
|
|
|
|
option will create a raw image file instead of a normal image file.
|
|
A raw image file differs
|
|
from a normal image file in two ways. First, the filesystem metadata is
|
|
placed in the proper position so that e2fsck, dumpe2fs, debugfs,
|
|
etc. can be run directly on the raw image file. In order to minimize
|
|
the amount of disk space consumed by a raw image file, the file is
|
|
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
|
|
blocks and directory blocks, which the standard image file does not have,
|
|
although this may change in the future.
|
|
<P>
|
|
|
|
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
|
|
recommended command is as follows (replace hda1 with the appropriate device):
|
|
<P>
|
|
|
|
<BR>
|
|
|
|
<TT> </TT><B>e2image -r /dev/hda1 - | bzip2 > hda1.e2i.bz2</B><BR>
|
|
<P>
|
|
|
|
This will only send the metadata information, without any data blocks.
|
|
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</B>
|
|
|
|
option can be specified. This will cause
|
|
<B>e2image</B>
|
|
|
|
to scramble directory entries and zero out any unused portions
|
|
of the directory blocks before writing the image file. However,
|
|
the
|
|
<B>-s</B>
|
|
|
|
option will prevent analysis of problems related to hash-tree indexed
|
|
directories.
|
|
<P>
|
|
|
|
Option
|
|
<B>-b</B>
|
|
|
|
<I>superblock</I>
|
|
|
|
can be used to get image from partition with broken primary superblock.
|
|
The partition is copied as-is including broken primary superblock.
|
|
<P>
|
|
|
|
Option
|
|
<B>-B</B>
|
|
|
|
<I>blocksize</I>
|
|
|
|
can be used to set superblock block size. Normally, e2fsck 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 at a particular
|
|
blocksize. If the superblock is not found, e2fsck will terminate with a
|
|
fatal error.
|
|
<P>
|
|
|
|
Note that this will work even if you substitute "/dev/hda1" for another raw
|
|
disk image, or QCOW2 image previously created by
|
|
<B>e2image</B>.
|
|
|
|
<P>
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H2>QCOW2 IMAGE FILES</H2>
|
|
|
|
The
|
|
<B>-Q</B>
|
|
|
|
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
|
|
the raw image it is not sparse. The QCOW2 image minimize the amount of disk
|
|
space by storing data in special format with pack data closely together, hence
|
|
avoiding holes while still minimizing size.
|
|
<P>
|
|
|
|
In order to send filesystem to the maintainer as a part of bug report to
|
|
e2fsprogs, use following commands (replace hda1 with the appropriate device):
|
|
<P>
|
|
|
|
<BR>
|
|
|
|
<B>e2image -Q /dev/hda1 hda1.qcow2</B>
|
|
<BR>
|
|
|
|
<B>bzip2 -z hda1.qcow2</B>
|
|
<P>
|
|
|
|
This will only send the metadata information, without any data blocks.
|
|
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</B>
|
|
|
|
option can be specified. This will cause
|
|
<B>e2image</B>
|
|
|
|
to scramble directory entries and zero out any unused portions
|
|
of the directory blocks before writing the image file. However, the
|
|
<B>-s</B>
|
|
|
|
option will prevent analysis of problems related to hash-tree indexed
|
|
directories.
|
|
<P>
|
|
|
|
Note that QCOW2 image created by
|
|
<B>e2image</B>
|
|
|
|
is regular QCOW2 image and can be processed by tools aware of QCOW2 format
|
|
such as for example
|
|
<B>qemu-img</B>.
|
|
|
|
<P>
|
|
|
|
You can convert a qcow2 image into a raw image with:
|
|
<P>
|
|
|
|
<BR>
|
|
|
|
<B>e2image -r hda1.qcow2 hda1.raw</B>
|
|
<BR>
|
|
|
|
<P>
|
|
|
|
This can be useful to write a qcow2 image containing all data to a
|
|
sparse image file where it can be loop mounted, or to a disk partition.
|
|
Note that this may not work with qcow2 images not generated by e2image.
|
|
<P>
|
|
|
|
Options
|
|
<B>-b</B>
|
|
|
|
<I>superblock</I>
|
|
|
|
and
|
|
<B>-B</B>
|
|
|
|
<I>blocksize</I>
|
|
|
|
can be used same way as for raw images.
|
|
<P>
|
|
|
|
<A NAME="lbAH"> </A>
|
|
<H2>INCLUDING DATA</H2>
|
|
|
|
Normally
|
|
<B>e2image</B>
|
|
|
|
only includes fs metadata, not regular file data. The
|
|
<B>-a</B>
|
|
|
|
option can be specified to include all data. This will
|
|
give 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 or QCOW2 formats. The
|
|
<B>-p</B>
|
|
|
|
switch may be given to show progress. 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), the
|
|
<B>-c</B>
|
|
|
|
option which cause e2image to try reading a block from the destination
|
|
to see if it is identical to the block which
|
|
<B>e2image</B>
|
|
|
|
is about to copy. If the block is already the same, the write can be
|
|
skipped. The
|
|
<B>-n</B>
|
|
|
|
option will cause all of the writes to be no-ops, and print the blocks
|
|
that would have been written.
|
|
<P>
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H2>OFFSETS</H2>
|
|
|
|
Normally a filesystem starts at the beginning of a partition, and
|
|
<B>e2image</B>
|
|
|
|
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</B>
|
|
|
|
option. Similarly the
|
|
<B>-O</B>
|
|
|
|
option specifies the offset that should be seeked to in the destination
|
|
before writing the filesystem.
|
|
<P>
|
|
|
|
For example, if you have a
|
|
<B>dd</B>
|
|
|
|
image of a whole hard drive that contains an ext2 fs in a partition
|
|
starting at 1 MiB, you can clone that fs with:
|
|
<P>
|
|
|
|
<BR>
|
|
|
|
<B>e2image -aro 1048576 img /dev/sda1</B>
|
|
<BR>
|
|
|
|
<P>
|
|
|
|
Or you can clone a fs into an image file, leaving room in the first
|
|
MiB for a partition table with:
|
|
<P>
|
|
|
|
<BR>
|
|
|
|
<B>e2image -arO 1048576 /dev/sda1 img</B>
|
|
<BR>
|
|
|
|
<P>
|
|
|
|
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.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
<B>e2image</B>
|
|
|
|
was written by Theodore Ts'o (<A HREF="mailto:tytso@mit.edu">tytso@mit.edu</A>).
|
|
<A NAME="lbAK"> </A>
|
|
<H2>AVAILABILITY</H2>
|
|
|
|
<B>e2image</B>
|
|
|
|
is part of the e2fsprogs package and is available from
|
|
<A HREF="http://e2fsprogs.sourceforge.net.">http://e2fsprogs.sourceforge.net.</A>
|
|
<A NAME="lbAL"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?8+dumpe2fs">dumpe2fs</A></B>(8),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?8+debugfs">debugfs</A></B>(8)
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="4"><A HREF="#lbAE">RESTORING FILESYSTEM METADATA USING AN IMAGE FILE</A><DD>
|
|
<DT id="5"><A HREF="#lbAF">RAW IMAGE FILES</A><DD>
|
|
<DT id="6"><A HREF="#lbAG">QCOW2 IMAGE FILES</A><DD>
|
|
<DT id="7"><A HREF="#lbAH">INCLUDING DATA</A><DD>
|
|
<DT id="8"><A HREF="#lbAI">OFFSETS</A><DD>
|
|
<DT id="9"><A HREF="#lbAJ">AUTHOR</A><DD>
|
|
<DT id="10"><A HREF="#lbAK">AVAILABILITY</A><DD>
|
|
<DT id="11"><A HREF="#lbAL">SEE ALSO</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:12 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|