Saturday, August 6, 2011

Clonezilla Live: Relocating a Partition

When my old Dev desktop machine slowly died, mostly I had reinstalled the software I needed to my laptop, but there were a few legacy products with complex and touchy configurations that I really would rather not have to deal with again. The easiest way around this was to restore the image I had of its OS partition to a VM, for occasional use in maintaining these legacy apps.
I had used Clonezilla Live to create the images, and duly fired up a VM, created a virtual disk, booted off the CDROM and attempted to recover the image to the new virtual disk.
It turns out that Clonezilla is a little fussy about where it restores its images to: it won't by default restore them to a partition other the one it backed up from.
For example, it backed up from IDE drive C: (/dev/hda1), but all new SATA drives and virtual disks have the first partition at /dev/sda1.
No problem; when clonezilla detects this it automatically tries to rewrite the image to a new temporary image to suit the new location. Unfortunately, this attempt fails when it runs out of memory and the restore is aborted (33Gb image).

Not being a *nix guy, I emailed Spiros Georgaras, the creator of the Clonezilla-SysRescCD, who seemed to be one of the only people out there writing helpful HOWTOs on the topic of Clonezilla.
I'm posting his reply here to help other folks who got to this particular dead end.

> [ME]
> You say in the docs:
> Recent versions of *Clonezilla Live* partly support restoring to a different location, so the *reloc-img*
> script is obsolete, and has been removed. *Clonezilla Live* now supports:
>     * Relocation of a disk image (restoring a whole disk)
>     * Relocation of a partition image (restoring a partition)
> I'm trying to do just this (relocate a partition image), and Clonezilla Live keeps trying to make a temp copy and failing.
> It appears to be trying to copy to /tmp, but I'm not sure where that's mounted to.

/tmp is mounted as tmpfs which means it's like a RAM-disk. If there's not enough memory, this could be a reason for the failures you're facing. If this is the case you could stop Clonezilla program (exit to command prompt), and
sudo su -
umount /tmp
mount /dev/sdxY /tmp
where /dev/sdxY is an existing linux partition on any of your hard disks (not the one containing your image file) Then try to run CLonezilla again

Thanks Spiros !