Restore a partimage to a smaller disk
Sometimes; when working with partimage
, someone can create a backup of a 1TB
partition which contains -for example- only 10GB of data; in this case, when
we want to restore it, partimage
will fail if the restore disk does not have
enough space (1TB in this case).
I faced this problem and here the trick I used to restore the backup image to a smaller disk image.
Create an image file
Create an image file with the right size (with seek
, we don't need to actually have the whole space):
# Make sure that the seek=[SIZE] is sufficient
dd if=/dev/zero of=disk_image.img bs=1 count=1 seek=1TB
Use image file as loopback
Make the image looks like a disk, by making it as a loopback device.
sudo losetup /dev/loop0 disk_image.img
Restore!
Restore the backup image to the loopback device.
sudo partimage restore /dev/loop0 backup.partimage.000
Done!
Done, now you can mount /dev/loop0
or delete the loopback device and mount the `disk_image.img` directly!
sudo losetup -d /dev/loop0 # delete loopback device
mount disk_image.img /mount/point
This was a trick that I want to share!