This tutorial describes how to burn CD using Linux command line.

Introduction

I suppose here you got mkisofs, cdrecord and cdrdao What you need ?

  • CD-Drive
  • a CD-RW

We have to check the device of our drive(dev) to burn Cd using command Line,

For Linux Kernels 2.6.x, we got:

cdrecord -scanbus dev=ATA
Cdrecord-Clone 2.01 (i686-pc-linux-gnu) Copyright (C) 1995-2004 Jà¶rg Schilling
cdrecord: Warning: Running on Linux-2.6.10
cdrecord: There are unsettled issues with Linux-2.5 and newer.
cdrecord: If you have unexpected problems, please try Linux-2.4 or Solaris.
scsidev: 'ATA'
devname: 'ATA'
scsibus: -2 target: -2 lun: -2
Warning: Using badly designed ATAPI via /dev/hd* interface.
Linux sg driver version: 3.5.27
Using libscg version 'schily-0.8'.
scsibus1:
        1,0,0   100) 'MATSHITA' 'UJDA730 DVD/CDRW' '1.00' Removable CD-ROM
        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) *

My drive is a Matshita UJDA730, it can read DVD. dev=1,0,0. If your kernel is 2.4.X, you have two ways to check your device, first:

cdrecord -scanbus

second

cdrdao scanbus

How to make an image iso

Command mkisofs will allow us to make an image iso of a directory. The following image iso will be named image.iso, you can call it foo.iso or save.iso, and path_of_your_directory is the absolute path of your directory, for example /home/user/project

mkisofs -v -r -J -o image.iso path_of_your_directory

you can also do it for a file

mkisofs -v -r -J -o image.iso path_of_your_file

Some explanations about the options used:

  • -v is the verbose mode
  • -r to reset the rights
  • -J is the Joliet extension, it allows to support Long names of files
  • -o is the output, here it is image.iso

Burning

The idea is to make an image iso with mkisofs and next to burn this image in our CD. Once iso have been created, we use cdrecord

cdrecord -v -speed=10 dev=ATA:1,0,0 -data image.iso

Fast Burning

Burn a CD could be faster without making ISO. We can do it through /dev/null. First, we have to find the size of ISO like follows:

mkisofs -r -print-size path_of_your_directory

If you want to burn a file:

mkisofs -r -print-size path_of_your_file

We obtain an integer, it is the image size, look at this example

Total extents scheduled to be written = 30147
30147

Now, the idea is to use a pipe on cdrecrord with the device. We are going to burn cd without making an image iso, just by using the image size (here 30147):

mkisofs -r -print-size chemin_du_repertoire 2>/dev/null | cdrecord -v  -speed=10 -dev=ATA:1,0,0 tsize=30147s -

for a file, if the size is 65432:

mkisofs -r -print-size chemin_du_repertoire 2>/dev/null | cdrecord -v  -speed=10 -dev=ATA:1,0,0 tsize=65432s -

Erase a CD-RW

You can find here the fast method:

cdrecord -v  -speed=10 -dev=ATA:1,0,0 -blank=fast

and the complete one

cdrecord -v  -speed=10 -dev=ATA:1,0,0 -blank=all