Translation(s): English - Français - Italiano


Burn Optical Media

There are several graphical programs available in Debian to burn CDs or DVDs. Install the relevant package:

This page describes usage of optical media writers/burners with CommandLineInterface programs.


Make an ISO 9660 image file

Two packages are available in Debian for producing ISO 9660 filesystems: genisoimage and xorriso. These programs support the same options as the legacy mkisofs and cdrecord programs.

After installing xorriso or genisoimage, you may put the file tree /path/of/directory into an ISO 9660 filesystem image file called my.iso by one of:

genisoimage -v -J -r -V MY_DISK_LABEL -o my.iso /path/of/directory
xorriso -as mkisofs -v -J -r -V MY_DISK_LABEL -o my.iso /path/of/directory

See also ManipulatingISOs

Burn the image file to CD, DVD, or BD

After installing wodim, cdrskin, or xorriso, you may burn the image file my.iso to a CD by one of:

wodim -v dev=/dev/sr0 -dao my.iso
cdrskin -v dev=/dev/sr0 -dao my.iso
xorriso -as cdrecord -v dev=/dev/sr0 -dao my.iso

cdrskin and xorriso commands will also work on BluRay discs (wodim should not be used with DVD or BD media, see here). For BluRay burning, you can also install the growisofs package:

growisofs -dvd-compat -speed=8 -Z /dev/sr0=my.iso -quiet

As usual with the command line, burning will start right away with no confirmation questions.

Test it

For comparing MD5 sums one must restrict reading from the CD, DVD, or BD to exactly the same number of data blocks that was written by the burn program. For this, inquire the size of the ISO image file.

blocks=$(expr $(ls -l my.iso | awk '{print $5}') / 2048)
dd if=/dev/sr0 bs=2048 count=$blocks | md5sum
md5sum my.iso

This should yield identical MD5 checksum strings. E.g.

8213+0 records in
8213+0 records out
16820224 bytes (17 MB) copied, 12.189631 s, 1.4 MB/s
492bd13e477b3efb507149152a4e7736  -
492bd13e477b3efb507149152a4e7736  my.iso

One may also mount the medium and compare data files with their originals on hard disk by doing:

sudo mount /dev/sr0 /mnt/cdrom
diff /mnt/cdrom/my/file /path/of/directory
sudo umount /dev/cdrom

It might be that you first have to create directory /mnt/cdrom before you can mount it. If you eject the medium and insert it again, it may well be mounted automatically underneath /media/. In this case, you do not have to run the sudo commands.

Audio CD

Music CD players expect the CD-DA format, which is not a filesystem, but a simple list of file-like entities called Tracks. Each track is normally one piece of music. E.g. a complete song.

The content of the tracks has to be presented as data files with uncompressed samples of 44100 Hz sampling rate, 16 bits per sample, 2 channels, little-endian byte order, WAV header. This is also known as .wav file.

After installing the cdrskin or wodim package:

cdrskin -v dev=/dev/sr0 -sao -audio track1.wav track2.wav ... trackN.wav
wodim -v dev=/dev/sr0 -sao -audio track1.wav track2.wav ... trackN.wav

The resulting media cannot be read by dd or other data readers. Reading audio tracks from CD may be done by cdrskin with the extract_audio_to= option, or readom from the wodim package.

Drive Addressing

Above examples use the device file address of your first optical drive, /dev/sr0. To get a list of all your optical drive devices do one of:

cdrskin --devices
xorriso -devices

which will report something like

0  -dev '/dev/sr0' rwrw-- :  'HL-DT-ST' 'BDDVDRW GGC-H20L'
1  -dev '/dev/sr1' rwrw-- :  'HL-DT-ST' 'DVDRAM GH24NSC0'
2  -dev '/dev/sr2' rwrw-- :  'Optiarc ' 'BD RW BD-5300S'

wodim will perform this run only if the obsoleted device files /dev/scd* exist.

The sequence of drive numbers may change with each reboot. If you need persistent device names, consider to use the lengthy ones in directory /dev/disk/by-id/. You will recognise them by bearing the same manufacturer and model names as in above --devices runs. E.g.

/dev/disk/by-id/usb-Optiarc_BD_RW_BD-5300S_306663601043-0:0

ISO 9660 Burning On The Fly

One may avoid the need to store an ISO 9660 filesystem image file by piping the output of the ISO producer into the standard input of the burn program. Just omit option -o with the producer and use "-" as data file name with the burn program. Use option -tao instead of -dao or -sao, because the latter need to know the data amount in advance:

genisoimage -v -J -r -V MY_DISK_LABEL /path/of/directory \
| wodim -v dev=/dev/sr0 -tao -

With growisofs:

genisoimage ... \
| growisofs -Z /dev/sr0=/dev/fd/0

Program xorriso with its native command set performs this under control of a single process

xorriso \
  -md5 on \
  -outdev /dev/sr0 \
  -blank as_needed \
  -joliet on \
  -volid MY_DISK_LABEL \
  -map /home/user/the_directory / \
  -find / -exec mkisofs_r --

ISO 9660 Multi-Session

Although ISO 9660 filesystems are read-only, it is possible to append new data files and a new directory tree which can refer to old files and new files alike.

Initial session (if necessary overwriting a re-usable medium like BD-RE from scratch):

xorriso \
  -for_backup \
  -outdev /dev/sr0 \
  -blank as_needed \
  -volid MY_BACKUP_"$(date '+%Y_%m_%d_%H%M%S')" \
  -update_r /home/user/documents /documents

Further update sessions will add new files, overwrite changed files, and remove deleted files:

xorriso \
  -for_backup \
  -assert_volid 'MY_BACKUP_*' fatal \
  -dev /dev/sr0 \
  -volid MY_BACKUP_"$(date '+%Y_%m_%d_%H%M%S')" \
  -update_r /home/user/documents /documents

At some update attempt, the program will go on strike because the medium is full. Then you need to write an initial session onto another blank or re-usable medium.

Verification of the most recent session data:

xorriso -for_backup -indev /dev/sr0 -check_md5 FAILURE --

Verification of all recorded sessions

xorriso -for_backup -indev /dev/sr0 -check_media --

In case of mismatch, the exit value will be non-zero

if test $? = 0 ; then echo "OK" ; else echo "MISMATCH !" ; fi

Legacy

Before Linux 2.4, using the ide-scsi driver for burners could improve performance ("hdc=ide-scsi" in lilo/GRUB bootloader options). The detection of the burner as a SCSI device could be verified with cdrecord -scanbus. On Linux 2.6 ,ide-cd replaced ide-scsi for CD burners.

On some systems you might need to add your user account to the cdrom group (or have some kind of write access to the burner device file in /dev/)

See also:


CategorySoftware CategoryHardware CategoryCommandLineInterface CategoryDesktopApplication CategorySound