Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to generate several ext2 images. The obvious way to do that is to create an image, mount it & copy the content. But it requires root permissions twice (to chown the files and to mount the image). Also I found two tools for generating images: e2fsimage & genext2fs.

  • genext2fs places the image in RAM while generating but size of one of my images is ~30GiB.

  • e2fsimage crashes with some values of image size.

So how can I generate my images? It would be nice if the tool will calculate the image size itself.

share|improve this question
up vote 1 down vote accepted

Figured out why e2fsimage crashes. It is caused by int32 overflow when image size is greater than 4GiB. So the solution is to count required blocks & inodes, create loop file (truncate & mke2fs) and then use e2fsimage with -n argument (so it will not create the loopfile but use already created one)

share|improve this answer

Creating image does not need root privilege. Here is an example to create an ext2 image:

dd if=/dev/zero of=./MyDisk.ext2 bs=512 count=20480
mkfs.ext2 ./MyDisk.ext2

but the root privilege is needed to mount the device:

mkdir MyDisk
sudo mount ./MyDisk.ext2 MyDisk
share|improve this answer

Your Answer


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.