DVD & CD

These notes look at recording pre-mastered ISO-9660 images onto DVDs and CDs, with an emphasis on DVD media.

DVD Properties

The 1× speed for CDs is 150 KiB/s. The 1× speed for DVDs is 1,385 KB/s.

For all writable DVDs, a sector holds 2048 bytes of user data. Specifications for DVD+RW, DVD+R, and DVD-RAM formats stipulate the number of sectors as well. Specifications for DVD-RW and DVD-R stipulate only minimum number of sectors, and thus the capacity may differ among manufacturers.

"MMC" abbreviates "Multimedia Commands", a command set to multimedia devices via SCSI/ATAPI.

User data are organized into blocks of 2048 bytes. A sector consists of a block of user data plus bookkeeping and validation data; only the user data are available to the host OS.

Toolbox

cdrskin with option -help for options compatible with cdrecord legacy; with option --help for options breaking the chains for the legacy. home page.

The main tool for burning CDs is wodim (eponymous package).

cdrtools licensing incompatibility

The main tools used here for burning DVDs are growisofs plus dvd+rw-mediainfo and dvd+rw-format (package dvd+rw-tools), but wodim does pitch in here and there.

Under Fedora, dvdrecord resolves to wodim:

-> file --brief `which dvdrecord`
symbolic link to /etc/alternatives/cdrecord-dvdrecord
-> file --brief /etc/alternatives/cdrecord-dvdrecord
symbolic link to /usr/bin/wodim
-> file --brief /usr/bin/wodim
ELF 64-bit LSB executable, 

Under Fedora, cdrecord resolves to wodim:

-> file --brief `which cdrecord`
symbolic link to /etc/alternatives/cdrecord
-> file --brief /etc/alternatives/cdrecord
symbolic link to /usr/bin/wodim
-> file --brief /usr/bin/wodim
ELF 64-bit LSB executable, 

Identifying the DVD/CD Drive

Under Fedora, /dev/sr0 connects to the (first) DVD/CD drive, and /dev/cdrom is a symbolic link to /dev/sr0:

-> file /dev/cdrom
/dev/cdrom: symbolic link to sr0
-> file /dev/sr0
/dev/sr0: block special (11/0)
-> lsblk /dev/sr0 --output 'NAME,MAJ:MIN,TYPE,ROTA,RM,TRAN,VENDOR,MODEL,REV'
NAME MAJ:MIN TYPE ROTA RM TRAN   VENDOR   MODEL             REV
sr0   11:0   rom     1  1 sata   ASUS     DRW-24B1ST   i   1.00

Other distributions may choose different device names, such as /dev/scd0. Here are some ways to discover what's used.

Try the sleeper command eject:

