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