Clonezilla and kpartx/losetup

Discussion in 'all things UNIX' started by tlu, Nov 15, 2009.

Thread Status:
Not open for further replies.
  1. tlu

    tlu Guest

    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 . 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


    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


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

    results in

    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?
  2. Pedro

    Pedro Registered Member

    Nov 2, 2006
    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. o_O

    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?
  3. tlu

    tlu Guest


    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) (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.
  4. Mrkvonic

    Mrkvonic Linux Systems Expert

    May 9, 2005
    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.
  5. tlu

    tlu Guest

    Yes, that's probably the best way. I'm also using rsync for /home but was interested in an alternative.
Thread Status:
Not open for further replies.