Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to recreate file system metadata on a virtual disk. I can save this metadata using e2image, and the e2image man page tells me I can use e2image -I to restore the file system. Unfortunately, the man page doesn't provide any information on how to use this argument. I've tried the following (command results indented for easier reading):

msk $ e2image /dev/nbd1 -I test.qcow2
  e2image 1.42.5 (29-Jul-2012)
  e2image: Wrong magic number for Ext2 Image Header while trying to open test.qcow2
msk $ sudo e2image /dev/nbd1 -I test.qcow2
  e2image 1.42.5 (29-Jul-2012)
  e2image: Wrong magic number for Ext2 Image Header while trying to open test.qcow2
msk $ sudo e2image test.qcow2 -I /dev/nbd1
  e2image 1.42.5 (29-Jul-2012)
  e2image: Wrong magic number for Ext2 Image Header while trying to open /dev/nbd1

My filesystem is in fact ext4, however the man page says the following:

The e2image program will save critical ext2, ext3, or ext4

I used the following command to create the image:

sudo e2image -Q /dev/mapper/nbd0p1 test.qcow2
share|improve this question

1 Answer 1

up vote 1 down vote accepted

e2image supports three different formats; by default, it creates a "normal" custom e2image file format. With -r it creates a large sparse file with metadata at proper offsets, and with -Q it creates a qcow2 format file. (The -Q option was added somewhat recently to make large filesystem images more portable).

Although it's not at all clear from the manpage, the -I option is only valid for a "normal" e2image file format - i.e. an image created without -r or -Q.

Since you have a qcow2 image, you can use qemu-img to write it back out onto a block device:

# qemu-img convert -O raw test.qcow2 /dev/nbd1

However, you should be aware that your e2image-generated image contains metadata only, i.e. no file data at all. You'll be writing out metadata which points to various blocks on /dev/nbd1 for file data, and files will therefore contain whatever data was previously in those blocks on /dev/nbd1.

So I've told you how to do it, but please be sure it's actually what you want to do!

share|improve this answer
    
Hi, thanks a lot for your answer. I did come to this conclusion about metadata after doing some reading about file systems. And thanks for the clarification re: command-line switches. –  mkingston Sep 15 '13 at 21:10
    
In fact, for the record, file metadata is something I don't really want to keep, because I wanted to replace my files in the partition without consideration for their address on the device. So in conclusion, e2image is not really the tool I want to use. Thanks again for a clear answer, anyway. –  mkingston Sep 15 '13 at 21:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.