12.3 Installing and Configuring a DVD Drive

Installing and configuring a DVD-ROM drive or DVD writer requires the same steps detailed in Chapter 10, with the following exceptions:

  • Windows 95B/98/Me and Windows 2000/XP support DVD-ROM drives natively, and see DVD writers as DVD-ROM drives. Windows can access DVD-ROM data discs directly, but it requires a player application to decode and display DVD-Video.

  • Linux recognizes DVD-ROM drives and DVD writers only as standard CD-ROM drives. Although Linux can read ISO-9660-formatted DVD discs, reading UDF-formatted DVD discs (including standard DVD-Video and DVD-ROM discs) requires separate applications.

  • Just as for writing CDs, Windows and Linux both require separate applications to write DVD discs in DVD-RAM, DVD-R/RW, or DVD+R/+RW drives. To write DVDs with an ATAPI DVD writer under Linux, you must configure the DVD writer to use the ide-scsi driver rather than the default ide driver.

  • DVD drives use Region Coding, which restricts which DVD discs may be played in that drive. For example, a drive set to Region 1 (U.S. and Canada) can play only Region 1 discs, while a drive set to Region 2 (Europe) can play only Region 2 discs. By default, DVD Region is set to the installation location. The Region setting for the drive can be changed a limited number of times, typically five.

12.3.1 Configuring a DVD Drive Under Windows

The only configuration a DVD drive may require under Windows is resetting the Region Code using Device Manager. To do so, expand the listing for DVD/CD-ROM drives, double-click the entry for the DVD drive to display Properties, and then display the Advanced Settings page, shown in Figure 12-1. The line at the bottom of the dialog states how many more Region Code changes are allowed for this drive. Use the scrolling list to locate the country and click to highlight that country. Windows inserts the corresponding region in the New Region box. Click OK to confirm the warning dialog to reprogram the drive for the new region.

Figure 12-1. Using the Advanced Settings page of the Properties dialog to reset the DVD Region Code with Windows 2000 Professional

Some DVD drives shipped before January 1, 2000 did not implement Region Code locking in hardware, instead using software and the registry to control the number of times the Region could be changed. If you have one of those drives and exceed the allowed number of Region changes, you can reset the counter by uninstalling the drive itself and the software that accesses it (e.g., a DVD player application), deleting all references to the drive and the software from the registry, and then reinstalling the drive and software. All DVD drives shipped on or after January 1, 2000 implement Region Code locking on a chip inside the drive itself, and in theory cannot be reset short of returning them to the manufacturer. Of course, many DVD manufacturers dislike region coding intensely, and have "accidentally" left ways by which a user can reset the region coding counter. We can't detail those here, but bypassing region coding is a popular topic on various Internet sites.

Configuring a DVD writer under Windows is no more difficult than configuring a DVD-ROM drive. Recent versions of Windows recognize a DVD writer natively as a DVD-ROM device, and can use it to read CD-ROM and DVD-ROM data discs. Because a DVD writer provides the read functions of a DVD-ROM drive, you can use it to watch DVD-Video discs simply by installing whatever player application you prefer and verifying that the Region Code is configured properly. Note, however, that DVD writers often have slow read speeds, so if you are ripping video, you may want to install a separate 16X DVD-ROM drive for that purpose.

Writing DVDs requires DVD writing software. Most DVD writers include software, although it may have limited functionality. Nero Burning ROM, our favorite software for burning CDs, also supports most popular DVD writers, and is an excellent choice if you need a full-featured writing package for Windows.

12.3.2 Configuring a DVD Drive Under Linux

Configuring a DVD drive under Linux requires a bit more work than doing so under Windows. In contrast to recent versions of Windows, which natively recognize a DVD-ROM drive as such, Linux by default sees a DVD-ROM drive as a CD-ROM drive. Without additional configuration, Linux can use a DVD-ROM drive to read a CD-ROM data disc and may be able to read a DVD-ROM data disc formatted as ISO-9660. That's where it ends, however. By itself, Linux cannot read UDF-formatted discs, which is to say standard DVD-ROM and DVD-Video discs, and it cannot play DVD movies.

In this respect, Linux is similar to Windows NT 4. Although neither understands DVD natively, that problem is not insurmountable. Either operating system can access data and video DVD discs with the help of player applications, many of which are available for Linux. Chances are your Linux distribution installed several player applications by default. If not, it's easy enough to locate, download, and install the player applications you need.

