How do I restore a partimage image to a smaller drive?

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.


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.


The best way to do this is to combine the instructions found here:

http://www.coolacid.net/20080908134/Latest/restore-a-partimage-backup-to-loopback (make sure you read the comments on this page as step 3 has been updated)

with the instructions found here:

http://cptl.org/wp/index.php/2010/04/29/resizing-a-linux-disk-image-file/

Step by step:

  1. Create a Linux Disk Image file as instructed by link #1 large enough that partimage will allow you to restore your partimage backup to it.
  2. Restore your partimage file to the new linux disk image file created by step 1.
  3. Follow the instructions in link #2, create a new Linux Disk Image to contain the partition that is the final target size you'd like.
  4. Copy all the data from the mounted partimage linux disk device partition created in step 2 to the new filesystem on the partition created in step 3.
  5. Use partimage to make a backup of the data on the disk partition created in step 4, so that you end up with a partimage back up of the partition that you can restore back to your disk.

I am currently going to attempt this process to restore a partimage to a raid 1 exported disk as a solution to my own question here:

3WARE 9650-4LPML JBOD DISK to RAID - 1 Mirror Migration How To?