Nuxified

FOSS technologies explained

  • Useful Articles
  • Blogs
  • Images
  • Tips
  • Archives

January 16, 2007

splitting large files or directories into small tar files

Every once in a while there comes a situation where a file is too big for a CD, or you want to store a file larger than 2GB on a FAT partition, or you want to make a backup of data with UNIX-style permissions (almost a 100% necessity if backing up a $HOME folder with settings) and all you have is a FAT volume somewhere. Here the multi-volume feature of GNU tar comes to play. The ZIP and RAR formats have a similar feature, probably originally for floppy disks, but they don’t store UNIX-style permissions. Also, the feature is in GNU tar for a partly historical reason (partly because it is probably still widely used for the original purpose):

TAR stands for Tape Archive and is the way to store data on magnetic tapes, the sort that is still sometimes used for backups. Tapes have a fixed size, and backups can get enourmous, so logically you’ll need multiple tapes. However, this feature can be used with files as well: (user-entered text is in italics)

% tar --create --multi-volume --tape-length 200M --file data1.tar --same-permissions file1 file2 ... fileN
Prepare volume #2 for `data1.tar' and hit return: n data2.tar
Prepare volume #3 for `data2.tar' and hit return: n data3.tar
...
Prepare volume #N for `data2.tar' and hit return: n dataN.tar
%

the option name –tape-length strongly hints the origin of the feature. when entering n dataN.tar, you’re telling GNU tar that the name of the new part should be dataN.tar; if you don’t specify a new name, it will write to the same file again. This, again, comes from the tape history of the feature, where you would change tapes and press enter. The same procedure can be used with floppy disks.
It is quite a nuisance to enter the new file name all the time (I should know, I did it with 35 archives before learning about the now-described usage), so you can also specify multiple files at the command line thus: (This time, I am using short options)

% tar -cMp -f data1.tar -f data2.tar -f data3.tar -L 200M file1 file2 file3 ... fileN

Using strange old-style options allows you to use shell expansions here (you need the correct number of ‘f’s)

% tar cMpLfff 200M data{1,2,3}.tar file1 file2 ... fileN

unpacking

little more than swapping –create or -c for –get or -x, for example:

% tar xpMfff data{1,2,3}.tar

Though I haven’t tried it, you should be able to use -z or -j options for gzip or bzip2 compression, respectively, with multi-volume archives as well.

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)

Related

Article by free-zombie / Community Blogs

Learn Unix

I run Unix Tutorial website and help anyone interested to pick up Unix skills. If you have questions or just want to share your ideas – please join the Unix Tutorial on Facebook.

Tech Stack Solutions

Tech Stack Solutions is my company that provides Unix support. Sign up or simply get in touch to find out how I can help!

Search this Website

You May Also Like

Recent Posts

  • Advice on using SUDO
  • FFmpeg 4.0
  • KDE Plasma 5.9.0 Release
  • How to Install Ubuntu Linux without a DVD or USB
  • How to Securely Save All Your Passwords with Keepass
  • 9 Signs You Should Use Linux on Your Computer
  • The Easiest Way to Optimize Your MySQL Database Performance
  • Setting up a Linux Web Development Environment in Windows
  • Hunting Down Disk Space Hogs on Linux Command Line
  • 6 Simple Android Apps for Monitoring and Managing Your Linux Server

Archives

Categories

  • Community Blogs
  • Images and Screenshots
  • News
  • Technical Topics
  • Useful Articles

Basic Unix Commands

Basic Unix Commands
  • ls command
  • mkdir command
  • man command in unix
  • cd command - change directory
  • uname command

Advanced Unix Commands

Advanced Unix Commands
  • ln command - symlinks
  • tune2fs unix command - filesystem parameters
  • du command - disk usage
  • lsb_release command
  • find unix command

Unix Reference

Unix Reference
  • SSH port forwarding
  • unix commands
  • visudo tutorial
  • mtime unix
  • lrwxrwxrwx
  • Unix Tutorial digest

Unix Books

Unix Tutorials

Unix How-Tos
  • check raspbian version
  • autostart in KVM
  • List files in Ubuntu package
  • check CentOS version
  • create bootable USB in MacOS
  • Useful Articles
  • Blogs
  • Images
  • Tips
  • Archives

Copyright © 2023 · Education Pro Theme on Genesis Framework · WordPress · Log in