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