DeutschEnglish

Submenu

 - - - By CrazyStat - - -

14. May 2012

Mount clonezilla image to restore single file (browse)

Filed under: Linux,Windows — Tags: , , , , , , , , , , — Christopher Kramer @ 12:28

Clonezilla is a fine tool to backup/restore/clone partitions or drives. It is very powerful, can handle both Linux and Windows partitions and so on. If you do not know it, you should really give it a try. It is really free software (open source), which means it is also free to use for commercial purposes.

By the way, if you want to backup/restore images of Windows partitions/drives, I’d also recommend DriveImage XML which is also very powerful yet simple (only free for private use). Windows 7 has also built-in backup and imaging tools, which you can give a try. But this post is about Clonezilla.

One important feature that Clonezilla does not offer out of the box is browsing images to restore single files. You can only restore complete partitions or drives.

But there is a way around this, which is discussed in this forum thread, although not perfect as it requires lots of time and disk space as well.

The basic approach is to convert the whole image into a (probably huge) img-file that can be easily mounted. In the forum post linked above several different commands are discussed depending on your image file.
Here I’d like to show you what worked for me.

In my case, the file was compressed using gzip and it was an image of a linux partition (ext3). I used Ubuntu Linux to mount the image. The steps I took:

  1. Install partclone (sudo apt-get install partclone)
  2. Prepare an img-file somewhere where enough free disk space is available:
    touch /dir-to-new-image/partition.img

    You should have at least as much free disk space as the size of the image there.

  3. Convert the clonezilla-image into the img-file:
    sudo cat /dir-to-images/partition.ext3.ptcl-img.gz.*
    | sudo gzip -d -c
    | sudo partclone.restore -C -s - -O /dir-to-new-image/partition.img

    (This is one line. Note the minus after -s. I overlooked it when I tried this first.)
    This will take some time, dependent on how big the image and how fast your drive(s).
    There are other commands in the forum thread for NTFS images and other compression formats.

  4. Mount the img-file:
    sudo mount -o loop -t ext3 /dir-to-new-image/partition.img /mnt

Thanks a lot to all posters of the forum mentioned above for these hints, especially bfitzhugh, nutria007, ttguy and gaebriel!

P.S.: It’s always good to have a (recent) backup 😉 One drive of mine just crashed after about two years in operation, so I know what I am talking about…

Think about what pain it would be if the drive of your laptop / desktop would crash just right now. If you get a bad feeling thinking about this, you should make a backup now.

Recommendation

Try my Open Source PHP visitor analytics script CrazyStat.

13 Comments »

  1. Thanks for the quick HowTo!

    Imaged my server a while ago before a reinstall but forgot it was unbrowsable -_-‘

    This should do the trick, thanks!

    Comment by Souheil — 21. September 2012 @ 00:56

  2. Hi,

    I have tried your procedure and had an error while mounti the image:

    $ sudo mount -t ext4 /mydir/myimage.img /mnt/backup
    mount: wrong fs type, bad option, bad superblock on /mydir/myimage.img,
    missing codepage or helper program, or other error
    In some cases useful info is found in syslog – try
    dmesg | tail or so

    In dmesg have finded the problem:

    EXT4-fs (loop0): bad geometry: block count 28304104 exceeds size of device (28303360 blocks)

    Googling for two evenings finaly find a solution on: http://www.linuxquestions.org/questions/linux-general-1/cannot-mount-hard-disk-block-count-exceeds-size-of-device-bad-partition-table-880149/

    Solved simply with:
    fsck.ext4 -f /mydir/myimage.img
    before mount

    Hope this help someone
    regards

    Comment by Paolo — 16. November 2012 @ 22:35

  3. Thanks much for your post. It was partly responsible for my solving the problem I had. In fact, this procedure worked on an image that was made from a machine which was partitioned with the Ext3 file system. However, it failed when I tried mounting an image made from an Ext4 partition – the final image, when mounted via furius ISO mount, showed a blank file browser window, and showed a mount error when mounting is attempted from the terminal. Consequently, after much trial and error, I went looking for a solution, and found it here: http://blog.thewulph.com/?p=232

    The commands for merging and decompressing the file/s is good. However, partclone.restore is not the best command to to use in making the mountable image.

    Instead, the following will create a mountable image of clonezilla images which are created from Ext3/Ext4 file systems:
    sudo partclone.extfs -r -s /source_path/file_name-img -o /output_path/file_name.img –restore_row_file

    One line can be used by exploiting the pipe command:
    cat /source_path/file_name.gz.* | gzip -d -c | partclone.extfs -r -s – -o /output_path/file_name.img –restore_row_file

    Thats it! Hope it is clear enough to help someone.

    Comment by Donovon — 22. November 2012 @ 07:19

  4. Please note that the –restore_row_file, as mentioned in the above, is a double dash (- – without the space). Additionally, you can now mount the final image by using the furius ISO mount software, or via the terminal with the following:
    sudo mount -o loop /dir_to_image/file_name.img /mnt/optional_subdir_name/

    Comment by Donovon — 22. November 2012 @ 07:31

  5. Thanks, made my day!

    Comment by SyBorg — 23. January 2013 @ 08:37

  6. I’m on Ubuntu and it kept complaining about my sudo password being wrong. Then, in the linked article, I noticed some people just use sudo for the last command (partclone), not for cat nor gzip.

    What I did was to: sudo ls (this asks for password), and then I entered the command you show. Since sudo remembers the password for a minute, it worked fine without asking for the password again.

    It took 25 minutes for a 56 GB drive image.

    Comment by Fun — 13. April 2013 @ 01:44

  7. @Donovon

    YOU CRAZY GUY! Thanks I tried a long time but the trick was using partclone.extfs!! Thanks dude!

    Regards
    Jogi

    Comment by Jogi — 28. September 2013 @ 20:42

  8. I’ve made a video that explains how to operate (explore) the clonezilla image by restoring it to a virtual machine.
    Pretty simple, fast and easy:

    Comment by Pedro — 5. November 2013 @ 23:49

  9. @ Pedro: The idea of restoring it to a virtual machine is great! That’s probably one of the easiest ways that can be even easily done by the usual windows user 😉
    I wonder why nobody had this idea before…

    Comment by Christopher Kramer — 6. November 2013 @ 00:11

  10. […] […]

    Pingback by Umzug auf Linux - welche Backup Methode? - Linux: Linux-Forum — 15. June 2014 @ 01:12

  11. How to restore single file in windows OS?

    Comment by Rudianto — 27. October 2014 @ 05:26

  12. @ Pedro, smart portuguese guy 😉

    Comment by jppataki — 19. February 2015 @ 21:07

  13. […] http://blog.christosoft.de/2012/05/mount-clonezilla-image-to-restore-single-file-browse/ […]

    Pingback by partclone restore exit error - dinohensen.nl — 6. December 2015 @ 19:44

RSS feed for comments on this post. TrackBack URL

Leave a comment

%d bloggers like this: