Cdrecord and Mkisofs

Share your own howto's etc. Not for support questions!

Cdrecord and Mkisofs

Postby dawgie » 2004-06-21 19:44

Gnu/Linux and the programs that run on it are a moving target. There are changes in the new Linux kernel (2.6.x) hardware configuration for ATAPI CD and DVD burners. Some of the configuration information presented may become obsolete years or months from now, but just a small bit of knowledge of some of the command line programs can go a long way in understanding how all the pieces fit together. If you understand some of this, you have an easier time reconfiguring your system in the future.

This is an attempt to convey a basic understanding of how cdrecord and mkisofs can be used. Please let me know of errors, omissions, &tc.

Kernel 2.6 note:
Cdrecord is easier to use!
SCSI emulation for ATAPI IDE CD burners is no longer used for kernel 2.6
If you are using 2.6 and later, use dev=/dev/hdx where 'x' is the letter of your cdburner location

All of the graphical CD burning programs you use on your box are front ends to cdrecord. The quickest way to burn CDs is with cdrecord. Burning CDs with cdrecord is easy and fun. Blank CDs are cheap!
If you have downloaded an .iso file. The basic command to burn to a CD it is simply:
$ cdrecord dev=(address) /path/to/iso/file

If you enter the command:

$ cdrecord --help

You will see several pages of options go flying by. Some of these options are worth noting:
-v verbose mode
-eject opens your cup holder when the CD is finished
-dummy does a test run without burning
speed=xx sets the speed of the recorder. Without this set, cdrecord will burn at the highest usable speed. Unless there is a configuration entry limiting the speed.

The first step in using cdrecord, is to find the address of your CDR-RW device.
Enter the following command:
$ cdrecord -scanbus(not needed with kernel 2.6)

On my computer, I got this output:

bob@Naylux:~$ cdrecord -scanbus
Cdrecord 2.01a07 (i686-pc-linux-gnu) Copyright (C) 1995-2003 J�rg Schilling
Linux sg driver version: 3.1.25
Using libscg version 'schily-0.7'
0,0,0 0) 'CD-RW ' 'CDR-5W48 ' 'VSG3' Removable CD-ROM
0,1,0 1) *
0,2,0 2) *
0,3,0 3) *
0,4,0 4) *
0,5,0 5) *
0,6,0 6) *
0,7,0 7) *
1,0,0 100) 'ADAPTEC ' 'ACB-5500 ' 'FAKE' NON CCS Removable Disk 1,1,0 101) *
1,2,0 102) *
1,3,0 103) *
1,4,0 104) *
1,5,0 105) *
1,6,0 106) *
1,7,0 107) *

Note that my CD burner address is 0,0,0
(I also have a removable media card reader that showed up at 1,0,0)

--> remember that CD burning is a hardware-intensive task for you computer. While the CD is burning it is not a good time to start up other programs.

I have downloaded BBC-Linux to my home directory.
The name of the file is bbc-2.1.iso
To burn this to a CD, I enter the command:
$ cdrecord -eject dev=0,0,0 -v /home/bob/bbc_2.1.iso
Or, I can do a test run with:
$ cdrecord -eject -dummy dev=0,0,0 -v /home/bob/bbc_2.1.iso

With a little bit of work, we can make things even simpler.
Edit the file /etc/defaults/cdrecord
Add the following 2 lines (with the address of your CD-RW):
cdrw=0,0,0 -1 -1 "" (kernel 2.6: cdrw=/dev/hdx -1 -1)
Save the file.
Now you can burn with:
$ cdrecord -eject -v /path/to/iso

mkisofs command is used to create an iso9660 filesystem image to burn to a CD that can be read on most operating systems.
The basic command is:
$ mkisofs -o name.iso -options /path/_to/_where/_the/_files/_are/

If you enter the command:

$ mkisofs --help

You will see several pages of options go flying by.

Some of these options are commonly used
-o name of the .iso file
-J uses Joliet naming for Windows readability
-r uses Rock Ridge naming for UNIX readability
-v verbose mode
-V volume_name writes volume ID

