The officially official Devuan Forum!

You are not logged in.

#1 2023-09-01 22:07:23

Registered: 2022-07-14
Posts: 126  

e2image - image created as sparse file and is mountable

I stumbled upon … browse-res , which is awesome!

e2image can be used to create an image of an ext4 file system, while only copying sectors which are in use:

e2image -ra /dev/sda1 /path/to/file.img

file.img will be created as a sparse file, so it will only occupy the space which is really used in the file system, even though its apparent size will reflect the capacity of the file system. It can be mounted directly, like any file system image:

This will save a massive amount of time when making a backup image and it's mountable. Excellent!
One question remains: How can the sparse file "trick" ls?

Since more than a decade I was happily doing:

su -
mount /dev/sda1 /mnt
cat /dev/zero>/mnt/null.dat    # until "no space left on device"
rm /mnt/null.dat
umount /dev/sda1
cat /dev/sda1 | gzip >sda1.img.gz

The image-archive sda1.img.gz has a size of about half the partition's effective data-content, but is not mountable of course.


Board footer