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 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
- Make the image looks like a disk, by making it as a loopback device.
sudo losetup /dev/loop0 disk_image.img
- Restore the backup image to the loopback device.
sudo partimage restore /dev/loop0 backup.partimage.000
- Done, now you can mount
/dev/loop0or delete the loopback device and mount the
sudo losetup -d /dev/loop0 # delete loopback device mount disk_image.img /mount/point
This was a trick which I want to share with you.