I have a video that I want to burn to a CD that is in my home directory
The name of this video is vacation2000.avi
To make an iso, the command is
$ mkisofs -o vacation.iso -Jvr -V Bobs_Vacation /home/bob/vacation2000.avi

Then to burn the CD:
$ cdrecord -eject -v vacation.iso
When someone puts the CD in a windows machine, the CD icon has the label "Bobs_Vacation"

I want to make an iso of a CD so I can make lots of copies.
$ mount /cdrom
$ mkisofs -o WhateverYouWantToNameIt.iso -Jvr /cdrom/

As root, you can mount an .iso file as a loop back device to examine the contents.
If you do not already have a temporary mount directory, create one:

# mkdir /mnt/temp

Mount the iso file in the /mnt/temp directory:
# mount -t iso9660 -o ro,loop=/dev/loop0 /home/bob/vacation.iso /mnt/temp

cdrecord:command not found or permission denied
This may be a permission problem. Try the command as root.
cdrecord needs to run as suid for a normal user.

No devices found when running cdrecord -scanbus
You may be missing part of the information in your boot menu:
kernel /boot/vmlinuz-2.4.21 root=/dev/hdc1 ro hdd=scsi

Device address changes
Sometimes plugging and unplugging digital camera and card readers will change the address of the CDR-RW.

Program exits before burn begins
Missing device address
Unable to set priority. May need to reconfigure or reinstall

Partial burn
Empty buffer (less common than it used to be)
Bad media
Bad hardware
---> Note: sometimes a source file is messed up because it was copied from a scratched CD or from bad block of data on a HD.

There are many more options to using cdrecord on the command line and I will not go into detail. Some of these are:
Directly copying a CD from another drive
$ cdrecord -v dev=0,1,0 speed=4 -isosize /dev/scd1 (note speed set to slow the CDR-RW drive)
Multiple sessions
-multi -msinfo -fix -nofix
Music CDs
-audio -swab -padsize=

As always, RTFM (read the fine manual)

home page for cdrecord:
ttp:// ... ecord.html
Linux Documentation Project:
Andy McFadden's CD-Recordable FAQ:
Loop Back Devices:

edited:2004-10-17 (added kernel 2.6 info)

Last edited by dawgie on 2004-10-17 19:35, edited 1 time in total.
User avatar
Posts: 431
Joined: 2004-06-16 21:30
Location: New Hampshire USA

Postby mzilikazi » 2004-09-16 02:26

I see no mention of the fact that the 2.6.* kernel does not require SCSI emulation as it can access ATAPI devices directly. In this case you would use dev=/dev/hdb although cdrecord complains about being an 'inofficial' version it does work just fine.

To burn .iso images I prefer to use a script created specifically for my cd-rw called 'burn' that lives in /usr/bin. It looks like this:
Code: Select all
cdrecord dev=/dev/hdb driveropts=burnfree,noforcespeed fs=14M speed=16 -dao -eject -overburn -v "$1"

So I simply type burn file.iso and voila!
User avatar
Forum Ninja
Posts: 3321
Joined: 2004-09-16 02:14
Location: Colorado Springs, CO

Postby jsumners » 2004-09-16 13:32

Also, if you want to burn data "on the fly" you can pipe the output of mkisofs directly to cdrecord:

mkisofs -o - /path/to/directory/with/cdfs/ | cdrecord dev=(device) -v -eject -

(That should work. I am at work and can not verify it though.)

Another application that is useful is cdrdao. Let's say you just got a shiny new cd and want to copy it so that you don't have to use the original.

For a regular data cd you can do:
cdrdao copy --device device --speed 12 --eject -v

And for an audio cd with cd-text:

cdrdao copy --device device --speed 12 --eject -v --with-cddb --cddb-servers ""

In these two examples the burner will be used for both reading the source disc and writing the new disc. The only catch is the eject only works for the final eject; it does not eject between source copy and disc burn.
Posts: 5
Joined: 2004-09-14 20:23

Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 3 guests