# replace bzip2 with pbzip2



## overmind (May 16, 2011)

Hi,

I've noticed *bzip2* does not scale (on Quad Core I have less than 1.0 load when archiving a big file with *bzip2*).

With *pbzip2* I can speed up the archiving process x3 times.

Is ok to move *bzip2* from /usr/bin/bzip2 and then create a symlink to *pbzip2* ?

That would be something like this:

```
mv /usr/bin/bzip2 /usr/bin/bzip2.old
ln -s /usr/local/bin/pbzip2 /usr/bin/bzip2
```

I want that my tar utility to use *bpzip2* instead of *bzip2*. I want to know if I break anything by using that method or if is there other approach other than the one with pipes.

The one with pipes would be:

```
tar cf - . | pbzip2 > ../file.tbz
```

or:


```
tar --use-compress-prog=pbzip2 -cf file.tbz .
```


----------



## mix_room (May 16, 2011)

In your first example I don't see why you would need the symlink nor in the second case. 

Why don't you just leave bzip2 in place, thus reducing the chances of getting other weird behaviour, and just drop in pbzip2 as an argument where you need it?


----------



## overmind (May 16, 2011)

I want to use:


```
tar -cvjf archive.tgz *
```

That's why I would need a symlink.

Well, I think I'll leave it as it is and use one of my examples from previous pos, until I am sure that I don't break anything.


----------



## Galactic_Dominator (May 17, 2011)

overmind said:
			
		

> I want to use:
> 
> 
> ```
> ...


Except that the compression algo for gzip and bzip2 is built into the tar binary.  In your example, your proposed changes will have zero impact.


----------



## Alt (May 17, 2011)

overmind said:
			
		

> I want that my tar utility to use *bpzip2* instead of *bzip2*. I want to know if I break anything by using that method or if is there other approach other than the one with pipes.
> 
> The one with pipes would be:
> 
> ...


You can make shell alias for tar so he will alway use your prog: 
	
	



```
alias tar tar --use-compress-prog=pbzip2
```


----------



## overmind (May 17, 2011)

I thought *tar* uses external *bzip2* binary.


----------



## phoenix (May 17, 2011)

FreeBSD tar(1) uses libarchive(3) which supports a whole slew of tar, cpio, pax, etc archive formats and zip, gzip, bzip2, etc compression formats.  See libarchive-formats(5) for the full list.


----------

