So you want to write a CD under Linux. Sure, there are tons of frontends but they're all arcane, aren't installed on your system, don't work, or some combination of the three. Don't worry, burning from the command line is easier than you think. You need root privileges to do most of this stuff (check the su command).

ameoba nags me to mention I'm assuming you're using either SCSI discs or IDE SCSI emulation. If you don't know, you probably are.

Before you start you'll want to know what the thing is. Run the command below as root.

cdrecord -scanbus

Simply enough, the number with your CD-R drive next to it is your burner. It's three numbers separated by commas, unspaced. Whenever you see "#,#,#" below, substitute your drive's numbers.

Scenario I: You want to make a 1:1 copy of a CD.

Oh, you picked a fairly easy one. First we have to make an image of it. Run the command below to do that. The name can be anything, my choice was arbitrary.

dd if=/dev/scd0 of=~/DELETETHISLATER.iso

If that worked, you can skip this paragraph. But listen, if /dev/scd0 doesn't exist, then your CD drive may be at /dev/scd1 (if you have two) or maybe at /dev/cdrom0. If you're really stumped, but you can read CDs in the drive, check /etc/fstab with a text reader. It ought to say.

Great, now we've got an image of the disc. And we want to write it. Run the command below as root.

cdrecord dev=#,#,# speed=(your drive's speed) ~/DELETETHISLATER.iso

Happily, your CD is ready. If you really want to go for the gusto you can get it out using the eject command. Or just press the button on the drive. Whatever. You're now free to delete DELETETHISLATER.iso in your homedir.

Scenario II: You want to make a music CD

So your hard drive is full of MP3s. I won't ask questions, because I don't want to know, Blackbeard. You'll need to make sure you have LAME installed.

You're going to enter the directory where the MP3s are using the cd command (stands for "change directory"). Now, lame would want you to do each file one at a time, but that's a pain in the ass. Instead, issue the command below.

find *mp3 -exec lame --decode '{}' \;

Quicker than you know it, you have a directory full of WAVs! Now, su to root and run this command:

cdrecord dev=#,#,# speed=(your drive's speed) -audio *wav

Yeah, you can individually specify the files if you want a certain order, but you won't want to. At any rate, you can delete all those gargantuan WAV files once it's done.

Scenario III: You want to back up some files

In only two easy steps! First we'll run mkisofs like so.

mkisofs -J -o ~/DELETETHISLATER.iso /home/directorywhereyourstuffis

There can be as many directories as you want, but mkisofs just dumps all the files into the CD's root directory (though it respects subdirectories). You can fix this using graft points, but that's a little complicated for this node; check the manpage if you need to get that fancy. Then issue the following command to burn the ISO image:

cdrecord -multi dev=#,#,# speed=(your drive's speed) DELETETHISLATER.iso

The multi switch will make a multi-session CD (Allowing you to add more files later)

Scenario IV: You want to burn an image you downloaded from the Internet

Well, your luck depends on the format.

ISO images

Aren't you lucky! If it's just an ISO, check Scenario I, and skip the making the image part.

If there are MP3s too (Saturn games often come this way, or so I hear), you need to decode them (check Scenario II), then you can run this nifty mixed-mode command:

cdrecord dev=#,#,# speed=(your drive's speed) -data datatrack.iso -audio *wav

BIN/CUE images

Mercifully, this isn't as hard as it used to be. Get cdrdao if you don't have it. Make sure the bin and cue files are named the same thing and then run this command.

cdrdao write --device #,#,# --speed (your drive's speed) filename.cue

Like magic!

CloneCD images

Rename the .img file to .bin and use the BIN/CUE method above. This "sometimes" (i.e., usually) works.

CDI images

Haha, good luck, you'll need it. Try cdirip and the cdrecord hack. If you can get it to work you're greater than I.

NRG images

I've never done it, but people claim nrg2iso works. Look into that.

Impress your friends and frighten your enemies with your new knowledge of Linux CD burning!

The problem with the method Ichiro2k3 describes for burning a music cd, is that while cdrecord has nice features like allowing one to incorporate both data and music tracks onto the same disc, it inserts a nasty two-second pause between audio tracks, which can be extremely annoying when listening to something like a Paul Oakenfold album.

This can be avoided by burning the disc in DAO (disk-at-once) mode, using the aptly named cdrdao command. Though it does support burning data tracks, its primary use, at least in my experience, has been for audio-only cd's, especially 1:1 copies.

I am not going to paste the man page here, since you presumably have access to it if you've installed the program; after all, the appropriate way to invoke any unfamiliar command is to preface it with "man." However, the short version is that when using cdrdao, you must write a TOC (table-of-contents) file, which you then pass to the command as an argument:

heartstab ~ $ cdrdao write "name_of_tocfile"

The syntax of such a file can again be found in the manpage, but since writing them by hand is incredibly tedious, the following shellscript can be used to quickly write one when invoked in the same directory as the .wav files:

echo "Heartstab's Simple TOC file generator v1.0"
echo "Creating TOC file"
echo "CD_DA" > toc
for i in *wav; do echo "TRACK AUDIO" >> toc && echo "FILE \"$i\" 0" >> toc && echo "Added file \"$i\""; done
echo "TOC written as ./toc"

The above, of course, in no way takes advantage of the myriad capabilities of the program, but it will get rid of the gaps between tracks, especially when making 1:1 copies.

Log in or register to write something here or to contact authors.