Init - logo

Burning CD/DVD with Linux

This reference is an extensive collection of examples for burning/ripping CD/DVD.
Collected from various sources and mainly my own experience. Have fun!
Change /dev/sr0 to your burner device, and adjust the speed parameter as you like.
You can burn as a normal user by giving read and write permissions your burner device: chmod a+rw /dev/sr0 or add the following line to you udev rules: KERNEL=="sr0", MODE="0666"
Then set the programs(such as cdrecord and growisofs) to execute as root: chmod +s `which cdrecord`
However normal users can't set a higher priority and cdrecord turns off burn-proof
Umount the device before burning. Sometimes cdrecord can't seem to umount a mounted medium
mkisofs does't create directories. Use graft-points (see below) to get directories on the medium
cdrdao turns burn-proof on by default (if your burner supports it). cdrecord turns it off by default
To enable burnproof with cdrecord use driveropts=burnfree

Up

The following software is used. I provide basic build instructions but it is probably easier to use your natvie distribution way for getting packages (like emerge, apt-get, rpm, etc.)

cdrecord, mkisofs and cdda2wav
This will install the binaries in /usr instead of /opt/shily and the ownership of the files is root:root instead of bin:bin
make INS_BASE=/usr DEFINSUSR=root DEFINSGRP=root && make INS_BASE=/usr DEFINSUSR=root DEFINSGRP=root install

dvd+rw-tools
make all rpl8 btcflash && make prefix=/usr install

cdparanoia
Although you can also use cdda2wav (supplied with cdrecord) I prefer cdparanoia, because it has better reconstruction of scratches and jitter. All the examples will use cdparanoia
./configure --prefix=/usr && make && make install

lame
Lame is used for encoding (wav->mp3) and decoding (mp3->wav).
./configure --prefix=/usr --enable-mp3rtp --enable-mp3x && make && make install &&

cdrado
cdrdao is used for burning .bin files. If you're not planning to burn .bin and .cue files you don't need to install this program.
./configure --prefix && make && make install

dvdbackup
dvdbackup is used to copy encrypted DVD's to a harddisk. Only useful if you're planning to backup encrypted DVD's (requires libdvdread). Use this patch to compile
patch -Np1 -i ../../packages/dvdbackup_0.1.1-10.diff && cd src &&
gcc -o dvdbackup -I/usr/include/dvdread -L/usr/lib -ldvdread dvdbackup.c &&
cp dvdbackup /usr/local/bin

Up

Remember to burn as root for newer kernels! "scsi: unknown opcode 0x01" is an error you see a lot when burning as a normal user, even when you gave yourself permissions to burn

Burn some files to CD. We pipe mkisofs directly to cdrecord. The final dash is not a typo!. The mkiosfs options '-J' and '-R' ensures your disks can also be read on windoze machines.

mkisofs -J -R file1 file2 | cdrecord -dev=/dev/sr0 -driveropts=burnfree -speed=32 -

Erase a CD-RW. Make sure your burner is unmounted or it won't work!

cdrecord -dev=/dev/sr0 -speed=32 -blank=fast

For other blanking options:

cdrecord -blank=help

Burn an iso image.

cdrecord -dev=/dev/sr0 -speed=32 -driveropts=burnfree iso_image

MDF files are images created using Alcohol 120%. To burn these you first need to convert them to ISO using mdf2iso. Then burn it as described above.

To copy a data CD on the fly use your mountpoint for files, like this:

mkisofs -J -R /mnt/mount_point | cdrecord -dev=/dev/sr0 -speed=32 -

To copy a data CD with caching to your harddisk first execute the following and then burn the created iso image.

mkisofs -J -R -o image.iso /mnt/mount_point

If you want directories on your CD you can do the following: Create a directory which holds all the files and directories you want to burn. Now burn the file . (which is a "dot" and burns everything in the current directory).
Or you can use graft-points. By default all files in an iso image are burned in the root of the cd. If you want to create a nice structure you can use something like this. It's pretty self-explainatory. Again, if you want to burn it directly without creating an iso image, pipe (|) the output to cdrecord (see above) and remove "-o image.iso"

