Path: utzoo!attcan!uunet!know!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!cmcl2!uupsi!sunic!nuug!ifi!enag From: enag@ifi.uio.no (Erik Naggum) Newsgroups: comp.unix.misc Subject: Re: Recovering corrupted tar's Message-ID: Date: 4 Oct 90 22:12:56 GMT References: <4121@neuro.med.umn.edu> Sender: enag@ifi.uio.no (Erik Naggum) Organization: Naggum Software, Oslo, Norway Lines: 34 Nntp-Posting-Host: svarte.ifi.uio.no In-Reply-To: alk@neuro.med.umn.edu's message of 4 Oct 90 01:37:52 GMT Originator: enag@svarte.ifi.uio.no In article <4121@neuro.med.umn.edu> alk@neuro.med.umn.edu (Anthony L Kimball) writes: So, anyone have a handy-dandy tool to patch a tar archive which has had it's leading N blocks overwritten? I do so hate to do this by hand. The files occupying the first n blocks are lost, where n >= N. The problem is to find the value of n. If you know N, you can scan from there for the tar file start block. It contains the filename from byte 0 in the block, up to 100 characters, nul-padded, then some decimal numbers, with space and nul characters interspersed, then a bunch of nul characters to pad out the block. This should suffice to describe the block if you look for it in, e.g. od dumps or in an emacs buffer. When you know the offset into the file, you have the value of n. Then it's a simple matter of doing: dd if= skip= | tar tvf - Works like a charm. It may take a while to find the first block of the first complete file, though. Searching programs shouldn't be that hard to write, either, but I don't think anybody has done this, yet. There is no redundancy in tar files, so if you lose a block, it's gone. Hope this helps. -- [Erik Naggum] Naggum Software; Gaustadalleen 21; 0371 OSLO; NORWAY I disclaim, , therefore I post. +47-295-8622, +47-256-7822, (fax) +47-260-4427