Burning CDs in Linux

Brion Hase - Sioux City Linux Users Group

Intro

This is document is an introduction of how to do the following in Linux:

  • Burn ISO images to IDE CDROM CD-W/.CD-RW drives
  • Create ISO images from a CD in an IDE Drive
  • Copy data CDs with an IDE CD-W/CD-RW drive.
  • Mount ISO images as live files systems to review or change
  • Ripping Audio CD’s to Wave and MP3 files
  • Burning Audio CDs using Wave Files
  • Using GUI interfaces to rip, create and burn CDs in Linux.

For more detailed information on how to create and write CD ROMs in Linux refer to the end of this document. For this paper I used Mandrake 9.0. If you have any corrections or additions please send them to me at bjh at deadpacket dot com

Common Linux Programs For Reading and Writing CDs

Command: cdrecord

Description/Features

  • Command line utility for writing Audio and data CDs.
  • A mature and has been around for a very long time.
  • Supports CD-W, CD-WR, DVD-W, and DVD-RW.
  • Supports Linux, Win32 and several other platforms.
  • A very versatile recorder, it works with most drives.

How do you setup cdrecord?

The best way to setup your CD burner is to create an /etc/default/cdrecord configuration file. Before you can do that you will need to find and setup the Linux CD recording device. Run following command to determine which Linux device your recorder is on:

cdrecord -scanbus

The above command should scan your disk data bus channels and find your CD-W or CD-RW drive. I got the following result:

[root@default]# cdrecord -scanbus     Cdrecord 1.11a32 (i586-mandrake-linux-gnu) Copyright (C) 1995J002 J�rg Schilling     Linux sg driver version: 3.1.24     Using libscg version 'schily-0.6'     scsibus1:     1,0,0 100) *     1,1,0 101) *     1,2,0 102) *     1,3,0 103) 'IOMEGA ' 'ZIP 100 ' '23.D' Removable Disk     1,4,0 104) *     1,5,0 105) *     1,6,0 106) *     1,7,0 107) *

I can only see my IOMEGA drive on /dev/hdd (second IDE controller, slave drive) is listed as being on SCSI device (1,3,0). From that I can interpolate my 48x burner (which is the slave device on my primary IDE controller) is “1,1,0″. I create /etc/default/cdrecord with the following parameters:

CDR_DEVICE=1,1,0     CDR_SPEED=48

Note for SCSI devices, If ‘cdrecord -scanbus’ says it can’t find “/dev/pg”, ‘modprobe sg’ will fix it. Put “sg” into your “/etc/modules”.

Next if cdrecord -scanbus” doesn’t see your ATAPI IDE cd burning device as a SCSI device, make sure your system is seeing the IDE device for your burner. Use the following command to check your kernel message from boot up.

# dmesg | grep '^hd.:'

Look to see if your CD drive appears. It should look something like this:

hda: IBM-DHEA-38451, ATA DISK drive     hdb: SONY CD-RW CRX225E, ATAPI CD/DVD-ROM drive     hdc: TOSHIBA CD-ROM XM-5702B, ATAPI CD/DVD-ROM drive     hdd: IOMEGA ZIP 100 ATAPI, ATAPI FLOPPY drive     hda: 16514064 sectors (8455 MB) w/472KiB Cache, CHS=1027/255/63, UDMA(33)     hdb: ATAPI 40X CD-ROM CD-R/RW drive, 2048kB Cache, UDMA(33)     hdc: ATAPI 12X CD-ROM drive, 256kB Cache, DMA

This also helps you identify where the device is located. If your drive doesn’t appear, you potentially have several different issues which may be related to the hardware problem(s), hardware compatibility issue(s), or problem(s) related to the operating system’s kernel level or configuration.

Once you have verified that IDE device is present, verify that ATAPI IDE/SCSI emulation is enabled for the device. You can do this using the following command. If the kernel messages below do not appear, you may be required to update your kernel and turn on support for related modules. I assume that most modern distributions, these modules are enabled by default, so you may want to try configuring the devices in your boot loader first.

