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


Burn Optical Media

There are several GUI programs available in Debian.

For example install the brasero package and start brasero in X. Others options are xfburn and k3b.

But sometimes you may want to use the command line or write a shell script.

Make an ISO 9660 image file

Two programs are available for producing ISO 9660 filesystems: genisoimage and xorriso.

Assumed you have already installed did the genisoimage or xorriso packages, you may put the file tree /home/user/for_iso into an ISO 9660 filesystem image file /home/user/file.iso by one of:

genisoimage -v -J -r -V MY_DISK_LABEL -o /home/user/file.iso /home/user/for_iso
xorriso -as mkisofs -v -J -r -V MY_DISK_LABEL -o /home/user/file.iso /home/user/for_iso

Both program runs in this example are controlled by the same options, which originally stem from program mkisofs.

Burn the image file to CD, DVD, or BD

For CD media, there is wodim. For DVD and BD (Blu-ray) there is growisofs. For CD, DVD, and BD there are cdrskin and xorriso.

Assumed you already installed the wodim, cdrskin, or xorriso packages, you may burn the image file /home/user/file.iso to a CD by one of these three commands

wodim -v dev=/dev/sr0 -dao /home/user/file.iso
cdrskin -v dev=/dev/sr0 -dao /home/user/file.iso
xorriso -as cdrecord -v dev=/dev/sr0 -dao /home/user/file.iso

All three are actually controlled by the same options, which originally stem from program cdrecord.

On DVD or BD media, one may run the same cdrskin and xorriso commands as in above example. One may also use growisofs (from the package growisofs):

growisofs -dvd-compat -speed=8 -Z /dev/sr0=/home/user/file.iso -quiet

Some believe it would be better if wodim were not used with DVD or BD media. Perhaps so, but there are many variables involved, most especially burner types and condition, and media quality. Burn on one does not necessarily mean readable on another.

As usual with the command line, burning will start right away with no confirmation questions. If you experience failure, consider to ask for advise at mailing lists debian-user@lists.debian.org or pkg-libburnia-devel@lists.alioth.debian.org .

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 /home/user/file.iso | awk '{print $5}') / 2048)
dd if=/dev/sr0 bs=2048 count=$blocks | md5sum
md5sum /home/user/file.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  /home/user/file.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 /home/user/for_iso/my/file
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.

This applies not to DVD or BD media. Usable are wodim and cdrskin.

wodim -v dev=/dev/sr0 -sao -audio track1.wav track2.wav ... trackN.wav
cdrskin -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 readom out of wodim, or by cdrskin option extract_audio_to=. See

man readom
man cdrskin

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 /home/user/for_iso \
| 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/for_iso / \
  -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

See also: