Previous Section  < Day Day Up >  Next Section

Recipe 11.10. Spanning a Large File over Several CDs

11.10.1 Problem

You have a very large file, such as a tar archive or a large graphical image, that you wish to store on CD. However, it is larger than a single disc.

11.10.2 Solution

Use the split utility to divide the file, then convert the new files to .iso images and burn them to discs. Use cat to reassemble the original file.

For example, here is a 2-GB tar archive named big-backup. This example splits it into 650-MB chunks. The CD capacity is 700 MB, but there must be room for file overhead:

$ split -b 650m big-backup.tar.gz

creating file `xaa'

creating file `xab'

creating file `xac'

Each file is now about 682 MB. Now convert each one to an .iso image:

$ for i in xa*; do echo -e "$i"; mkisofs -o $i.iso $i; done

This generates a lot of output. When it's finished, the ls command will show this:

$ ls

xaa  xaa.iso  xab  xab.iso  xac  xac.iso

Now you can transfer each one of the .iso files to its own CD:

$ cdrecord -v -eject dev=0,1,0 xaa.iso

$ cdrecord -v -eject dev=0,1,0 xab.iso

$ cdrecord -v -eject dev=0,1,0 xac.iso

To reassemble the tarball, copy the .iso files from the CD to your hard drive, and use the cat command:

$ cat xaa xab xac > big-backup.tar.gz

Or, append the contents of each CD to the archive on your hard drive one at a time, without having to copy them over first:

$ cat /cdrom/xaa > big-backup.tar.gz

$ cat /cdrom/xab >> big-backup.tar.gz

$ cat /cdrom/xac >> big-backup.tar.gz

You can name the reassembled file anything you like—just be sure to preserve the tar.gz extension. And you can now extract the archive:

$ tar xvzf big-backup.tar.gz

11.10.3 Discussion

This is a good way to make a quick and dirty backup, or to move a large number of files, but don't count on it for regular backups. If any of the split files become corrupted, it is difficult to recover the data, especially from compressed files.

See Chapter 16 to learn how to do large backups.

11.10.4 See Also

    Previous Section  < Day Day Up >  Next Section