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

    and

    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

    Joined:
    Nov 2, 2006
    Posts:
    3,502
    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

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

    Mrkvonic Linux Systems Expert

    Joined:
    May 9, 2005
    Posts:
    10,213
    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
     
  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.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.