# dmesg | grep 'ide-scsi'

Kernel command line: BOOT_IMAGE=linux ro root=301 devfs=mount hdd=ide-scsi

ide_setup: hdd=ide-scsi

In the output above “hdb=ide-scsi” is missing for my system. Check the lilo or grub configuration to see if your cd burning device can be setup for SCSI emulation. In my case I changed the following line in /boot/grub/menu.lst

kernel (hd0,0)/boot/vmlinuz root=/dev/hda1 devfs=mount hdd=ide-scsi

By changing the line to the following

kernel (hd0,0)/boot/vmlinuz root=/dev/hda1 devfs=mount hdb=ide-scsi hdd=ide-scsi

After competing the above change, I ran the grub install script to save the grub configuration changes. This script added my changes to grub, but I lost the pretty Mandrake startup screen.

sh /boot/grub/install.sh

After rebooting I reran a scanbus with cdrecord and got positive results.

# cdrecord -scanbus       Cdrecord 1.11a32 (i586-mandrake-linux-gnu) Copyright (C) 1995-2002 J�rg Schilling     Linux sg driver version: 3.1.24     Using libscg version 'schily-0.6'     scsibus1:     1,0,0 100) *     1,1,0 101) 'SONY ' 'CD-RW CRX225E ' 'QYB1' Removable CD-ROM     1,2,0 102) *     1,3,0 103) 'IOMEGA ' 'ZIP 100 ' '23.D' Removable Disk     1,4,0 104) *     1,5,0 105) *     1,6,0 106) *     1,7,0 107) *

Size Matters! Make sure you have enough size in your CD’s FIFO buffer. The following setup up for 32MB CD cache:

echo "35000000" > /proc/sys/kernel/shmmax

Command: cdparanoia

Description/Features:

  • Compact Disc Digital Audio (CDDA) extraction tool commonly referred to as a “ripper”.
  • Extracts audio tracks from audio CD’s directly to WAV and other music formats.
  • Works with most CD drives.
  • Originally a derivative work from cdda2wav.
  • Paranoia III is current version, it is stand alone version and is the first version independent from cdda2wav. Version III is not portable, Linux only.
  • Paranoia IV will be portable to other platforms.

Example #1 - Ripping first song from a Audio CD (using from first IDE CDROM drive on second channel)

# cdparanoia -d /dev/hdc       cdparanoia III release 9.8 (March 23, 2001)     (C) 2001 Monty  and Xiphophorus       Report bugs to paranoia@xiph.org     http://www.xiph.org/paranoia/       Ripping from sector 0 (track 1 [0:00.00])     to sector 240381 (track 11 [9:06.01])       outputting to cdda.wav       (== PROGRESS == [> | 000509 02 ] == :-|  0 ==)
Example #2 ripping second and third track from audio CD directly to a single wave file. (Ripping from the default CDROM drive which was linked automatically under Mandrake to /dev/cdrom):
[root@test root]# cdparanoia 2-3 -d /dev/cdrom Perl_Jam_10

Example #3 - Ripping an entire CD to a group of WAV files (named Perl_Jam_10). The “-B” parameter tells Paranoid to split into multiple WAV files on track boundaries.

# cdparanoia -B 1- Perl_Jam_10       # ls -l     total 122060     -rw-r--r-- 1 root root 40906028 Jan 10 00:33 track01.Perl_Jam_10     -rw-r--r-- 1 root root 51791084 Jan 10 00:34 track02.Perl_Jam_10     -rw-r--r-- 1 root root 32145452 Jan 10 00:35 track03.Perl_Jam_10

Command: XCDroast

Description/Features:

Graphical front end for cdrecord for X-Windows.

Command: RipperX

Description/Features:

