CD/DVD/BD writing

From Gentoo Wiki
Jump to:navigation Jump to:search
Article status
This article has some todo items:
  • Describe how to write UDF images to CDs

This article describes how to burn optical disks on Gentoo from the command line with the app-cdr/cdrtools or app-cdr/dvd+rw-tools packages.

See also
See the LiveUSB article for information on writing iso files to USB devices.

Installation

Kernel

Configure the kernel to support the filesystems necessary for reading and writing ISO disks.

KERNEL Enable ISO 9660 and UDF filesystem support
File systems  --->
   CD-ROM/DVD Filesystems  --->
      <*> ISO 9660 CDROM file system support
      [*]   Microsoft Joliet CDROM extensions
      [*]   Transparent decompression extension
      <*> UDF file system support

Emerge

Follow the CDROM page for hardware driver kernel configuration, along with including UDF write support.

Install the app-cdr/cdrtools or app-cdr/dvd+rw-tools packages, for writing CD/DVD/BD media:

root #emerge --ask app-cdr/cdrtools

Or:

root #emerge --ask app-cdr/dvd+rw-tools

For UDF writing, ensure included the above mentioned UDF kernel drivers and the following package:

root #emerge --ask sys-fs/udftools

Best practice is to use read write (RW/RE) media for testing writing ISO9660/UDF filesystem images. If a command fails to work, or the hardware or media fails, you can try again.

Usage

Usage for the ISO9660/UDF filesystem.

Determine the size of media

First, find the maximum size the media can contain.

user $dvd+rw-mediainfo /dev/sr0
Track Size:            24438784*2KB

Or 24438784*2KB = 48877568 KB for 50GB BD-R DL (Blu-ray dual layer) media.

user $truncate --size=48877568KB test.udf

Or you can use the following with disabling defect management:

user $truncate --size=50GB ./test.udf
Note
Defect management sets aside 256MB aside during formatting and also reduces write to half-speed. See the writing section below for specifics.

Create and populate filesystem

Create either a ISO9660 or a UDF filesystem. Microsoft Windows uses lvid for optical media title:

user $mkudffs --lvid="MY_VOLUME" --utf8 ./test.udf

Mount the filesystem:

user $sudo mount -oloop,rw ./test.udf /mnt/tmp/

Populate filesystem:

user $rsync -ax --delete /home/larry/Documents/ /mnt/tmp/

Verify proper permissions are preserved:

user $chown -R larry.larry /mnt/tmp
user $chmod -R a+r /mnt/tmp
user $chmod -R go-w /mnt/tmp

Writing

CD-RW media

CD-RW media requires the packet device driver and starting the /etc/init.d/pktcdvd service and the following line within /etc/fstab:

FILE /etc/fstab
/dev/pktcdvd/0  /mnt/udfwrite  udf             user,noauto,noatime,utf8  0 0
Note
Within the Linux kernel, the pktcdvd driver has been marked as deprecated since 2016 and slated for removal in 6.2. Removal was temporarily postponed. Instead it is recommended to try writing directly to CD-RW media formatted and mounted with the UDF filesystem.

DVD/Blu-ray (RW/RE) media

DVD-RW, DVD+RW, DVD-RAM, and Blu-ray Recordable Erasable (BD-RE) media can be easily written by simply mounting the media and writing to the media as a normal filesystem, as these devices and media allow random writing, versus CD-RW only allowing sequential writing.

The following simply automates writing a ISO9660 by piping to mkisofs, then writing.

user $ growisofs -dvd-compat -rock -V "TITLE" ./some/files /dev/sr0

The commands mkisofs/growisofs provide the "-udf" option for writing a bridged/hybrid ISO9660/UDF filesystem. This option may waste disc space, upwards of 483,328 bytes or sectors 20-256. See mkisofs "-UDF" option.

Verify write session:

user $ diff -urN ./some/files /mnt/dvd/

Image writing

CD writing

ISO
user $cdrecord -scanbus
user $cdrecord -speed=40 dev=2,0,0 -eject -dao driveropts=burnfree test.iso

DVD/Blu-ray

BD defect management

By default growisofs uses defect management which requires 256MB extra space and incurs a penalty of ~50% reduced write speeds. This may be disabled via:

root #dvd+rw-format /dev/dvd -ssa=none

Disabling comes with the tradeoff of making the disk more prone to failed burns, if used burns should be done at slowest supported speed and with new and high-quality disks. This option may be preferable for archivists used to generating their own parity data.

ISO
user $growisofs -Z /dev/sr0=test.iso
UDF
UDF Direct Writing

For writing, modifying, removing files to/from UDF filesystem mounted DVD and Bluray media, users only require the common cp and rm tools.

Linux kernel requirements, compile without pktcdvd or blacklist the module for avoiding conflicts, include the usual SCSI related drivers for the optical drive and enable the UDF filesystem driver. Verify and/or recompile, reboot as needed.

First, insert a blank DVD/BD rewritable disc:

root #dvd+rw-format /dev/sr0
Note
DVD+RW and BD-RE media only require formating once! See dvd+rw-format man.
root #mkudffs -l video /dev/sr0

Then, mount the filesystem:

root #mount -t udf -o rw,noatime /dev/sr0 /mnt/dvd

From here, the UDF filesystem mounted disc can be used as a normal writable mount.

Finally, verify any write operations:

root #diff -urN /your/file /mnt/dvd/your/file

If needed, monitor /var/log/messages for mounting/write operations.

If drive operations are excessively slow or delayed, use "dvd+rw-format -lead-out" for improving disc compatibility. Read dvd+rw-format author/maintainer's website notes. Also if possible, specifying the booktype via dvd+rw-booktype may help but is untested here as of writing this.

UDF Image Writing

An alternative command to write a UDF filesystem to the disk where the user is certain it will fit after factoring in some overhead for Defect Management (typically 24GB or less for single-layer):

user $growisofs -dvd-compat -Z /dev/sr0=test.udf

If the above truncate command is used with 25GB/50GB specified for BD media, it is required to disable Defect Management to fit the image (else the burn will fail):

user $growisofs -use-the-force-luke=spare:none -dvd-compat -speed=4 -Z /dev/sr0=test.udf

See also