This is a question that many asked about GNU / Linux and it was how to compress and split files in volumes? They even claimed that there was no application that could do this, and they also mentioned that programs such as Winzip, Winrar and other compressors took part on volumes the files were once compressed.
And then, those programs in proprietary software or freeware rejoin the files and decompress the information contained in them, very useful for very large files that exceeded the ability to save in a file in the FAT32 file system whose limit is 4gb.
As I did to handle large files of 4.7gb, 8gb, 16gb or more if the file system for removable drives is still FAT32, it is simple to split them into volumes and join them on the target computer with the same software tools.
But…. In GNU / Linux is it possible to do without proprietary tools or freeware such as unrar or rar? The answer is yes, this would be with tar, gzip, split and cat combining these programs that are accessed as commands through the console, but first we must have a basic concept of each of these programs:
- TAR, refers in Computing to a file format widely used in UNIX environments, identified by the file suffix “.tar”. It also refers to the file manipulation program that is standard in these environments, but does not include file compression.
- GZIP, is an abbreviation of GNU ZIP, a GNU free software that replaces the UNIX compress program. It is based on the Deflate algorithm, which is a combination of the LZ77 and Huffman encoding. Deflate was developed in response to patents that covered LZW and other compression algorithms and limited the use of compress. Gzip should not be confused with ZIP, which is not supported. Gzip only compresses files, but does not archive them. Because of this it is often used in conjunction with some archiving tool (popularly tar).
- SPLIT, The split program is a utility for Unix-like operating systems, used to split a file into one or more of a smaller size. Hence its name, which in English means to depart.
- CAT, The cat command (for concatenation) is a Unix program used to concatenate and display files, source.
With this learning obtained, the reader can realize why to use these 4 applications or free software tools to create compressed packed files and divided into volumes specified by the user, the first thing that will be done is as an example:
We want to compress 10 video files that exceed 8gb and we want to transfer these files to another computer using a 16gb USB Pen Drive with the FAT32 file system.
This can be divided into 2 actions:
- Process of “packing / compression / splitting into volumes”.
- Process of “Join / Unpack / Unzip”.
Action 1 “packing / compression / splitting into volumes” process
We will divide each of the actions into steps to follow the correct order to fulfill the first action:
1. The first thing having identified the files is to create a directory for later packaging. with the command:
2. After all the files are copied to the “workdir” directory, this can be done in the following way with the cp command (take this into account as if the files are in the same parent directory of workdir):
cp *.mp4 workdir
3. Having the files in the directory, we proceed to create the packed tar file with the following command:
tar -cvf packagefile.tar workdir /
Note: The following command would allow you to skip the next step which is compression instead of using the previous command you can add a parameter and create the packaging and compress it simultaneously in a single command as follows:
tar -czvf packagefile.tar.gz workdir /
4. Having created the packed file, it would only be necessary to compress it as follows:
In this way, the packaged and compressed file would be obtained, which would remain as “packagefile.tar.gz”.
5. The next step would be to split it into volumes that do not exceed a specified size with the split command that will be executed next:
split --bytes = 2000m .tar.gz packagefileprefix_
This will divide the original file into 2GB volumes, the process may take several minutes depending on the read / write speed of the hard drive of the computer where it is running.
6. The last step would be to copy the resulting files in volumes to the pendrive removable storage unit after this extract it and connect it to the remote computer copy the files in a folder created to work on it, its name could be workdir_desteny.
Action 2 “join / unpack / unzip” process
1. Already being located through the terminal or console in the workdir_desteny folder and obviously on the destination computer, the first thing to do is join the files or concatenate them using cat as follows:
cat packagefileprefix_ *> packagefile.tar.gz
This may take several minutes.
2. The following command will be to decompress the packed file:
There is a more simplified way that allows us to skip the last step would be to unzip and unpack the files with the following command:
tar -xvf packagefile.tar.gz
3. The last command or step is the unpacking of the file with:
tar -xvf packagefile.tar
With this, a directory will appear inside work_destiny whose name must be workdir or packagefile inside must be the video files that you want to transfer from one computer to another.
In this way, it is more than demonstrated that in the world of free software and GNU / Linux distributions there are tools that allow packing, compressing, splitting, joining, decompressing and unpacking the files, if the process is too long for the user to consider. you have bash programming knowledge, you can create a script.sh that automates this process of executing the different steps to carry out this task.
Although already in GNU Linux in the most recent versions of desktop environments they already show compression options to divide the files into volumes and you do not have to do this process which is a bit tedious.
But this is very important to know by system administrators, technicians and programmers since there will not always be access with a graphical interface to GNU/Linux distributions, learning how to carry out this process can be of great help in a moment during work or in everyday life at home.
Remember if you are an enthusiast of the world of free software that you just have to read and look for you will find the solution to many problems or limitations that you may encounter and that due to ignorance you do not know that the limitations in the world of free software and GNU / Linux in general do not really exist.