WRITELOOP

SPLIT A FILE INTO PIECES AND REORDER IT

2014 November 4

This can be useful to transport big files for example on FAT32 filesystems, which have a limit of 2GB per file.

  1. Generate a hash of the original file contents (to check the integrity of the file on the last step): $ md5sum [big_file_name] > original.md5

Copy the hash to the output directory (the place where you will put the “pieces”): $ copy original.md5 /output_directory

  1. Split a file into pieces of, for example, 1.5 GB:
$ split -b 1500m -d [big_file_name] [/output_directory/big_file_name.]
-b: maximum size of each chunk
-d: enables a numeric suffix. Ex.: big_file_name.00, big_file_name.01, etc...
  1. To regenerate the original file:
$ cd /output_directory
$ cat big_file_name.0* > big_file_name.RESTORED
  1. Get a md5sum of the regenerated file: $ md5sum big_file_name.RESTORED > restored.md5

  2. Compare the md5 hashes. If the hash (first hexadecimal string) is equal on both files, then it was successfully done. $ diff original.md5 restored.md5