Skip to content

Instantly share code, notes, and snippets.

@ajokela
Created February 16, 2012 14:08
Show Gist options
  • Save ajokela/1845100 to your computer and use it in GitHub Desktop.
Save ajokela/1845100 to your computer and use it in GitHub Desktop.
Split a large file with tar
Splitting the File
The two extra command line options you need to use over and above the standard syntax are -M (--multi-volume) which tells Tar you want to split the file over multiple media disks. You then need to tell Tar how big that media is, so that it can create files of the correct size. To do this you use the --tape-length option, where the value you pass is number x 1024 bytes.
The example below shows the syntax used. Lets say the largefile.tgz is 150 Meg and we need to fit the file on two 100 Meg Zip drives.
tar -c -M --tape-length=102400 --file=disk1.tar largefile.tgz
The value 102400 is 1024 x 100, which will create a 100 Meg file called disk1.tar and then Tar will prompt for volume 2 like below :-
Prepare volume #2 for disk1.tar and hit return:
In the time of tape drives you would have taken the first tape out of the machine and inserted a new tape, and pressed return to continue. As we want Tar to create the remaining 50 Meg in a separate file, we issue the following command :-
n disk2.tar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment