cybrkyd

Splitting archives in Linux in 7-zip

 Tue, 21 May 2024 12:24 UTC
Splitting archives in Linux in 7-zip
Image: CC BY 4.0 by cybrkyd

We have all been there. In the heat of the moment, what is that command again? And what options go along with it? Yes, there is even a XKCD comic (#1168) about this very phenomenon!

XKCD comic - Tar command

Here is how I will remember forevermore how to split an archive and here is where I shall note it. Also, this is not with Tar.

Split a 7z archive

For the folder red which is 3.1GB in size, I want to split it into nice 1GB archives. To split, I use this command:

$ 7z -v1g a -mx0 red-archive.7z red

The resulting archive files are split and named sequentially. In my example, I ended up with three archives where the first two are of equal size as per my specification.

-rw-r--r-- 1 cybrkyd cybrkyd 1073741824 May 21 10:08 red-archive.7z.001
-rw-r--r-- 1 cybrkyd cybrkyd 1073741824 May 21 10:08 red-archive.7z.002
-rw-r--r-- 1 cybrkyd cybrkyd  912875121 May 21 10:08 red-archive.7z.003

Extract a split 7z archive

To extract a split archive collection, you only need to extract the first volume but ensure that the other parts are also in the same location.

$ 7z x red-archive.7z.001

The files are now extracted.

»
Tagged in:

Visitors: Loading...