PDA

View Full Version : Clonezilla and kpartx/losetup


tlu
November 15th, 2009, 08:20 AM
One disadvantage of Clonezilla is that you can't restore specific files/directory from the image (as far as I know). The tool kpartx should overcome this problem: It should be possible to mount the image file as a device. So it would be easy to, e.g., copy specific files back to your HD.

The basics can be found on http://equivocation.org/node/107 . Let's say you have an image file called image.img on an external USB disk.

In order to list the partitions in that image file you would execute

sudo kpartx -l /media/disk/image.img

In order to find the next available loopback device execute

sudo losetup -f

and you'll probably get /dev/loop0

With

sudo losetup /dev/loop0 /media/disk/image.img

the device /dev/loop0 is mapped to the image file. The following steps (how to mount this device) can be found in the link above.

The problem: Neither the first nor the third step work on my system. My image is called 2009-10-01-14-img.

sudo kpartx -l /media/disk/2009-10-01-14-img

results in

-{ Quote: "Missing major number for persistent device.
Couldn't create ioctl argument.
Missing major number for persistent device.
Couldn't create ioctl argument.
last_lba(): I don't know how to handle files with mode 41ed
read error, sector 0
read error, sector 1
read error, sector 29
Missing major number for persistent device.
Couldn't create ioctl argument." }-
and

sudo losetup /dev/loop0 /media/disk/2009-10-01-14-img

results in

-{ Quote: "media/disk/2009-10-01-14-img: Is a directory" }-
But Clonezilla always saves an image as a directory and not as a file, doesn't it? So how can I use kpartx and losetup if they expect a single file?

I might be missing something very easy and obvious. Any idea?

Pedro
November 15th, 2009, 09:01 AM
Forgive my lack of insight, as i never tried to accomplish this. I don't even remember how it saves the partitions, since it uses different utilities for different formats.
I imaged my disk way back when, and back up only files. I never wanted or needed to go back to an earlier image. ???

But aren't you able to mount it using standard linux utils? What partition is it? NTFS, Ext3, or? If it's saving to different files per partition, it may be just like mounting an iso file no?

tlu
November 15th, 2009, 09:22 AM
-{ Quote: "
But aren't you able to mount it using standard linux utils? What partition is it? NTFS, Ext3, or? If it's saving to different files per partition, it may be just like mounting an iso file no?" }-
Pedro,

the USB disk is ext3 formatted. But that's not the problem. The mentioned image directory itself is 34 GB large and contains 19 files (among others) img.gz.ax (with x ranging from a ... q), most of them 2 GiB large. So in order to copy a specific file back to my HD, I would have to extract at least some of these img files (as I don't know which one contains it) and mount them with losetup/kpartx. Very laborious ;) I had hoped for an easier way how to do it.

By the way: I don't need it right now - I just want to be prepared for the case when I might need it.

Mrkvonic
November 15th, 2009, 02:43 PM
I usually backup root only with imaging software and data (/home) with rsync. It's easier that way, in my opinion. Plus, works in all modes, live, booted, installed, whatever.
Mrk

tlu
November 16th, 2009, 09:23 AM
-{ Quote: "I usually backup root only with imaging software and data (/home) with rsync. It's easier that way, in my opinion. Plus, works in all modes, live, booted, installed, whatever.
Mrk" }-

Yes, that's probably the best way. I'm also using rsync for /home but was interested in an alternative.