Configuring an ATA/ATAPI (not SCSI) DVD-ROM drive for optimum performance under Linux is straightforward. Add the following line to your startup script:

/usr/sbin/hdparm -c1d1k1 /dev/hdc

Substitute the appropriate device for /dev/hdc if your DVD-ROM drive is other than Secondary Master (hdc). Our editor, Brian Jepson, notes, "As a general rule when working with hdparm, I usually leave it at -k0 for a couple of days, then check the logs for error messages and use hdparm to verify that it kept the settings. If all is well, I'll change the script to use -k1. If all is not well, I usually have to stop using -d1 unless I can figure out why it didn't keep."

You may also set up the DVD-ROM drive as a raw device for playback, which can increase read performance dramatically. To do so, add the following line, again substituting the appropriate device if your DVD-ROM drive is configured as something other than Secondary Master, and tell your DVD applications to read from /dev/raw/raw1 instead of /dev/hdc:

/usr/bin/raw /dev/raw/raw1 /dev/hdc

Configuring a DVD writer under Linux may be more problematic. If your DVD writer uses a SCSI interface, most recent Linux versions automatically detect its capabilities and install it as a writable device. If your DVD writer uses the ATAPI interface, configuring it requires a few extra steps. By default, current versions of Linux recognize an ATAPI DVD writer as a CD-ROM drive and use the standard ide driver. To enable write support on an ATAPI DVD writer, you must configure the DVD writer to use the ide-scsi SCSI emulation driver rather than the standard ide driver. Once you do that, Linux recognizes the DVD writer as a writable SCSI device and you can write to the drive using applications such as dvdrtools (http://www.nongnu.org/dvdrtools/) as well as standard Linux copy, archiving, and backup utilities.

In the following sections, we take you through the process we used to install, configure, and test an elderly Hitachi ATAPI DVD-RAM drive that we installed in an existing Linux system. That system initially had a Seagate hard drive as Primary Master and a Plextor CD writer as Secondary Master. We shut down the system, popped the lid, and installed the Hitachi DVD-RAM drive as Secondary Slave. We then put the system back together, connected all the cables, and fired it up. The following sections take it from there. Viewing drive parameters

The first thing to verify is that Linux sees the new drive, and the easiest way to do that is to look at the list of the optical drives that Linux thinks are present. To view parameters for the installed drives, display /proc/sys/dev/cdrom/info. This file lists the hardware capabilities of each optical drive and establishes that Linux recognizes that the drive is present. Example 12-1 shows the info file for a PC with two optical drives installed: a CD writer as Secondary Master and a DVD-RAM drive as Secondary Slave.

Example 12-1. The info file for a PC with a CD writer and a DVD-RAM drive installed
CD-ROM information, Id: cdrom.c 3.12 2000/10/18

drive name:            sr0     hdd
drive speed:           32      0
drive # of slots:      1       1
Can close tray:        1       1
Can open tray:         1       1
Can lock tray:         1       1
Can change speed:      1       1
Can select disk:       0       0
Can read multisession: 1       1
Can read MCN:          1       1
Reports media changed: 1       1
Can play audio:        1       1
Can write CD-R:        0       0
Can write CD-RW:       0       0
Can read DVD:          0       1
Can write DVD-R:       0       0
Can write DVD-RAM:     0       1

This example shows drive status immediately after the DVD-RAM drive was installed. The CD writer had already been configured to use the ide-scsi driver, which allows it to write discs as well as read them. Because the DVD-RAM drive is using the standard ide driver, it is shown as hdd rather than sr1. Enabling the ide-scsi driver

Although Linux recognizes the DVD-RAM drive immediately after it is installed, it does so using the standard ide driver. By default the standard ide driver takes control of all IDE devices, including ATA hard drives and ATAPI optical drives. The standard ide driver is sufficient for hard drives and for read-only optical drives, but writable optical drives require SCSI emulation. The ide-scsi driver provides that emulation.

Linux supports SCSI CD writers and DVD writers directly. The ide-scsi driver is necessary only to provide SCSI emulation to ATAPI CD/DVD writers. Some recent Linux releases recognize CD/DVD writers at install time and automatically enable ide-scsi support. If you are using an earlier release or adding an ATAPI CD or DVD writer to an existing system, you may need to enable ide-scsi support manually.

The easiest way to enable ide-scsi emulation is to add or edit a line in your boot configuration file. First, use the command grep ATAPI /var/log/dmesg to verify drive configuration. You should see output similar to that shown in Example 12-2. In this example, the DVD writer for which we want to enable SCSI emulation via the ide-scsi driver is currently recognized by the system as hdd, under the control of the standard ide driver.

Example 12-2. Using the grep command to verify drive configuration
[thompson@caldwell thompson]$ grep ATAPI /var/log/dmesg
hdd: HITACHI GF-1000 B, ATAPI CD/DVD-ROM drive
hdd: ATAPI DVD-ROM DVD-RAM drive, 512kB Cache
scsi0 : SCSI host adapter emulation for IDE ATAPI devices
[thompson@caldwell thompson]$

To enable ide-scsi for hdd using the grub bootloader, log on as root and edit the file /boot/grub/grub.conf. In the kernel line, add the text hdd=ide-scsi. Example 12-3 shows grub.conf with the added text in bold.

Example 12-3. The grub.conf file with ide-scsi emulation for hdd added
title Red Hat Linux (2.4.18-18.8.0debug)
 root (hd0,0)
 kernel /vmlinuz-2.4.18-18.8.0debug ro root=LABEL=/ hdc=ide-scsi hdd=ide-scsi
 initrd /initrd-2.4.18-18.8.0debug.img
title Red Hat Linux (2.4.18-18.8.0)
 root (hd0,0)
 kernel /vmlinuz-2.4.18-18.8.0 ro root=LABEL=/ hdc=ide-scsi hdd=ide-scsi
 initrd /initrd-2.4.18-18.8.0.img

To enable ide-scsi for hdd using the lilo bootloader, log on as root and edit /etc/lilo.conf. If there is an existing append line, simply add the text hdd=ide-scsi to that line. If there is no append line, add the line append="hdd=ide-scsi". Example 12-4 shows lilo.conf with the added text in bold.

Example 12-4. The lilo.conf file with ide-scsi emulation for hdd added

 append="hdc=ide-scsi hdd=ide-scsi root=LABEL=/"

After you restart the system, examine /proc/sys/dev/cdrom/info to verify that the DVD writer is using the ide-scsi driver. In Example 12-5, the DVD-RAM drive now appears as sr1 rather than hdd, indicating that it is now controlled by the ide-scsi driver.

Example 12-5. /proc/sys/dev/cdrom/info showing that the DVD writer now uses the ide-scsi driver
CD-ROM information, Id: cdrom.c 3.12 2000/10/18

drive name:            sr1     sr0
drive speed:           0       40
drive # of slots:      1       1
Can close tray:        1       1
Can open tray:         1       1
Can lock tray:         1       1
Can change speed:      1       1
Can select disk:       0       0
Can read multisession: 1       1
Can read MCN:          1       1
Reports media changed: 1       1
Can play audio:        1       1
Can write CD-R:        0       1
Can write CD-RW:       0       1
Can read DVD:          1       0
Can write DVD-R:       0       0
Can write DVD-RAM:     1       0

You can also examine the file /var/log/dmesg to verify that the system is using the ide-scsi driver for the DVD writer, as well as to obtain other information. The two ide_setup lines in Example 12-6 indicates that the ide-scsi driver is being used for hdc and hdd. The hard drive (hda) is using DMA mode, as is the CD writer (hdc). Although hdb is shown as using PIO mode, in fact there is no device connected as Primary Slave.

Example 12-6. /var/log/dmesg showing that the DVD writer uses ide-scsi but operates in PIO mode
[thompson@caldwell var]$ grep ide /var/log/dmesg
BIOS-provided physical RAM map:
Kernel command line: ro root=LABEL=/ hdc=ide-scsi hdd=ide-scsi
ide_setup: hdc=ide-scsi
ide_setup: hdd=ide-scsi
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
    ide0: BM-DMA at 0xffa0-0xffa7, BIOS settings: hda:DMA, hdb:pio
    ide1: BM-DMA at 0xffa8-0xffaf, BIOS settings: hdc:DMA, hdd:pio
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
ide1 at 0x170-0x177,0x376 on irq 15
ide-floppy driver 0.99.newide
ide-floppy driver 0.99.newide
EXT3 FS 2.4-0.9.18, 14 May 2002 on ide0(3,2), internal journal
EXT3 FS 2.4-0.9.18, 14 May 2002 on ide0(3,1), internal journal
[thompson@caldwell var]$

The status line for ide1 is cause for concern. That line indicates that the Secondary interface is operating in BM-DMA (bus mastering DMA) mode, but it also shows that the BIOS is reporting hdd (the DVD-RAM drive) as PIO mode. There's a possible conflict here, because both devices on an ATA interface must operate in either PIO mode or DMA mode. Interfaces don't support two devices operating in different modes, so this line is oxymoronical.

There is no reason the DVD-RAM drive should operate in PIO mode. The drive is DMA-capable, as are the interface and the cable. This may be just an initial status report and Linux may configure the DVD writer to use DMA later in the boot process. It's worth checking, though, because if this interface really is being forced to use PIO mode, the CD writer will no longer work properly.

When in doubt, use hdparm to verify the current operating status of drives. Example 12-7 shows the output of hdparm -i for both optical drives. Both use DMA, although the DVD writer is configured as an MDMA-2 device and the CD writer as UDMA-2. Because both devices on an interface must use the same DMA level, that means the CD writer will use MDMA-2 (16.7 MB/s), but that is more than fast enough to support 24X CD writing.

Example 12-7. hdparm showing that both optical drives are using DMA
[root@caldwell sbin]# ./hdparm -i /dev/hdd


 Model=HITACHI GF-1000 B, FwRev=I0I0, SerialNo=
 Config={ Fixed Removeable DTR<=5Mbs DTR>10Mbs nonMagnetic }
 RawCHS=0/0/0, TrkSize=0, SectSize=0, ECCbytes=0
 BuffType=unknown, BuffSize=0kB, MaxMultSect=0
 (maybe): CurCHS=0/0/0, CurSects=0, LBA=yes, LBAsects=0
 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio1 pio2 pio3 pio4
 DMA modes:  sdma0 sdma1 sdma2 mdma0 mdma1 *mdma2

[root@caldwell sbin]# ./hdparm -i /dev/hdc


 Model=PLEXTOR CD-R PX-W2410A, FwRev=1.03, SerialNo=137699
 Config={ Fixed Removeable DTR<=5Mbs DTR>10Mbs nonMagnetic }
 RawCHS=0/0/0, TrkSize=0, SectSize=0, ECCbytes=0
 BuffType=unknown, BuffSize=0kB, MaxMultSect=0
 (maybe): CurCHS=0/0/0, CurSects=0, LBA=yes, LBAsects=0
 IORDY=on/off, tPIO={min:180,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio1 pio2 pio3 pio4
 DMA modes:  sdma0 sdma1 sdma2 mdma0 mdma1 mdma2
 UDMA modes: udma0 udma1 *udma2

[root@caldwell sbin]# Formatting a disc

After determining that the DVD-RAM drive is configured properly, the next step is to verify that the DVD writer can write to a disc. Formatting a disc is an easy test. To do that, we use the command mke2fs -c -v -b 2048 -m 0 /dev/scd1, where:

  • mke2fs?creates a Linux second extended filesystem

  • -c?checks for bad blocks

  • -v?provides verbose output

  • -b 2048?uses blocksize 2,048

  • -m 0?reserves zero blocks for superuser

  • /dev/scd1?the device to be formatted

After we issue that command, the DVD-RAM access light begins blinking, and the text shown in Example 12-8 appears.

Example 12-8. A verbose display when formatting a disc with mke2fs
[root@caldwell sbin]# ./mke2fs -c -v -b 2048 -m 0 /dev/scd1
mke2fs 1.27 (8-Mar-2002)
Filesystem label=
OS type: Linux
Block size=2048 (log=1)
Fragment size=2048 (log=1)
304800 inodes, 1218960 blocks
0 blocks (0.00%) reserved for the super user
First data block=0
75 block groups
16384 blocks per group, 16384 fragments per group
4064 inodes per group
Superblock backups stored on blocks:
        16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816

Running command: badblocks -b 2048 -s /dev/scd1 1218960
Checking for bad blocks (read-only test): done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@caldwell sbin]#

After the format completes and you mount the device, you can read and write to the drive as you would to any other volume.