How to restore a partimage image to a smaller drive

ext3partition

Without thinking, I made a partimage image of a ~1TB ext3 partition, which only actually contained about 2GB of data, so gzipped down to that size. I then wiped it and used it for something else.

I'd now like to delete the partimage partition, but just want to double-check what it contains before I do so. However, I don't have 1TB of spare space to work in and restore it to, and partimage itself insists on this. Is there any way to shrink the partition inside the partimage image without unzipping? Alternatively, is there a way to mount it or see what's inside?

Thanks.

Best Answer

If most of the image is properly empty (blocks of zeros), which it probably is to compress so well, you could try restore it in a virtual machine with a "not preallocated" disk. i.e.:

  1. Create a VM in VMWare or similar
  2. Install what-ever OS you need
  3. Shut down and add a new virtual disk of 1Tb+ size but do not set "allocate space now"
  4. Reboot the VM and restore your backup to that virtual drive

The virtual disk will hopefully not grow for empty blocks.

Edit: you might not have to do the "install OS" in step 2 - if you could normally run the restore operation from a bootable Live CD or USB drive then you could just boot the VM off that media (or an image of that media in a file) too.