Home : Linux :

Archiving

Reorganization has reduced this to RAR and PAR2 topics. I use them primarily on archives that I download from Usenet. Command line usage and KDE shortcuts are covered. See also: KDE (Ark and .war) and NNTP

PAR and PAR2

PAR and PAR2"The original idea behind this project was to provide a tool to apply the data-recovery capability concepts of RAID-like systems...". See AboutPAR2 for the advantages of PAR2 over PAR. PAR2 is commonly used to repair busted RAR archives.

Sep '07: Image is a way to create a shortcut using KDE's 'link to application' (right-click > Create New) to do single click repairs. I created it in my download directory (naming it '0 par2 repair' keeps it handy, it can be put anywhere, had on my desktop initially) so I don't have to go to my temp/repair directory until its repaired and ready to extract (no back and forth if I need a few more parts). The only drawback is that you either always need the lower case .par2 file or you need to create another link using 'par2 r *.PAR2 *' (call it '0 PAR2 repair'). While I see no need, there is a par2 GUI called gpar2.

Feb '07: There is an RPM for Mandriva 2007 (thanks to the lousy package manager I don't know if its in the stock distribution or contrib). Otherwise you may need to build this one from sources and you will need a C++ compiler (in addition to gcc).

Aug '06: If it doesn't compile, open reedsolomon.cpp and replace all (6) instances of "bool ReedSolomon" with "template <> bool ReedSolomon". Solution is courtesy of VenimK's rather cryptic post.

Repairing a rar archive from directory with rars, par2's and partials ("extra files"):

   [foo@bar foo]$ par2repair *.par2 *
or
   [foo@bar foo]$ par2 r *.par2 *

Repair an archive using any available .par2 (*.par2) files and any available "extra files" (*, i.e. partial/incomplete and otherwise busted rars). The latter is the whole point of par2 over par (cmd line references that don't include 'extra files' are wrong and wasteful). Less recovery data is needed because partial/busted rars can be recovered/fixed. It is case sensitive so you may need to use *.PAR2 *. If the directory you are in has subdirectories (or you have multiple archives in the current directory) you need be more specific than '*' for extra/incomplete files/rars, e.g. something like par2 r *.PAR2 *.rar.* (my incompletes are filename plus a .nn-nn extension where nn-nn is part numbers, e.g. rar.01-16 and rar.18-36 filenames when part 17 is missing). I have a temp directory (for repairing/extracting) below my download directory to avoid that (KISS).

Using 'par2 r' on split files will join them, e.g. foo.avi.001, foo.avi.002, etc. will become foo.avi after being 'repaired' (because the syntax is the same as for a repair, you will need a par2 file even if all the parts are fine)

Creation of par2 files in a directory containing just the rar files you want to create par2 files for:

   [foo@bar foo]$ par2create -r5 prefix

Create enough par2 files to repair up to 5% (-rn) damaged/missing data. Par2 files will be named prefix.volnnn+nn.par2.

Can be par2repair/par2create/par2verify or par2 r/par2 c/par2 v. See

   [foo@bar foo]$ par2

for more options.

See also:
"PyPar2 is a graphical frontend for the Linux par2 utility. It is written in Python and uses GTK through the PyGTK library. Of course, it is open source (GPL)."
[ comment | link | top ]

RAR and unrar

RAR and unrar"Linux CLI tool to process RAR files. While you probably won't find it on the distribution CD/DVD, you can usually find a package (e.g. PLF has one for Mandriva). IIRC installation from sources is is easy as 'make' (as root).

Oct '07: Both rar and unrar packages are in the PCLOS repository. I finally figured out that the right click 'extract to' is attached to unrar. You can extract rar archives with ARK and rar but you won't get the 'extract to' unless you have unrar installed... It may depend on the distribution, I believe rar has more IP restriction than unrar (why they may not be packaged together).

The main reason for the update is that I applied my PAR2 trick to unrar. The image (click to enlarge) shows how to create a shortcut using KDE's 'link to application' (right-click > Create New) to do a single click extraction of all archives in a directory of your choice while placing the extracted files in another directory of your choice. The shortcut can be placed anywhere and the paths can be to any mounted filesystem.

--

I haven't tried Ark for creating an archive but it unpacks rar archives just fine. KDE/Konqueror/Ark support has gotten to the point that you can right click (on any file/part of the archive) and 'extract to/here' in most instances (i.e. very few instances where you will have to 'open with Ark').

...Since I'm using the CLI for par2 I may as well use it for unrar as well.

04-Jun-2008: It looks like I may have misunderstood the extract switches (was using e) and inadvertently discovered the value of quoting (more than allowing paths with spaces).

The extract switch can be "e" or "x". "e" acts like the unzip "j" switch - all files are extracted to the current directory, any directory paths in the archive are junked/ignored... or created, but empty.

Using quotes, the following will work with the most common rar archive naming conventions and will extract all archives in the current directory.

   [foo@bar foo]$ unrar x "*.rar"

If you want to extract to another directory use

   [foo@bar foo]$ unrar x "*.rar" "/extract to"

If you want to extract a specific archive, you'll need to provide a bit more information and the different naming conventions will come into play (quoting also becomes optional). We need to point unrar to the first part of the archive - foo.rar, foo.part01.rar or foo.001.

   [foo@bar foo]$ unrar x *01.rar
   [foo@bar foo]$ unrar x "*some thing.rar"
   [foo@bar foo]$ unrar x *something.001
   [foo@bar foo]$ unrar x full_name.part01.rar

Something I don't think you can do with Ark is a partial extraction.

   [foo@bar foo]$ unrar x -kb "*.rar"

Keep broken/incomplete files (-kb), e.g. to preview a large file by extracting the first rar of a set.

Create a rar archive of files (credit)

   $ rar a archive.rar dir/ (put files in dir container)
   $ rar a archive.rar file1.ext file2.ext file3.ext (list of files)
   $ rar a archive.rar *.* (wildcard, files in current directory)

Break a large file into 14.6MB archives (credit)

   $ rar a -v15000k big_file.ext (.partnn)
   $ rar a -v15000k -vn big_file.ext (.rar and .rnn)

Unrar exit codes ($?): 0 = successful extraction, 1 = no files to extract, 3 = broken
[ comment | link | top ]

Back to: Linux