Graphical front end for X Windows for ripping CDs. RipperX is a GTK program to rip CD audio and encode mp3s. It can rip and encode in parallel and has plugins for cdparanoia, BladeEnc, Lame, GoGo, FHG (l3enc and mp3enc), XingMp3enc, 8hz-mp3, and the ISO encoder. It also has support for CDDB and ID3 tags.

Installation/Run:

Download the tgz file     Run: tar -xzvf ripperX-2.6.1.tar.gz     Run: cd cd ripperX-2.6.1 (depends upon version you downloaded)     Run: ./configure     Run: make     Run: su -c "make install"     OR get the binary RPM for www.rpmfind.net or www.mandrakeclub.com.     Run Insert your audio CD and run "ripperX" at command prompt.

Command: mkisofs

Used to create ISO file systems.

Command: dd

Command line program for copying binary data files or files systems to a second data file or file system. An old UNIX/LINUX command that has beenaroundd longer the most Linux users.

How-To Burn and Make Images Q & A

Have an ISO image of a disk and want to burn it to CD?

# cdrecord -vv-eject "/path/to/file.iso "

Create an ISO image from a CD?

The tried and true method for creating an ISO image of a CD is to use the dd command. The “if” value is the input file/interface. The “of” value is the output file/destination.

# dd if=/dev/hdc of=/path/to/file.iso

Check and/or change ISO images before burning to CD?

Use the following commands to mount the ISO image and check it. If you need to change the image, drop the”ro”o option.

# mount -t iso9660 /path/to/file.iso /mnt/cdrom -o loop,ro

Have separate cdrom and cdburner drives, here is how you burn CD-to-CD copies?

??? Something missing here ???

Use the following command. The “/dev/cdrom” entry should be the device which you are reading from.

# cdrecord -vv -data -isosize /path/to/file.iso

How do I burn a directory of data files to CD?

First create an ISO file from the directory using mkisofs. Use
the following command to create an ISO image of directory
“/path/to/directory” in the file “filename.iso”:

# mkisofs -J -R -r -o /path/to/file.iso /path/to/directory

Make sure you aren’t in the “/path/to/directory” when you create the image or mkisofs will write an infinitely sized ISO file. The -J option creates Joliet extensions forinter operabilityy with Windows. The -R option creates Rock Ridge extensions for Unixinterpretabilityy. The -r changes the owner and permissions within the iso to something sensible for a CD. Then to burn the ISO image to CD using the command from above:

# cdrecord -vv -data -isosize /path/to/file.iso

How do I burn Audio (WAV) files to CD?

# cdrecord -vv -audio -pad "/path/to/wav/*.wav"

What is the best way to create a copy an audio CD on a second audio CD?

From the examples on the cdrecord man page, run the following two commands. The first creates WAV files and an info file from the CD and then the second command reads these files and places them on the copy.

# cdda2wav -v255 -D2,0 -B -Owav     # cdrecord -v -dao -useinfo *.wav

How to I check an ISO image to make sure I have a good file?

Use the following command to get the checksum for your image. Compare this value with the checksum provided by the download site.

md5sum /path/to/disk1.iso

OK, I burned a CD and I can read it on my other PC, how the hell do I mount CDs on my CD Burner under Linux?

Once you have your IDE CD burner configured, you can no longer mount is by its IDE channel name (e.g. /dev/hdb). Use the SCSI CD device name instead (i.e /dev/scd0).

# mount /dev/scd0 /mnt/cdrom

References

http://www.cdrfaq.org/
http://linux.ucla.edu/guides/cheatsheet.php3
http://www.fokus.gmd.de/research/cc/glone/employees/joerg.schilling/private/cdrecord.html
http://www.xiph.org/paranoia
http://ripperx.sourceforge.net/
http://www.speculation.org/garrick/tips.html
http://linux.sgms-centre.com/howto/cdwriting.php
http://www.cdrfaq.org/faq01.html#S1

Originally published January 9th, 2004.

Comments are closed.