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.

17 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:
    http://www.youtube.com/watch?v=ainjV3X6wqQ

    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. […] https://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

  14. Hi,

    I got an error “EXT4-fs (loop0): bad geometry: block count…” instead of successfull mounting – a simple resize2fs ./sdb2_restore.img solved my problem

    Greetz

    Comment by Christoph — 22. June 2017 @ 09:20

  15. If you receive an error like:

    Partclone v0.2.70 http://partclone.org
    Starting to restore image (-) to device (partclone-restore.img)
    device (partclone-restore.img) is mounted at
    error exit

    For ntfs use:
    sudo cat /dir-to-images/sdb1.ntfs-ptcl-img.gz.* | sudo gzip -d -c | sudo partclone.ntfs -C -r -W -s – -O /dir-to-new-image/hda1.img

    For ext4 use:
    sudo cat /dir-to-images/sdb1.ext4-ptcl-img.gz.* | sudo gzip -d -c | sudo partclone.ext4 -C -r -W -s – -O /dir-to-new-image/hda1.img

    See https://askubuntu.com/questions/453114/restoring-clonezilla-images-cat-gzip-partclone-not-working

    Comment by Rusto — 6. August 2019 @ 00:22

  16. For some reason, step 3 was giving the following error:

    Partclone v0.3.13 http://partclone.org
    Starting to restore image (-) to device (/mnt/o/IMB_IMG/IMB_Laptop.img)
    $: command not found

    gzip: stdin: unexpected end of file
    read image_hdr error=0
    Partclone fail, please check /var/log/partclone.log !

    It seemed to me that the error was maybe files being accessed out of order by cat, so I went to the comments here (http //ubuntuforums.org/showthread.php?t=872832) and saw how to cat in order, The resulting command was this:

    sudo cat sda2.ntfs-ptcl-img.gz.aa sda2.ntfs-ptcl-img.gz.ab sda2.ntfs-ptcl-img.gz.ac sda2.ntfs-ptcl-img.gz.ad sda2.ntfs-ptcl-img.gz.ae sda2.ntfs-ptcl-img.gz.af sda2.ntfs-ptcl-img.gz.ag sda2.ntfs-ptcl-img.gz.ah sda2.ntfs-ptcl-img.gz.ai sda2.ntfs-ptcl-img.gz.aj sda2.ntfs-ptcl-img.gz.ak sda2.ntfs-ptcl-img.gz.al sda2.ntfs-ptcl-img.gz.am | sudo gzip -d -c | sudo partclone.restore -C -s – -O /mnt/o/Laptop.img

    Hope this helps anyone with that error.

    Comment by Leonidas — 26. January 2022 @ 04:02

  17. […] first I tried this tutorial to open my image which creates an img-for me but I cannot mount this file. Later I used this […]

    Pingback by Partclone broken image restore - Boot Panic — 5. February 2022 @ 15:29

RSS feed for comments on this post. TrackBack URL

Leave a comment