-> eject --default
eject: default device: `/dev/cdrom'

If you happen to have a disc with content on hand, load it and let findmnt or mount help you out:

-> findmnt --type iso9660 --output LABEL,SOURCE,TARGET --noheadings
CD113A1 /dev/sr0 /run/media/ray/CD113A1
-> mount --type iso9660 --show-labels
/dev/sr0 on /run/media/ray/CD113A1 type iso9660 

If you have package xorriso installed:

-> xorriso -devices

0  -dev '/dev/cdrom' rwrw-- :  'ASUS    ' 'DRW-24B1ST i' 

You can get help from lsblk, lsscsi, or lshw, too:

-> lsblk --paths | grep rom
/dev/sr0     11:0    1  1024M  0 rom  
-> lsscsi | grep --perl-regexp 'DVD|CD' --ignore-case
[5:0:0:0]    cd/dvd  ASUS     DRW-24B1ST   i   1.00  /dev/sr0 
-> lshw -class disk
WARNING: you should run this program as super-user.
  *-cdrom

       logical name: /dev/cdrom
       logical name: /dev/sr0

Package uitls-linux provides lsblk. The latter two commands are provided by packages of their respective names.

Look for block device 11 in /proc/devices:

-> grep --perl-regexp '11 ' /proc/devices 
 11 sr

Check out /proc/sys/dev/cdrom/info:

-> grep name /proc/sys/dev/cdrom/info
drive name:		sr0

A DVD/CD drive has a list of profiles describing what types of media it supports and what features it implements for each type of medium. You can ask xorriso to display these profiles:

-> xorriso -outdev /dev/sr0 -list_profiles 2>&1 | grep Profile
Profile      : 0x002B (DVD+R/DL)
Profile      : 0x001B (DVD+R)
Profile      : 0x001A (DVD+RW)
Profile      : 0x0016 (DVD-R/DL layer jump recording)
Profile      : 0x0015 (DVD-R/DL sequential recording)
Profile      : 0x0014 (DVD-RW sequential recording)
Profile      : 0x0013 (DVD-RW restricted overwrite)
Profile      : 0x0012 (DVD-RAM)
Profile      : 0x0011 (DVD-R sequential recording)
Profile      : 0x0010 (DVD-ROM)
Profile      : 0x000A (CD-RW) (current)
Profile      : 0x0009 (CD-R)
Profile      : 0x0008 (CD-ROM)
Profile      : 0x0002 (Removable disk)

The hexadecimal numbers in the second column are the MMC codes representing the media listed in the third column. See chapter 5 Features and Profiles for Multi-Media Devices for the definitions of profiles and their features. Command GET CONFIGURATION retrieves the list of profile codes.

Use dvd+rw-mediainfo to read a DVD's inscribed properties (MID):

-> dvd+rw-mediainfo /dev/sr0
INQUIRY:                [ASUS    ][DRW-24B1ST   i  ][1.00]
GET [CURRENT] CONFIGURATION:
 Mounted Media:         1Ah, DVD+RW
 Media ID:              RITEK/004
 Current Write Speed:   4.0x1385=5540KB/s
 Write Speed #0:        4.0x1385=5540KB/s
 Speed Descriptor#0:    00/2295103 R@6.0x1385=8310KB/s W@4.0x1385=5540KB/s

READ CAPACITY:          2295104*2048=4700372992

(There is no man page.) Media Information Code

Use wodim to read a CD's inscribed properties (ATIP):

 -> wodim dev=/dev/sr0 -atip

Manufacturer: INFODISC Technology Co., Ltd.

Absolute Time in Pregroove

DVD+RW Media

DVD+ discs come in three variants: DVD+RW, DVD+R, DVD+R DL (double layer). DVD+RW can be written and erased approximately 1,000 times. DVD+R and DVD+R DL cannot be erased, but recording is not limited to one fell swoop, either. DVD+RW and DVD+R have a nominal capacity of 4.7 GB; DVD+R DL spans 8.5 GB.

The nominal capacity of 4.7 GB summarizes the actual capacity of 4,700,372,992 bytes chunked into 2,295,104 sectors of 2048 bytes each:

-> dvd+rw-mediainfo /dev/sr0 | grep 'READ CAPACITY'
READ CAPACITY:          2295104*2048=4700372992

A DVD+RW is an erasable medium with random read-write access. DVD+RW supports a single session only, although growisofs and xorriso can append new data onto the existing session. There is no notion of blanking a DVD+RW.

A new DVD+RW needs to be formatted in preparation for a lifetime of rewriting. Conveniently, growisofs, wodim, and xorriso spot a new DVD+RW and automatically format the disc on your behalf. You can attend to your own behalf beforehand if you wish:

-> cdrskin dev=/dev/sr0 -format

-> dvd+rw-format /dev/sr0

-> wodim dev=/dev/sr0 -format

-> xorriso -dev /dev/sr0 -format full

DVD+RW formatting is normally one-and-done. You can still reformat if you wish. With dvd+rw-format, append option -force. But wodim will decline to format an already-formatted disc. The man page for dvd+rw-format recommends against reformatting a DVD+RW. The man page for xorriso suggests reformatting a DVD+RW suffering read errors.

For DVD+RW, formatting proceeds as a sort-of background operation. Once an initial portion of the disc is formatted, actual writing can begin. The unformatted areas will be formatted implicitly as needed until the entire disc has been formatted. For the end-user, this just-in-time approach reduces the apparent amount of time required to format. dvd+rw-mediainfo reports the status of fomatting: "READ DISC INFORMATION"


An implication of this just-in-time approach is that you should explicitly overwrite a DVD+RW if you wish to erase previous data. Reformatting alone fails as a proxy for blanking because the formatting command returns successfully after erasing only an initial portion of the disc. User data beyond the preliminary formatting remain open to commands like hexdump and dd in the hands of any interested party savvy enough to probe.

DVD+RW disc does not necessarily erase all data on the disc. (MMC format type 0x26. Under the hood, a host command (e.g. xorrecord) sends an MMC FORMAT_UNIT to the DVD/CD drive. There is some leeway in what parameters a host command sets when calling FORMAT_UNIT, and the there is some leeway in how a drive's firmware responds. It looks like just how much gets initialized depends on how the command used issues the FORMAT_UNIT command to the DVD/CD drive an perhaps on the drive's firmware as well.

DVD-RW Media

DVD-RW offers two recording modes: sequential recording and restricted overwrite. Sometimes you'll see "incremental-sequential" instead of just "sequential." A new DVD-RW uses sequential mode. To activate restricted overwrite mode, you must explicitly format the disc. As consequent terminology, an "unformatted" DVD-RW is a disc in sequential-recording mode, and a "formatted" DVD-RW is a disc in restricted-overwrite mode.

A DVD-RW in sequential mode supports multiple sessions. It is in one of three states: A blank disc is not readable; rather, it is ready for writing anew. An appendable disc's sessions can be read, and the disc can add new sessions after prior sessions without losing data. A closed disc can be read only. If you want to record your data in multiple sessions, then this is the mode for you.

A DVD-RW in restricted-overwrite mode is a single-session medium. You cannot append to it. You do not blank it before writing; just write when ready. If simply overwriting a disc from scratch meets your needs for typical use, then this mode offers the convenience of omitting blanking.

To see a disc's current mode:

-> cdrskin -minfo 2>&1 | grep 'Mounted media type'
Mounted media type:       DVD-RW sequential recording

-> dvd+rw-mediainfo /dev/sr0 | grep 'Mounted Media'
 Mounted Media:         13h, DVD-RW Restricted Overwrite

To format a DVD-RW from sequential-recording mode into restricted-overwrite mode:

-> cdrskin dev=/dev/sr0 -blank=format_overwrite_quickest

-> dvd+rw-format /dev/sr0 -force

To revert a formatted DVD-RW from restrcited-overwrite mode to sequential-recording mode:

-> cdrskin dev=/dev/sr0 -blank=deformat_sequential_quickest

-> dvd+rw-format /dev/sr0 -blank

You must blank a DVD-RW that is in the default sequential mode before you can write it anew. Minimal blanking suffices in preparation for burning a pre-mastered image:

-> cdrskin dev=/dev/sr0 blank=format_overwrite_quickest

-> dvd+rw-format /dev/sr0 -blank

-> wodim dev=/dev/sr0 blank=fast

-> xorrecord dev=/dev/sr0 blank=deformat_quickest

Confusingly, both cdrskin and xorrecord will do a full blank even if told to do a minimal (fast) blank. For example:

-> xorrecord dev=/dev/sr0 blank=fast -dummy

xorriso : NOTE : -blank: DVD-RW present. Mode 'fast' defaulted to mode 'all'.
xorriso : HINT : Mode 'deformat_quickest' produces single-session-only media.
xorriso : NOTE : -dummy mode prevents blanking of medium in mode 'all'.

This is the reason for the esoteric options for these commands above. The following also quashes this insubordination from cdrskin:

-> cdrskin dev=/dev/sr0 blank=fast --prodvd_cli_compatible

A new DVD-RW is in sequential mode and hence is unformatted. Use dvd+rw-format to put a DVD-RW into restricted-overwrite mode:

-> dvd+rw-format -force /dev/sr0

-> dvd+rw-mediainfo /dev/sr0 | grep --perl-regexp 'Mounted Media|Disc status'
 Mounted Media:         13h, DVD-RW Restricted Overwrite

To revert a formatted DVD-RW to unformatted, sequential mode:



Erasing DVD+RW

Fully blanking a disc fills all sectors with zeros—binary zeros, that is, or 0x00. DVD-RW offers built-in blanking, which dvd+rw-format, wodim, and xorisso can initiate. DVD+RW does not offer native blanking, but growisofs provides a special usage idiom instead. You can also overwrite a DVD via shred and scrub.

To fully blank a DVD-RW:

-> dvd+rw-format -blank

-> xorriso -outdev /dev/sr0 -blank all

-> wodim dev=/dev/sr0 -blank=all

To overwrite an entire DVD+RW with binary zeros:

-> growisofs -Z /dev/sr0=/dev/zero

This works fine for DVD-RW, too.

Truth in note writing: This usage always complains thus (for my platform, anyway):


4690739200/4700372992 (99.8%) @4.0x, remaining 0:01 RBU 100.0% UBU 100.0%
:-[ WRITE@LBA=230540h failed with SK=5h/END OF USER AREA ENCOUNTERED ON THIS TRACK]: Input/output error
:-( write failed: Input/output error

/dev/sr0: writing lead-out
/dev/sr0: reloading tray

Despite this infernal IO error of elusive provenance, zeroing succeeds as verified by read-back.

You can use hexdump or another program to verify that each and every byte is 0x00. For example, here's an unadorned report from hexdump:

-> hexdump /dev/sr0
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
1182a0000
-> echo 'ibase=16; 1182A0000' | bc
4700372992

You can have hexdump get to the point more concisely by laboring with its -format option, like so:

-> eject; eject --traytoggle; sleep 8
-> hexdump --format ' "0x%02x " "%_Ad bytes\n" ' /dev/sr0
0x00 *
4700372992 bytes
-> hexdump --format '1/1 "%02x " "%_Ad bytes\n"' /dev/sr0
ff *
4700372992 bytes
To see how blanking and erasing work, it's first useful to fill a disc with a simple, non-zero bit pattern. Since blankin First, set each byte to 0xff:
-> scrub --pattern fillff --no-signature /dev/sr0
scrub: using Quick Fill with 0xff patterns
scrub: please verify that device size below is correct!
scrub: scrubbing /dev/sr0 4700372992 bytes (~4482MB)
scrub: 0xff    |................................................|

You can verify for good measure:

-> hexdump --format '1/1 "%02x " "%_Ad bytes\n"'  /dev/sr0
ff *
4700372992 bytes
dvd+rw-format /dev/sr0 -blank=full
* BD/DVD±RW/-RAM format utility by <appro@fy.chalmers.se>, version 7.1.
* 4.7GB DVD+RW media detected.
- illegal command-line option for this media.
- you have the option to re-run dvd+rw-format with:
  -lead-out  to elicit lead-out relocation for better
             DVD-ROM compatibility, data is not affected;
  -force     to enforce new format (not recommended)
             and wipe the data.
 -> dvd+rw-format /dev/sr0 -force
* BD/DVD±RW/-RAM format utility by <appro@fy.chalmers.se>, version 7.1.
* 4.7GB DVD+RW media detected.
* formatting 50.4%

The man page for dvd+rw-format admonishes that reformatting a DVD+RW does not suffice for blanking. It explicitly advises using growisofs as above to zero-out a DVD+RW. Here's an example that bears out the warning. First, set each byte to 0xff:

-> scrub --pattern fillff --no-signature /dev/sr0
scrub: using Quick Fill with 0xff patterns
scrub: please verify that device size below is correct!
scrub: scrubbing /dev/sr0 4700372992 bytes (~4482MB)
scrub: 0xff    |................................................|

You can verify for good measure:

-> hexdump --format '1/1 "%02x " "%_Ad bytes\n"'  /dev/sr0
ff *
4700372992 bytes

This shorthans means that each and every byte is 0xff. Now format the disc and then re-examine its contents:

-> dvd+rw-format /dev/sr0 -force

-> hexdump --format '"%10_ad " 1/1 "%02x " "%_Ad bytes\n"' /dev/sr0 
         0 00 *
 455081984 ff *
4700372992 bytes

This report reveals that formatting erased the initial 455,081,984 bytes (by setting them to 0x00) but left the remaining bytes alone. Reformatting with xorriso likewise erases only an initial portion of the disc (445,349,888 bytes).

Burning DVDs

Here's how to burn a pre-mastered ISO image onto a DVD+RW, a formatted DVD-RW (i.e. in restricted-overwrite mode), or a blanked DVD-RW (i.e. in sequential mode):

-> stat --format %s Fedora-Live-Xfce-x86_64-21-5.iso 
935329792

-> cdrskin dev=/dev/sr0 Fedora-Live-Xfce-x86_64-21-5.iso  

Track 01: Total bytes read/written: 935329792/935329792 (456704 sectors).
-> wodim dev=/dev/sr0 -sao Fedora-Live-Xfce-x86_64-21-5.iso 

Track 01: Total bytes read/written: 935329792/935329792 (456704 sectors).
-> xorrecord dev=/dev/sr0 Fedora-Live-Xfce-x86_64-21-5.iso

Media summary: 1 session, 456854 data blocks,  892m data,     0 fr

You can also use growisofs to burn images. It has peculiar syntax. With DVD+RW, a fully blanked DVD-RW, and a formatted DVD-RW:

-> growisofs -Z /dev/sr0=Fedora-Live-Xfce-x86_64-21-5.iso
About to execute 'builtin_dd if=Fedora-Live-Xfce-x86_64-21-5.iso of=/dev/sr0 obs=32k seek=0'
/dev/sr0: "Current Write Speed" is 4.1x1352KBps.
    8552448/935329792 ( 0.9%) @1.9x, remaining 7:13 RBU  99.8% UBU   6.6%

  919306240/935329792 (98.3%) @4.0x, remaining 0:02 RBU  95.5% UBU 100.0%
builtin_dd: 456704*2KB out @ average 4.0x1352KBps

-> eject; eject --trayclose

With a minimally-blanked DVD-RW:

-> growisofs -dvd-compat -dvd-compat -Z /dev/sr0=Fedora-Live-Xfce-x86_64-21-5.iso 

-> eject; eject --trayclose

The man page does not document the need for either the double -dvd-compat or full blanking when burning an image to an unformatted DVD-RW. Instead, an error message reveals the trick:

:-[ WRITE@LBA=0h failed with SK=5h/ILLEGAL MODE FOR THIS TRACK]: Input/output error
:-( attempt to re-run with -dvd-compat -dvd-compat to engage DAO or apply full blanking procedure
:-( write failed: Input/output error

When growisofs sees a file system on a DVD+RW, it issues the following warning:

WARNING: /dev/sr0 already carries isofs!

It gets to work just the same. If the warning needles your sensibilities, you can first zero-out the disc; see next; Alternatively, you can format the disc (as above).

By the way, growisofs uses a homespun dd for writing data to a disc.


Executing 'builtin_dd if=Fedora-Live-Xfce-x86_64-21-5.iso of=/dev/sr0 obs=32k seek=0'

It coordinates its internal buffer (Ring Buffer Utilization) with the DVD/CD drive's buffer (Unit Buffer Utilization).

Burning CDs

You must blank a CD-RW before you can rewrite it. Fast blanking should suffice:

-> cdrdao blank --device /dev/sr0

-> cdrskin dev=/dev/sr0 -blank=fast

-> wodim dev=/dev/sr0 -blank=fast

-> xorrecord dev=/dev/sr0 -blank=fast

There's no need to blank a new CD-RW. Cousins cdrskin and xorrecord will decline to blank an already-blanked CD-RW. Don't blank a CD-R or you'll turn it into a coaster.

Here's how to burn a pre-mastered ISO image onto a CD-R or a blank CD-RW via cdrskin, wodim, and xorrecord:

-> cdrskin dev=/dev/sr0 -sao Fedora-Live-Xfce-i686-20-1.iso 

Track 01: Total bytes read/written: 643825664/643825664 (314368 sectors).
-> stat --format %s Fedora-Live-Xfce-i686-20-1.iso
643825664

-> wodim dev=/dev/sr0 -sao Fedora-Live-Xfce-i686-20-1.iso

Starting to write CD/DVD at speed  10.0 in real SAO mode for single session.
Last chance to quit, starting real write in    0 seconds. Operation starts.
Track 01: Total bytes read/written: 643825664/643825664 (314368 sectors).

-> xorrecord dev=/dev/sr0 Fedora-Live-Xfce-i686-20-1.iso

Media summary: 1 session, 314518 data blocks,  614m data,     0 free

For a CD-RW, you can conveniently merge blanking and burning into a singe call:

-> cdrskin dev=/dev/sr0 -blank=as_needed -sao Fedora-Live-Xfce-i686-20-1.iso 

-> wodim dev=/dev/sr0 -blank=fast -sao Fedora-Live-Xfce-i686-20-1.iso

-> xorrecord dev=/dev/sr0 blank=as_needed Fedora-Live-Xfce-i686-20-1.iso

wodim will blank an already-blanked disc, but cdrskin and xorrecord will not waste your time.

Alternatively, you can use cdrdao to burn an image onto a CD-R or a blank CD-RW. First, create a toc-file that describes the layout and contents of the disc. Here's a simple example for burning a Fedora ISO image:

-> cat Fedora-Live-Xfce-i686-20-1.toc
CD_ROM
TRACK MODE1
DATAFILE "Fedora-Live-Xfce-i686-20-1.iso"

That is, a one-track data disc consisting of the Fedora image broken into 2048-byte blocks (mode 1); just what you want. The cdrdao man page has all the details for writing toc-files. You can vet a toc-file like so:

-> cdrdao toc-info Fedora-Live-Xfce-i686-20-1.toc

Fedora-Live-Xfce-i686-20-1.toc: 1 tracks, length 69:51:43, 314368 blocks, 705 

Now tell cdrdao to render the disc as described in the toc-file:

-> cdrdao write -n Fedora-Live-Xfce-i686-20-1.toc

Writing track 01 (mode MODE1/MODE1 )...
Wrote 705 of 705 MB (Buffers 100% 100%).
Wrote 314368 blocks. Buffer fill min 100%/max 100%.
Flushing cache...
Writing finished successfully.

You can do a dry run by substituting simulate for write.

For wodim and cdrskin, writing modes SAO and DAO are synonymous.

See cdrwtools and pksetup (package udftools) for accessing a CD-RW in packet mode.