1

My hard drive seems to be failing and I suspect some data may be already damaged, so I decided to make an entire drive backup with Clonezilla using dd. I have chosen bzip2 compression to fit entire 750 GB drive on a 500 GB one. The image is split into 4000 MB chunks.

Right now I'm working off a portable drive and I don't want to put too much strain on the dying drive. I want to recover some files onto that portable drive from the Clonezilla image I've made. My idea is to mount the compressed image so I can copy required files off it.

I already know how to access compressed image without extracting it first (AVFS), so I just need to mount the dd image. The problem is I have no extra space available, as the smaller drive is almost full (7 GB free), so cat-ing archive chunks together is not an option.

Is there any way to cat archive chunks on the fly, so I can mount the image that's inside the archive? I have found this solution, but I guess AVFS will need to seek the file. Or maybe there's some simplier solution?

  • 2
    Next time, use a qcow2 compressed image (with qemu-img convert -c -O qcow2) instead of a split bzip2ed raw image. – Stéphane Chazelas Nov 30 '13 at 15:37
  • qcow2 is actually a really cool idea. You might even be able to pull it off with 7GB free space and 4GB chunks, for the in place conversion of bzip2 to qcow2. If their compression rate is similar... – frostschutz Nov 30 '13 at 16:09
3

What you're asking for is not trivial. It's possible, I just don't know an existing implementation of the solution you need. AVFS probably won't work.

There is seek-bzip ( https://github.com/cscott/seek-bzip ) and similar projects which attempt to provide random block access to bzip2 archives. Creating the table for that will take about as long as uncompressing the entire thing; actual I/O will require the correct block to be found, uncompressed and held in memory, and if it's needed again later on, uncompressed again. I currently do not know of any way to employ that solution to your problem directly, though.

To my knowledge there also isn't any program that would take a filesystem image in a pipe (not seekable) and extract files out of it.

You'd have to implement this in NBD, fuse, or similar. AVFS goes in that direction, but it does not mention seekability of bzip2 files. If it does not employ this technology (and the source code doesn't look like it), it will work for smallish files only or for application that read the entire thing linear (such as cp or tar would). Any random access I/O (such as you have with a mounted filesystem image) would get you out of memory or the access would be so slow it's completely unusable (i.e. it would extract 450GB of data for a 4k read at the end of the disk).

There's cloop but it's not widely available (Knoppix only?) and it'd require you to convert your existing bz2 image to the cloop format first. If you do the conversion in-place and it fails, your image is gone.

Sometimes, buying a larger HDD is the preferable solution.

  • Thanks for detailed answer, I appreciate it. I'm going to RMA this disk and I just want to temporarily backup it for later restoration and have access to my files until I get a new one; if I were to buy a new disk I'd just clone the old one directly. Do you think that qcow2 conversion would be possible if I had, say, 70 GB of free space? – gronostaj Nov 30 '13 at 17:21
  • Might work. Have a care with the exact method, as you still have the risk of losing the image, if something goes wrong. I don't have time right now to experiment with it, but I'll be happy to do so next week if you can't figure it out by then (and remind me). – frostschutz Nov 30 '13 at 17:42
0

Well, first of all you need to put all the chunks into one file.

Afterwards you will be able to mount this "total" image through a loop device without.

Here's an example for doing so with use of gzip - you simply may apply it to the use of bzip :

So Clonezilla uses partclone you may find additional info on project's website too :

  • I've googled that already, but it doesn't solve my problem. I want to extract single files without restoring entire drive or partition and without permanently cat-ing chunks, because I have only 6-7 GB of disk space available. Also, I have chosen dd mode instead of partclone. Please read my question more carefully. – gronostaj Nov 30 '13 at 14:40
  • dd/bzip/gzip that doesn't matter you always mount these type of images via the loop-device, so you are able to restore single files from within. BUT you need to combine the cunks. – domi27 Nov 30 '13 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.