CD/DVD/BD writing

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

Install cdrtools or dvd+rw-tools packages, for writing CD/DVD/BD media. $ emerge cdrtools

Or, $ emerge dvd+rw-tools

For UDF writing, ensure you've included the above mentioned UDF kernel drivers and the following package, $ emerge udftools

Best practice is to use read write (RW/RE) media for testing writing ISO9660/UDF filesystem images. If a command incanatation fails to work, or the hardware or media fails, you can try try again. Direct file copy operations with CD/DVD/BD media may be slow and still risky sometimes?

Find Size of Media
First, find the maximum size the media can contain.

$ dvd+rw-mediainfo /dev/sr0 Track Size:           24438784*2KB (Or 24438784*2KB = 48877568 KB)

This is for 50GB Blu-Ray media. $ truncate -s 48877568KB test.udf

Or you can use the following with disabling Defect Management, $ truncate --size=50GB ./test.udf

NOTE: Defect Management sets aside 256MB aside during formating and also reduces write to half speed. See below Writing section for specifics.

Create and Populate Filesystem
Create either a ISO9960 or UDF filesystem. Microsoft Windows uses lvid. $ mkudffs --lvid="MY_VOLUME" --utf8 ./test.udf

Mount the filesystem $ sudo mount -oloop,rw ./test.udf /mnt/tmp/

Populate filesystem $ rsync -ax --delete /home/roger/Documents/ /mnt/tmp/

Verify proper permissions are preserved $ chown -R roger.roger /mnt/tmp $ chmod -R a+r /mnt/tmp $ chmod -R go-w /mnt/tmp

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. /dev/pktcdvd/0 /mnt/udfwrite  udf             user,noauto,noatime,utf8  0  0

DVD/BD (RW/RE) Media
DVD-RW,DVD+RW and 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.

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

UDF
TODO

BD Defect Management
By default growisofs uses Defect Management which requires 256MB extra space and uses reduced write speeds. You may disable this with, $ dvd+rw-format /dev/dvd -ssa=none

And use the following after writing to ensure files are properly written. $ diff -r /home/roger/Documents/ /mnt/tmp/

ISO
$ growisofs -Z /dev/sr0=test.iso

UDF
Atypically, you can write with the following as long as you are within the limits of your DVD/BD media's size limitations. $ growisofs -dvd-compat -Z /dev/sr0=test.udf

If you have used the above truncate with 25GB/50GB, specifying the top limits of BD media, you will need to disable Defect Management requiring 256MB extra space. $ growisofs -use-the-force-luke=spare:none -dvd-compat -speed=4 -Z /dev/sr0=test.udf