Burn Bluray data disks on Linux, minimize coasters

This article will show how you can burn a pure UDF filesystem to a bluray disc. After many failed attempts, I found the following set of commands never failed to make a proper disc.

UDF is able to overcome many shortcomings over previous ISO file systems, things like file path length, individual file size and so on. It's also compatible across all modern operating systems. For example, if you're a mac user, who needs to burn a dvd/bluray for someone on Windows, the following tools will work for you as well. Note that you will be on your own for figuring out how to install them.

You will need the following packages:

  • udftools For the mkudffs command for generating a UDF filesystem
  • losetup Which should be a part of your Linux distro by default
  • cdrtoolds-3.01 You won't be able to get this package from your distribution if you're running Debian/Ubuntu. See instructions below for where to get it.

Create the disc image

> truncate -s 25GB MYBLURAY-DISC.udf
> mkudffs MYBLURAY-DISC.udf

start=0, blocks=16, type=RESERVED 
start=16, blocks=3, type=VRS 
start=19, blocks=237, type=USPACE 
start=256, blocks=1, type=ANCHOR 
start=257, blocks=16, type=PVDS 
start=273, blocks=1, type=LVID 
start=274, blocks=12206500, type=PSPACE 
start=12206774, blocks=1, type=ANCHOR 
start=12206775, blocks=239, type=USPACE 
start=12207014, blocks=16, type=RVDS 
start=12207030, blocks=1, type=ANCHOR

The truncate command as used above creates an empty file of the right size for us to work with immediately. The command mkudffs can take an image as an argument and set it up for mounting right away, no need to attach the image as a block device first.

By default, mkudffs will name the image "LinuxUDF" on mount, to change this, add the additional argument:

> mkudffs --vid="My Label" MYBLURAY-DISC.udf

In order to put files onto the image you just created, you attach it to a logical block device.

> sudo losetup -f MYBLURAY-DISC.udf

Now the disc should immediately be available under your file manager. If your file manager doesn't detect the block device then mount it manually.

Example file manager

First check which block device the image is attached to:

> sudo losetup -a
/dev/loop0: [0019]:7 (/mypath/MYBLURAY-DISC.udf)

Then use the mount command as you normally would. You don't actually need the -o loop mount option, since it has already been attached to a loop device with the losetup command.

> sudo mount /dev/loop0 /mnt

Now you write the files/folders you want to the mounted directory. The great thing about this is the fixed size of the image, you won't accidentally make it too large to be burned to disc.

When you finish adding files, you MUST REMEMBER TO DISMOUNT THE FILESYSTEM AND DETACH THE DISC. Failure to do so will corrupt your data. If you mounted to image through your file manager, just press the eject button, otherwise simply:

> sudo umount /dev/loop0

Then you need to detach the loop device with:

> sudo losetup -d /dev/loop0

You can now proceed to actually burning the data to disc.

Burning the image with cdrecord

A terrible photo of my bluray drive

Getting the latest cdrecord

Here is where things become a little complicated. As of late there has been some controversy within the Debian/Ubuntu communities regarding the license chosen by Jörg Schilling, author of cdrecord and related tools. You can read up on it on Schilling's site.

You will need to the latest version of cdrecord to reliably burn with bluray drives, and the only way to really do this is to compile from source. If you search around, you might also be able to find a pre compiled version for your distribution, such as an Ubuntu PPA or something.

Its worth the effort of compiling this application, its absolutely rock solid at what it does. This actually compiles more than just cdrecord including tools for generating an ISO/UDF hybrid file system. It isn't possible to use these tools to generate a pure UDF file system, and I have had nothing but issues trying to use its hybrid capabilities.

Grab the latest version of the source and unzip it into a directory. The author's preferred method is to use a variation of make, called smake, however it is still possible to use the regular GNU make with the Gmake files included in the zip file.

> tar xf cdrtools-beta.tar.gz
> cd cdrtools-3.01
> make

Note: If you choose to perform make install, it will install everything into /opt/schilly rather than the usual /usr/local/.... Graphical applications such as kd3 will look in that location by default.

If you want install to put the files somewhere else, the documentation lists that you set an environment variable as follows:

> sudo make INS_BASE=/usr/local install

Choosing not to install to path

You can just use the cdrecord binary without running the make install command. Just specify the full path to the binary like so:

> /opt/schilly/cdrtools-3.01/OBJ/x86_64-linux-cc/cdrecord --version
Cdrecord-ProDVD-ProBD-Clone 3.01a14 (x86_64-unknown-linux-gnu) Copyright
(C) 1995-2013 Joerg Schilling

Test the command using the line above, it should report something along the lines of version 3.0-3.01.

Actually burning the image

Now it's time to call cdrecord with the image created earlier as an argument. You will need to give cdrecord some information, such as the path to the bluray burner and some very important options.

> /path/to/cdrecord -v -doa driveropts=burnfree \
    dev=/dev/sr0 MYBLURAY-DISC.udf

Let's break this down:

-v, normally I would consider turning on verbose output optional, but not in this case. Without this you get almost no feedback from the application. When this is on, you also get a countdown which allows you to look at some diagnostics before you actually commit to burning the disc.

-doa, specify disc at once mode, we are not going to be writing to the disc a second time.

driveropts=burnfree, checks the drive to see if it has an option called burnfree. This is really important if you want to avoid randomly ruining discs. When active, it allows the data buffer to the drive to become completely exhausted without ruining the data stream. Without this, if your computer can't keep up with the data transfer and the data buffer empties, your disc becomes unreadable.

dev=/dev/sr0, the path to the block device representing your bluray burner. Determining which dev device is your burner is a little out of the scope of this article, message me if you think it would be important to add this information.

Once the process finishes, you should have a solid UDF 2.01 formatted disc!

Please let me know if you find any issues with this guide, found it helpful, lacking, erroneous or deceitful. I take no responsibility for data lost, damage done, etc for anyone choosing to follow these commands.

I don't want to start a discussion as to whether or not optical data storage is a dead phenomenon. Though it is worth noting that the previous generation of optical media (CD's, DVD's) are notorious for degrading to an unreadable state in a short period of time (5 years or so).

Comments !