On Tue, Oct 19, 2004 at 12:59:42AM +0200, Wesley W. Terpstra wrote:
> To which, I say, wtf!

You're using it wrong.

> ... and yet par2 tells me I need 1909 more (I have 101).
> That means I would need 18* more information in order to recover foo.pdf!
> I have to admit, I am surprised by this. I would have expected a better
> ratio, even with very old techniques.

First off, I'm going to use PAR, since it's much simpler and in many
cases a better choice than par2.  (Par2 allows recovering files which
have internal corruption, which is useful for completing almost-complete
Bittorrented files.)

You need to split files separately for PAR to work as you want.  This
is done just about everywhere on Usenet binary groups these days.  I'm
going to use split(1); people on Usenet, unfortunately, have a habit
of using RAR.

Let's create a 16-meg file:

07:27pm [EMAIL PROTECTED]/11 [~/z] dd if=/dev/urandom of=testing bs=1048576 
count=16
16+0 records in
16+0 records out

Split it into parts, not necessarily of even size:

07:29pm [EMAIL PROTECTED]/11 [~/z] split -b 1000000 testing testing.part.
07:29pm [EMAIL PROTECTED]/11 [~/z] ls -l
total 32824
-rw-r--r--  1 glenn users 16777216 Oct 18 19:28 testing
-rw-r--r--  1 glenn users  1000000 Oct 18 19:29 testing.part.aa
-rw-r--r--  1 glenn users  1000000 Oct 18 19:29 testing.part.ab
-rw-r--r--  1 glenn users  1000000 Oct 18 19:29 testing.part.ac
-rw-r--r--  1 glenn users  1000000 Oct 18 19:29 testing.part.ad
-rw-r--r--  1 glenn users  1000000 Oct 18 19:29 testing.part.ae
-rw-r--r--  1 glenn users  1000000 Oct 18 19:29 testing.part.af
-rw-r--r--  1 glenn users  1000000 Oct 18 19:29 testing.part.ag
-rw-r--r--  1 glenn users  1000000 Oct 18 19:29 testing.part.ah
-rw-r--r--  1 glenn users  1000000 Oct 18 19:29 testing.part.ai
-rw-r--r--  1 glenn users  1000000 Oct 18 19:29 testing.part.aj
-rw-r--r--  1 glenn users  1000000 Oct 18 19:29 testing.part.ak
-rw-r--r--  1 glenn users  1000000 Oct 18 19:29 testing.part.al
-rw-r--r--  1 glenn users  1000000 Oct 18 19:29 testing.part.am
-rw-r--r--  1 glenn users  1000000 Oct 18 19:29 testing.part.an
-rw-r--r--  1 glenn users  1000000 Oct 18 19:29 testing.part.ao
-rw-r--r--  1 glenn users  1000000 Oct 18 19:29 testing.part.ap
-rw-r--r--  1 glenn users   777216 Oct 18 19:29 testing.part.aq

and then:

07:31pm [EMAIL PROTECTED]/11 [~/z] parchive a -n 5 testing.par testing.part.*
...
07:32pm [EMAIL PROTECTED]/11 [~/z] ls -l testing.p??
-rw-r--r--  1 glenn users 1001558 Oct 18 19:32 testing.p01
-rw-r--r--  1 glenn users 1001558 Oct 18 19:32 testing.p02
-rw-r--r--  1 glenn users 1001558 Oct 18 19:32 testing.p03
-rw-r--r--  1 glenn users 1001558 Oct 18 19:32 testing.p04
-rw-r--r--  1 glenn users 1001558 Oct 18 19:32 testing.p05
-rw-r--r--  1 glenn users    1558 Oct 18 19:32 testing.par

Now all I need is enough parts:

07:32pm [EMAIL PROTECTED]/11 [~/z] mkdir partial
07:32pm [EMAIL PROTECTED]/11 [~/z] cp testing.part.* partial/
07:33pm [EMAIL PROTECTED]/11 [~/z] rm partial/testing.part.ah
07:33pm [EMAIL PROTECTED]/11 [~/z] du partial
16444   partial
07:33pm [EMAIL PROTECTED]/11 [~/z] cp testing.p02 partial/

and recover:

07:33pm [EMAIL PROTECTED]/11 [~/z/partial] parchive r testing.p02
Checking testing.p02
  testing.part.aa                          - OK
  testing.part.ab                          - OK
  testing.part.ac                          - OK
  testing.part.ad                          - OK
  testing.part.ae                          - OK
  testing.part.af                          - OK
  testing.part.ag                          - OK
  testing.part.ah                          - NOT FOUND
  testing.part.ai                          - OK
  testing.part.aj                          - OK
  testing.part.ak                          - OK
  testing.part.al                          - OK
  testing.part.am                          - OK
  testing.part.an                          - OK
  testing.part.ao                          - OK
  testing.part.ap                          - OK
  testing.part.aq                          - OK

Restoring:
0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
  testing.part.ah                          - RECOVERED

and join:

07:33pm [EMAIL PROTECTED]/11 [~/z/partial] cat testing.part.* > testing
07:34pm [EMAIL PROTECTED]/11 [~/z/partial] diff testing ../testing
07:34pm [EMAIL PROTECTED]/11 [~/z/partial]

Alternatively, I can work exclusively with PAR files (though there's rarely
any reason to do this), by creating enough PARs so their sum is large enough
to recreate the file:

07:35pm [EMAIL PROTECTED]/11 [~/z] parchive a -n 20 testing.par testing.part.*
07:35pm [EMAIL PROTECTED]/11 [~/z] mkdir testing2
07:36pm [EMAIL PROTECTED]/11 [~/z] cp testing.p?? testing2

07:36pm [EMAIL PROTECTED]/11 [~/z/testing2] parchive r testing.p13
07:36pm [EMAIL PROTECTED]/11 [~/z/testing2] cat testing.part.* > testing
07:37pm [EMAIL PROTECTED]/11 [~/z/testing2] diff testing ../testing
07:37pm [EMAIL PROTECTED]/11 [~/z/testing2]

This is exactly what you describe.

-- 
Glenn Maynard


Reply via email to