Using Linux to split files into chunks for transfer to CD

Question: How can I tar up about 12GB of files on a linux box and then split the files into 700MB chucks?

Answer: You can use the following 2 methods on any GNU tooled box or using the Cygwin environment on Windows.

Using tar, gzip, split and cat - Method 1

Compressing & Splitting the files – Method 1

  1. Create an uncompressed Tar Archive of the files you want

    tar -cvf output.tar /path/to/file

  2. Split it into Chunks

    split -d -b 734003200 output.tar your_prefix

    Where “-d” means append a decimal suffix (00, 01, 02 etc)
    “-b” is the chunk size in Bytes (Type in xxxMB in Bytes into google for a conversion)
    650 megabytes = 681574400 Bytes
    700 megabytes = 734003200 Bytes
    “your_prefix” is whatever you want the chunk filenames to begin with
    Creates a series of files your_prefix00, your_prefix01 etc

  3. Gzip the Chunks (note for greater compression use bzip2

    gzip your_prefix*

  4. Copy the gzipped chunks to CD

Joining them back together again - Method 1

  1. Put all the chunks in one directory

  2. Unzip all the gzipped chunks

    gunzip your_prefix*

  3. Join the chunks

    cat your_prefix* >> mynewoutput.tar

  4. Untar to a new location

Using zip - Method 2

Compressing & Splitting the files - Method 2

  1. Zip up the files into a zip

    zip -r zipfile.zip /path/to/files

  2. Use zipsplit to create chunk

    zipsplit -n 12000000 zipfile.zip

    Where -n is the number of bytes to make each chunk

  3. Copy to CD

Unzipping to a new location - Method 2

  1. Copy the zip chunks to the same directory

  2. Change directory to the root of the new location

  3. Unzip all the chunk individually

    for i in /path/to/zipfil[0-9][0-9].zip ; do unzip $i ; done