Announcement

Collapse
No announcement yet.

Use RAR On Linux To Compress A File Into Multiple Parts

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Use RAR On Linux To Compress A File Into Multiple Parts

    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.

    [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 ~]#

    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 ~]#

    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.
    Don't Forget To Say Thanks
    Don't Let The Post DIE ... REPLY !!

  • #2
    The above is for making a split archive. If you want to make one archive of several files, just type;

    Code:
    rar a name_of_archive name_of_file_1 name_of_file_2 name_of_file_3
    Don't Forget To Say Thanks
    Don't Let The Post DIE ... REPLY !!

    Comment


    • #3
      ultra post thank you

      Comment


      • #4
        Hello Singh , Yes you have guided good , RAR is the best to compress/zip files on Linux.
        This is the complete procedure to install , Thanks for sharing.
        Last edited by Fleming; 05-07-2011, 01:51 PM.

        Comment


        • #5
          I prefer using 7zip for that.

          7z a -v<size> <output_filename> <file_or_folder_to_archive>

          So for example you want to archive the foler /backup recursive into split files of 200MB into files named testbackup.7z, you would type


          7z a -t7z -r -v200M ./testbackup.7z /backup

          I prefer 7zip as it has a very good compression level.

          Comment

          Working...
          X