2

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.

Andrew Ferrier
  • 864
  • 9
  • 21

3 Answers3

3

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.

David Spillett
  • 22,534
  • 42
  • 66
  • Good idea - this sounds like it could well work. I'll give it a go, probably with VirtualBox or similar, and feed back how well it works. – Andrew Ferrier Jul 28 '09 at 23:15
  • I'm sure VBox should the same as VMWare for the above. Just make sure you use its equivalent of VMWares "growable" option for the big virtual disk. – David Spillett Jul 29 '09 at 08:22
  • Thanks for the suggestion. This worked perfectly in the end. The only slight caveat is that you have to create a partition of the right size (or larger, but that doesn't matter since it's not all really allocated on disk anyway), before you start the partimage restore. This is in the partimage manual - it just hadn't occurred to me. Also, you must not select "Erase empty blocks" in partimage when you restore, or your virtualisation (VirtualBox in my case) will end up allocating the entire disk. – Andrew Ferrier Jul 29 '09 at 20:39
2

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?

Loose Cannon
  • 111
  • 2
  • 4
-1

I believe you can mount the image as though it were an .iso. You will need to unzip it first or there may be a way to mount it zipped... google is your friend.

I found this command with the keywords "mount iso ubuntu" in google.

sudo mount debianetch.iso /media/isoimage/ -t iso9660 -o loop

Chris Nava
  • 1,147
  • 1
  • 7
  • 9
  • Unfortunately I don't think this will work. A partimage image is not an iso. I did have a look before, but I couldn't find any way of mounting one. – Andrew Ferrier Jul 28 '09 at 23:17
  • My own attempts at "mounting" a partimage file involved creating a loop device pointing at a blockfile and using partimage restore, then mounting *that*. – Andrew Oct 15 '10 at 03:48