The rar command can be useful on Linux to not only compress a file but also split the file into multiple parts during the compression. This will make the files easier to transfer to other servers or easier for other people to download. First rar needs to be installed which can done on CentOS using the directions below. After that we describe how to easily compress and break a file into multiple chunks using one simple rar command.
Install rar On CentOS Linux Using RPMForge and yum:
First install the RPMForge yum repository if you do not already have it installed using the directions in this article. After installing the RPMForge repo issue the below command to install RAR on Linux.
Use RAR To Compress And Split Apart A File Into Multiple Parts On Linux:
Once RAR is installed you can easily compress and split apart a file using the below command. The file we start out with below is 368MB MySQL dump and after issuing the rar command below it has been split into 4 10MB files and 1 8.7MB file.
You can now move the 5 files between servers or share the files with others in a much easier way so they are not required to download one large file.
Install rar On CentOS Linux Using RPMForge and yum:
First install the RPMForge yum repository if you do not already have it installed using the directions in this article. After installing the RPMForge repo issue the below command to install RAR on Linux.
[root@dev ~]# yum install rar
Loading "allowdowngrade" plugin
Loading "fastestmirror" plugin
Determining fastest mirrors
rpmforge 100% |=========================| 1.1 kB 00:00
primary.xml.gz 100% |=========================| 2.2 MB 00:02
rpmforge : ################################################## 10367/10367
primary.xml.gz 100% |=========================| 202 B 00:00
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package rar.i386 0:3.8.0-1.el5.rf set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================== ===========================
Package Arch Version Repository Size
================================================== ===========================
Installing:
rar i386 3.8.0-1.el5.rf rpmforge 264 k
Transaction Summary
================================================== ===========================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 264 k
Is this ok [y/N]: y
Downloading Packages:
(1/1): rar-3.8.0-1.el5.rf 100% |=========================| 264 kB 00:01
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: rar ######################### [1/1]
Installed: rar.i386 0:3.8.0-1.el5.rf
Complete!
[root@dev ~]#
Loading "allowdowngrade" plugin
Loading "fastestmirror" plugin
Determining fastest mirrors
rpmforge 100% |=========================| 1.1 kB 00:00
primary.xml.gz 100% |=========================| 2.2 MB 00:02
rpmforge : ################################################## 10367/10367
primary.xml.gz 100% |=========================| 202 B 00:00
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package rar.i386 0:3.8.0-1.el5.rf set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================== ===========================
Package Arch Version Repository Size
================================================== ===========================
Installing:
rar i386 3.8.0-1.el5.rf rpmforge 264 k
Transaction Summary
================================================== ===========================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 264 k
Is this ok [y/N]: y
Downloading Packages:
(1/1): rar-3.8.0-1.el5.rf 100% |=========================| 264 kB 00:01
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: rar ######################### [1/1]
Installed: rar.i386 0:3.8.0-1.el5.rf
Complete!
[root@dev ~]#
Use RAR To Compress And Split Apart A File Into Multiple Parts On Linux:
Once RAR is installed you can easily compress and split apart a file using the below command. The file we start out with below is 368MB MySQL dump and after issuing the rar command below it has been split into 4 10MB files and 1 8.7MB file.
[root@dev ~]# rar a -v10240k compressed-db.rar devdb-11-12-2008.sql
RAR 3.80 Copyright (c) 1993-2008 Alexander Roshal 16 Sep 2008
Shareware version Type RAR -? for help
Evaluation copy. Please register.
Creating archive compressed-db.rar
Adding devdb-11-12-2008.sql
Calculating the control sum
Creating archive compressed-db.part02.rar
... devdb-11-12-2008.sql
Calculating the control sum
Creating archive compressed-db.part03.rar
... devdb-11-12-2008.sql
Calculating the control sum
Creating archive compressed-db.part04.rar
... devdb-11-12-2008.sql
Calculating the control sum
Creating archive compressed-db.part05.rar
... devdb-11-12-2008.sql OK
Calculating the control sum
Done
You have new mail in /var/spool/mail/root
[root@dev ~]#
RAR 3.80 Copyright (c) 1993-2008 Alexander Roshal 16 Sep 2008
Shareware version Type RAR -? for help
Evaluation copy. Please register.
Creating archive compressed-db.rar
Adding devdb-11-12-2008.sql
Calculating the control sum
Creating archive compressed-db.part02.rar
... devdb-11-12-2008.sql
Calculating the control sum
Creating archive compressed-db.part03.rar
... devdb-11-12-2008.sql
Calculating the control sum
Creating archive compressed-db.part04.rar
... devdb-11-12-2008.sql
Calculating the control sum
Creating archive compressed-db.part05.rar
... devdb-11-12-2008.sql OK
Calculating the control sum
Done
You have new mail in /var/spool/mail/root
[root@dev ~]#
You can now move the 5 files between servers or share the files with others in a much easier way so they are not required to download one large file.
Comment