How to prepare and burn CDs and DVDs on *NIX systems with cdrtools
If you want to burn CDs on Linux, BSD or any other *NIX system, your only software choices are
cdrtools and
clones of cdrtools. All the graphical CD burning programs you see are just frontends for cdrtools.
cdrtools isn't one application, but rather a suite of 4 small, specialized programs:
readcd: Low-level CD/DVD reader, nice for ripping protected or damaged disks.
cdda2wav: CD audio ripper.
mkisofs: ISO/HFS/UDF filesystem builder.
cdrecord: CD/DVD writer.
In this guide, I'm only going to be covering the last two.
Before anything else, you might want to make sure that you can run cdrecord as a non-root user. Try running
cdrecord -scanbus. If it succeeds, you're all set. If you get a Permission Denied error, run
chmod 4755 $(type -p cdrecord) as root. This will make cdrecord suid root. Insecure, but easy.
If you're using Linux, and possibly other systems, cdrecord will only work with SCSI CD burners. If you have a SCSI burner, fine. If you have an IDE burner, you'll need to use SCSI emulation.
SCSI emulation in Linux
First off, you should check to see if it is already enabled. Run
dmesg | less and look for the "Kernel command line:" line. If it contains something like "hdc=ide-scsi", you're all set, so skip this section.
To enable SCSI emulation, you need to make your boot loader pass the parameter
hdx=ide-scsi to the kernel. Check
dmesg if you don't know the name of your burner. If it's the secondary master device, it will be
hdc.
I've never used GRUB, so I can't help you with that, but here's how to set up LILO to do it:
1. Open up /etc/lilo.conf in your favorite editor, as root.
2. Go down to the "image" section for your current kernel.
3. Directly under the "label" line, add this line:
append = "hdc=ide-scsi"
(replace hdc with the correct identification for your drive)
4. Save, exit, then run
/sbin/lilo -L as root.
5. Reboot.
Note that from now on you will need to access your drive as
/dev/sr0 instead of /dev/hdc or whatever you currently use. If you have a /dev/cdrom symlink, replace it:
rm /dev/cdrom
ln -s /dev/sr0 /dev/cdrom
Now your system is ready to burn some CDs.
Burning a filesystem image
To cut to the chase:
cdrecord -v -dao dev=0,0,0 speed=10 driveropts=burnfree file.iso
Explanation:
-v: Verbose mode. Might as well enable it.
-dao: Disk-at-once mode.
dev=0,0,0: Specifies the SCSI device to use. Format is bus,id,lun. If you don't have any real SCSI devices, this setting is correct. If you ARE using SCSI, run
cdrecord -scanbus to get a list.
speed=10: Burning speed, in this case 10x.
driveropts=burnfree: Enables buffer underrun protection, if your drive supports it.
file.iso: Image to burn.
cdrecord doesn't support .bin, .ccd, .nrg or anything else that isn't a raw filesystem image. However, there is a tool that breaks .bin files into their component images, which cdrecord can burn correctly. I'll discuss it later.
Erasing CD-RW and DVD-RW media
cdrecord -v dev=0,0,0 speed=10 blank=fast
Explanation:
-v: Verbose mode.
dev=0,0,0: Device.
speed=10: Speed.
blank=fast: Erase mode.
The options for
blank that you'll be interested in are
all and
fast.
fast does a quick, minimal erase that doesn't really erase the disk. Unless you need to totally erase the disk, fast is good enough.
all erases the entire disk, which can take a long time.
Burning the contents of .bin files
In certain circles, the most common CD image format is the .bin/.cue combo. cdrecord can't burn these, but you can get .iso images and other stuff out of them using a tool called
binchunker.
To install it:
1. Extract the archive
2. Switch to the directory of the extracted files
3. Run
make
4. Run
make install as root.
To use it:
bchunk -v file.bin file.cue file
Explanation:
-v: Verbose mode.
file.bin: .bin file
file.cue: .cue file
file: Name for extracted tracks. Appropriate extensions will be added automaticly.
For data CDs, you'll get a .iso file. For audio CDs you'll get .cdr files, unless you use the
-w switch in which case you'll get .wav files.
Creating ISO-9660 filesystems
If you have a directory whose contents you want to put into an iso file as is, then it's very easy to use mkisofs manually to prepare the image. However, if you want to take files and directories from all over your system and assemble them into an .iso using an arbitrary directory structure, you'd be better off using a
frontend.
I'm assuming that the former is true. Switch to the directory to be .iso-ized.
mkisofs -V "Volume Label" -iso-level 2 -J -R -v -o ~/file.iso .
Explanation:
-V "Volume Label": Sets the volume label to Volume Label. The most commom use of this information is as the name of the disk displayed next to the drive letter in Windows.
-iso-level 2: Sets ISO-9660 compliance level to 2, allowing filenames beyond 8.3 to be used. If you're going to be using this CD in DOS, you might want to use
-iso-level 1.
-J: Enable Joliet extensions, used by Windows and some *NIX systems to allow longer filenames, special characters in filenames, and deeper directories.
-R: Enable Rock Ridge extensions, used by *NIX systems to store owner and permission info, as well as unrestricted filenames.
-v: Verbose mode.
-o ~/file.iso: Save to file.iso in your home directory (~).
.: Directory to create the image from, in this case the current directory.
Now, which of the -J and -R flags you use will depend on what you need to store, and what operating systems you'll be using this CD under. In most cases, -J is enough. If you want to store extra info for *NIX systems and still have extended filenames in Windows, use -J and -R. If you will only be using it on *NIX systems, just use -R.
Installing dvdrtools for DVD burners
If you've been trying to follow along with this guide using a DVD burner, you may have found that cdrecord says "built without DVD support, ask author for ProDVD". In this case, you'll need to get something with DVD support. I use a fork of cdrtools called
dvdrtools.
To install it:
0. If your system has a package manager, uninstall the existing cdrtools package.
1.
Download dvdrtools.
2. Unpack it, then switch to the extracted directory.
3. Install it using the usual ./configure, make, make install method.
4. Go to the directory where the dvdrtools binaries are located, usually /usr/bin or /usr/local/bin.
5. Run
ln -sf dvdrecord cdrecord. This creates a symlink for frontend compatibility.
I believe I've covered everything you'll need to know to get started with CD and DVD creation under *NIX systems. Remember that this only scratches the surface of what you can do, consult the man pages for more info.