How to create UDF images and burn them to DVD or CDROM

burningdata-cddvd

Writing CDs with cdrecord and making images with genisoimage is no problem.

I want to write DVDs in a similar manner, first creating an image, then burning it to disk. This is quite beneficial, since I can inspect the image before burning it to disk.

Now, all I've seen, is how to use the growisofs command to burn something to DVD, but all how-to's were using ISO9660 for DVDs. But I want to burn UDF images. Before I can burn them, I need to make them, but how do I create UDF images?

Also, If you could explain, or link on how to burn BluRay, that would be great, too.

All tools must be command line, as I need to work with it, where GUI is no option.

Best Answer

There are in fact two ways of generating a UDF filesystem image on Linux, depending on your requirements.

Create a UDF/ISO-9660 image with mkisofs

The mkisofs tool has the ability to generate a combined UDF and ISO-9660 bridge filesystem in a single pass. This is a filesystem that stores both a UDF directory and a legacy ISO-9660 directory referring to the same file data (so the data is only stored once). Any modern operating system (Windows XP or newer) will access the UDF data and completely ignore the ISO-9660 information, so to all intents and purposes this is a UDF filesystem.

The advantage of this approach is that you can create the filesystem in one pass, starting with an input directory and ending with a populated filesystem image. This means you can also dump the output directly to growisofs and burn it straight to disk. The possible disadvantage is that there will be a small amount of space wastage due to the legacy ISO-9660 structures, and the resulting filesystem will not be writable (so you can't use it for your DVD-RAM or BD-RE media if you want to be able to modify the data on a mounted disk).

To generate such a filesystem image, you would use a command like:

mkisofs -udf -o myimage.udf -V MyDiskTitle /path/to/input/files

or to burn directly to disk:

growisofs -Z /dev/dvd -udf -V MyDiskTitle /path/to/input/files

Note that to use this option you need a recent version of proper mkisofs, not the abandoned and ancient genisoimage fork that ships with many Linux distributions.

Create a "pure" UDF filesystem with mkudffs

If you absolutely must have a pure UDF filesystem with no ISO-9660 data structures, you can use the mkudffs tool from the udftools package along with a loopback device to generate a local image. This requires more steps than using mkisofs above, but it is the only way to generate both a pure UDF filesystem and one which can be mounted read-write after being burned to random-access media like DVD-RAM or BD-RE.

First, you need to generate a blank file to contain the image. Here the size is given as 650 MB to match a standard CD, this will obviously need to be larger for a DVD/Blu-Ray. See this wikipedia article for the exact sizes of DVD media.

$ truncate -s 650M /tmp/cdimage.udf

Now invoke mkudffs to generate a UDF filesystem in this blank image:

$ mkudffs --media-type=dvdrw /tmp/cdimage.udf

See mkudffs(1) for other possible media types. Both truncate and mkudffs will create sparse files if your filesystem supports them; so the image won't occupy the full size unless you fill it.

Then you can mount your image locally to copy data to it

$ sudo mkdir /media/udfimage
$ sudo mount -t udf -o loop,rw /tmp/cdimage.udf /media/udfimage

After the data has been copied to the image, the process is followed in reverse to unmount the image and detach the loopback device:

$ sudo umount /dev/loop0
Related Question