Is there a faster way to restore a sparse image?

Tim asked:

I have a 20G logical volume with 5G of data which I’m backing up as a sparse image, as follows:

dd conv=sparse if=/dev/group/volume of=/mnt/backup/foo.img

This takes about 3 minutes, but restoring it from the same media takes about 25 minutes using this command:

dd if=/mnt/backup/foo.img of=/dev/group/volume

Is there a faster way to do this? Or are there some options I can fine-tune to speed it up? The backup media is formatted as ext4, but this could be changed.

My answer:

You forgot conv=sparse on the “restore” command.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.