mkisofs -J -R -o image.iso -graft-points music=/mnt/data/mp3/Various\ Artits pictures=/home/wilco/pictures

Burn a .bin image. A bin file contains the data to be burned, and if you have a cue file it contains information on how to burn the data. If your cue file is missing you can generate one with bin2iso, or use that program to convert the bin file to .iso so you can burn it with cdrecord. You can burn the .bin file with cdrdao.

cdrdao write --device /dev/sr0 --driver generic-mmc --speed 32 cuefile.cue

Blanking a disk is also easy with cdrdao. Just use blank instead of write.

Up

I use a bitrate of 192 for mp3. It's pretty good quality. If you want higher/lower quality (like 128) adjust the b parameter.
To rip all the tracks from an audio CD:

cdparanoia -B 1-

Rip partial CD's. X is the first track that is ripped, Y the last one. -B puts every track in a new wav file.

cdparanoia -B X-Y

Convert WAV's into MP3. We use lame -h (higher quality) and -b 192 (birate will be 192).

lame -h -b 192 file.wav file.mp3

To convert multiple mp3's use this construction:

for FILE in *.wav; do lame -h -b 192 "$FILE"; done

Convert flac files to wav. These wav files can be burned to an audio-cd or converted to MP3 (see above). You will need flac for this.

for i in *.flac; do flac -d "$i"; done

Burning mp3's.
If you want to burn the music as mp3 so you can only read it as a data cd and in mp3 players, use the same way as burning data cd's.
When you want to create an audio cd from mp3 you need to convert your mp3's to wav first.
Using lame can be a pain in the ass. It can give you a lot of errors and failed WAV's. You can also use mplayer, xmms or bmp. If you want to convert using xmms go to "preferences". Choose "disk writer plugin" as output plugin. Configure it (using the configure button) and start the playlist.
To decode all mp3s in a directory to wav files in the current directory using mplayer:

for FILE in *.mp3; do mplayer "$FILE" -ao pcm:file="`basename "$FILE" .mp3`.wav"; done

To decode a single mp3 file:

lame --decode file.mp3 file.wav

Burn a music (audio) CD. The pad option adds 2 secons between the tracks. The next command burns all wav files in the current directory.

cdrecord -dev=/dev/sr0 -driveropts=burnfree -audio -pad *.wav

There is a cool program that can rip a CD, use CDDB(for automatically getting titles/artists) and convert it into MP3/OGG all in one command. It's called abcde. It's very flexible and highly advisible if you rip a lot!
Here's my /etc/abcde.conf file (remember to adjust!)

Up

The speed parameter is optional: growisofs will select the appropriate speed automatically and speed down/up when possible. To explicitely set the speed parameter (has no effect) use: growisofs -dvd-compat -speed=4 -Z /dev/sr0=/dev/hdb

Burn some VOB, BUP and IFO files (e.g. a complete DVD structure). Make sure the directory VIDEO_TS contains all the files and create and empty AUDIO_TS directory. Also the all filenames have to be in uppercase (so be careful with FAT32 partitions). This command assumes the current working directory contains an AUDIO_TS and VIDEO_TS directory.

growisofs -dvd-compat -Z /dev/sr0 -dvd-video .

Erase a DVD+RW or DVD-RW
Formatting dvd+-rw is not advisable so it's better to just overwrite the old data.

Create a new DVD. This will also erase any previous content (if any) on a rewritable dvd. This example burns all files in the directory /var and keeps the directory structure. To create a volume name for a DVD use the -V switch as shown in this example.

growisofs -Z /dev/sr0 -J -R -V VOLUME_NAME /var

Add files to a compilation on a disc previously burned with the -Z option. The '-M' option is only useful for multi-session disks. This is basically the same as above only -Z is now -M

growisofs -M /dev/sr0 -J -R files

Copy a dvd movie or a data dvd from /dev/hdb to /dev/sr0. We use the growisofs switch -dvd-compat to make sure the dvd can be read in most kind of dvd players. This also works for windows data dvd's. Tested with "Spectrum Encyclopedie 2003" (See F.A.Q.)
Warning: if a DVD is encrypted with CSS this method fails because growisofs can't copy the encryption and it doesn't decrypt. Use the dvdbackup method (see below).

