I l@ve RuBoard Previous Section Next Section

Hack 44 Burning a CD Without Creating an ISO File

figs/moderate.giffigs/hack44.gif

Create a CD from another CD, the live filesystem, or even an http download

The safest method for making a copy of a CD is to first make an ISO and then burn the ISO (as in [Hack #43]). But sometimes you don't have the space (or time) for the interim step of making a copy.

If you have a fast enough machine, you can usually burn straight from one CD to another. This usually works best when the source CD and the burner are on separate device chains (like primary and secondary IDE, or IDE and SCSI).

To make a real-time copy of a CD, give this a try:

# dd if=/dev/hdb | cdrecord -v speed=12 dev=0,0,0 fs=8m -data -

The - argument to cdrecord means that the data track should be read from STDIN instead of from a file. The dd line is feeding the cdrecord pipe with a copy of the CD in the slave drive on the primary IDE chain (hdb). The fs=8m parameter makes the write FIFO a bit bigger, to help offset any momentary pipeline hiccups. As long as your bus is up to the task (and your machine isn't otherwise too occupied) then this method will work fine.

Likewise, there is no real need to make an ISO before burning a copy of data from the filesystem. Give this a try:

# mkisofs -r /home/ftp/ | cdrecord -v speed=12 dev=0,0,0 fs=8m -data -

Like the dd above, mkisofs writes to STDOUT by default. This is then fed to STDIN of the cdrecord process, burning the ISO as it is created, in real time. This saves the need to keep a copy of the ISO file lying around your filesystem. Be warned, if your data source is greater than the size of your CDR (somewhere between 650 and 700MB) then you'll end up with a coaster but not a usable disk.

Get an idea of how much space you'll need with du first:

# du -hs /home/ftp/
412M /home/ftp

Perfect. A 412M ISO will fit nicely.

Anything that can print ISO data to STDOUT is a candidate for the left-hand side of a pipeline. How about doing a real-time network burn?

root@catlin:~# mkisofs -r backup/ \  
| ssh florian "cdrecord -v speed=12 dev=0,0,0 fs=8m -data -"

Or copying a local CD to a remote burner over the network?

root@catlin:~# dd if=/dev/cdrom \  
| ssh florian "cdrecord -v speed=12 dev=0,0,0 fs=8m -data -"

Or even downloading an ISO and burning it, all in one pass?

# curl http://my.server.com/slackware-8.1-install.iso \  
| cdrecord -v speed=0 dev=0,0,0 fs=8m -data -

I wouldn't recommend attempting to do a network burn over wireless; you'll want a nice, solid 100Mbps Ethernet cable for this job. And the download example might look silly, but it does illustrate the power of the Unix pipeline: any program can be plugged into nearly any other, to make things happen that the designer of either program likely hadn't ever thought.

    I l@ve RuBoard Previous Section Next Section