Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The usage of the Linux basic command e2image

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "the usage of the Linux basic command e2image". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

E2image

The e2Image program saves ext2, ext3, or ext4 file system metadata located on the device to a file specified by the image file. By using the-I option on these programs, the image file can be checked by dupe2fs and the debugger. This can help experts recover severely corrupted file systems.

If the image file is "-", the output of e2image is sent to standard output so that the output can be piped to another program, such as gzip (1). (note that this is currently supported only when creating the original image file with the-r option, because the process of creating a normal image file or QCOW 2 image currently requires random access to the file, which cannot be done using pipes.)

It is a good idea to create image files for all file systems on your system and save partition layouts periodically (which can be generated using the fdisk-l command). The image file should be stored on a file system other than the file system of the data it contains to ensure that the data can be accessed in the event of a severe corruption of the file system.

To save disk space, e2Image creates image files as sparse files or in QCOW2 format. Therefore, if you need to copy a sparse image file to another location, you should compress it first, or use the GNU version of the cp "sparse=always" option. This does not apply to QCOW2 images, which are not sparse.

The size of the ext2 image file mainly depends on the size of the file system and the number of inode being used. For a typical 10GB file system, with 200000 nodes in use out of 1.2 million nodes, the image file would be about 35 megabytes; using a 4G file system with 15000 nodes out of 550000 nodes would produce an image file for 3MB. Image files are usually compressible; image files that take up 32 MB of space on disk are usually compressed to 3 or 4MB.

The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.

1. Grammar

E2image [- rsI] device image-file

2. List of options

Option

Description

-I

Restore the metadata in the file to the partition

-r

Create an image in raw format

-Q

Create an image in QCOW2 format

3. Description

1) "- I" option

The "- I" option causes e2Image to reinstall the metadata stored in the image file to the device. It can be used to restore file system metadata back to the device in an emergency. The "- I" option should be used as a desperate measure only when other options fail. If the file system changes after the creation of the image file, the data is lost. In general, you should first make a full image backup of the file system so that you can try other recovery strategies later.

2) "- r" option

The "- r" option creates a raw image file instead of a normal image file. There are two differences between the original image file and the normal image file. First, put the file system metadata in place for e2fsck, dupe2fs, debugger, and so on. You can run it directly on the original image file. To minimize the disk space consumed by the original image file, create the file as a sparse file. (note that you copy or compress / extract the file using a utility that does not know how to create a sparse file; the file will be as large as the file system itself!) Second, the original image file also includes indirect blocks and directory blocks that are not available in the standard image file, although this may change in the future.

When the file system is sent to the maintainer as part of the bug report, the original image file is sometimes used to e2fsprogs. When used in this manner, the recommended command is as follows (replace hda1 with the appropriate device): "e2image-r / dev/hda1-| bzip2 > hda1.e2i.bz2". This will send only metadata information without any data blocks. However, the file name in the directory block can still display information about the contents of the file system, and bug reporters may want to keep this information confidential. To resolve this problem, you can specify the "- s" option. This causes e2Image to scramble the directory entries and zero any unused parts of the directory block before writing to the image file. However, the "- s" option will prevent the analysis of problems related to the hash tree index directory

Note that this is possible even if you replace "/ dev/hda 1" with another original disk image or the QCOW2 image previously created by e2Image.

3) "- Q" option

The "- Q" option creates a QCOW2 image file instead of a normal or original image file. QCOW2 image contains all the information that the original image does, but unlike the original image, it is not sparse. The QCOW 2 image minimizes the amount of disk space by storing the data in a special format and packaging the data tightly together, avoiding vulnerabilities while still minimizing the size.

To send the file system to the e2fsprogs as part of the bug report, use the following commands: "e2image-Q / dev/hda1 hda1.qcow2", "bzip2-z hda1.qcow2". This will send only metadata information without any data blocks. However, the file name in the directory block can still display information about the contents of the file system, and bug reporters may want to keep this information confidential. To resolve this problem, you can specify the "- s" option. This causes e2Image to scramble the directory entries and zero any unused parts of the directory block before writing to the image file. However, the-s option will prevent the analysis of problems related to the hash tree index directory.

Note that the qcow2 image created by e2Image is a regular qcow2 image that can be processed by a tool that knows the qcow2 format, such as qemu-img.

4. Examples

Save sdb4 metadata

[root@localhost ~] # e2image / dev/sdb4 sdb4

E2image 1.41.12 (17-May-2010)

[root@localhost ~] # file sdb4

Sdb4: Linux rev 1.0 ext2 filesystem data

This is the end of the introduction to "the usage of the Linux basic command e2image". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report