growisofs -dvd-compat -Z /dev/sr0=/dev/hdb

If a DVD is protected it sometimes works using the DVD-video switch. Mount the source on /mnt/dvd

growisofs -dvd-compat -Z /dev/sr0 -dvd-video /mnt/dvd

Burn a DVD iso image (.iso, .img or .mdf)

growisofs -dvd-compat -Z /dev/sr0=image.img

Copy encrypted DVD's. If growisofs burns the layout at the start and you get "DriveReady SeekComplete Error" messages when running dmesg the DVD is probably encrypted with CSS. The best way to go is to use vobcopy or alternatively dvdbackup (no longer developed). Then copy the DVD to your harddisk. Vobcopy and dvdbackup will create a directory with the same name as the DVD label. You only need one of the programs and vobcopy expects the DVD to be mounted (in this example /mnt/dvd).

Automated DVD ripping and ejecting:

mount /mnt/dvd && vobcopy -m /mnt/dvd -t "Movie Name" && eject
OR: dvdbackup -i /dev/dvd -o . -M
growisofs -dvd-compat -Z /dev/sr0 -dvd-video DVD_LABEL/

Create an ISO from an AUDIO_TS, VIDEO_TS folder. The directory DVD/ should contain a folder called VIDEO_TS.

mkisofs -dvd-video -o Iso.iso DVD/

Up

When using a 2.4 kernel you should use dev=0,0,0 or check with cdrecord -scanbus or with cdrdao scanbus to locate your burner device. Use this instead of /dev/sr0
Check your kernel settings. Make sure to do the following:
Add the following to lilo.conf (or your grub config file): append="sr0=ide-scsi". Replace sr0 with your burner.
Check your kernel has support for "ide-cd", "scsi emulation", "scsi support", "scsi cd-rom", "scsi generic". I have them built as modules (except ide-cd) which works fine. You can find these options in "ATA/IDE/..." and "SCSI support" in your kernel config
When using growisofs you should use scd0 instead of sr0

Up

Q: /dev/hdX is not a valid block device
A: make sure you have ide-cd and ide-scsi built into your kernel or built as modules and loaded them both. With modprobe you can load the modules, like this: modprobe ide-scsi. See the introduction for more information

Q: My burner makes a clicking sound when a CD/DVD is in the drive.
A: Probably a bad medium.

Q: My burner smells like it's really burning!
A: Can be the burner is going to die, but probaply it's just a little bit of dust inside it.

Q: mkisofs/growisofs says it's using 8.3 filenames!
A: Your files are burned with long filenames. It's just a warning.

Q: How do I turn burnproof on?
A: Use the following cdrecord switch: -driveropts=burnfree

Q: What about burnproof (burn free) with DVD or with cdrdao?
A: Growisofs handles buffer underruns automatically. It works better for DVD+R(W). See growisofs homepage for a good explanation.
cdrdao turns on burn-proof automatically when it's available.

Q: Can I burn without root privileges?
A: Sure. As root do: chmod u+s `which growisofs`. Now you can burn dvd's as normal user.

Q: I'm using kernel 2.6.x and the newest cdrecord and it won't work!
A: Using a newer 2.6 kernel (such as 2.6.8) in combination with the newest cdrecord gives problems when you're trying to burn as a normal user. Try to downgrade cdrecord or burn as root.

Q: Copying a windows data dvd fails
A: Try to burn at a lower speed such as 2.4. Also some dvd+rw's don't work on windows (I've had problems with Philips discs)

Q: Can I burn more onto a CD than the medium size?
A: Use overburn, like this: mkisofs -J -R file | cdrecord -overburn -dev=/dev/sr0 -speed=32 -

Q: I get this growisofs warning: Unknown file type (unallocated) ./.. - ignoring and continuing. What does it mean?
A: Probably has something to do with the character set. If you have a better explanation please mail me. Anyway, it's harmless. I've had it a dozen times but all DVDs were fine.

Q: :-( /dev/sr0: media is not recognized as recordable DVD: 0
A: No DVD is in the drive.

Q: :-( write failed: No space left on device
A: DVD is too small. Use the option: -overburn

Up