Recording Optical Media using UDF Filesystems

2022.08.21 WORK IN PROGRESS

Microsoft Windows started using UDF filesystems for writing optical media since ~2010, while Linux programmers/maintainers/users continue using ISO or UDF emulated (or workaround/hacked) ISO specification filesystem when writing/recording to optical media.

The process of writing a UDF filesystems to optical media documented below seems to indicate similar bit by bit sample comparisons, between the process documented below and the process used for writing optical media using Microsoft Windows 10 verions.

As to why nobody has documented the below process for the past ~10 years, shrugs... but for me, after figuring this out over the past five or more years, had a lack of time for writing such documentation. The only Linux frontend (or program I'm aware of) for writing actual UDF filesystems is CDW. (Copyright 2016 Kamil Ignacak and available via SourceForge.net, a command line console based optical writing/recording software tool.) CDW mostly writes and records ISO filesystems, and is only able to write the UDF filesystem image file with your files, or not being able to record the resulting UDF image file to optical media. However, writing/recording the final UDF image file, as documented below, is quite easily done!

Below will instruct edumacated UNIX/Linux console users how to manually create and write/record a UDF filesystem image file to optical media. My intention is to, sometime within the future, maybe with time, create a simple script (not using Python scripting) for automatation.

Create an initial image file

TODO: Insert exact byte sizes for some popular multiple optical media types, for preventing writing larger image files than an optical media's size.

Creates a simple file not containing the size of a 50GB file, or merrily a template of a file, called a sparse file. Sparse file sizes can be viewed by using "/bin/ls -s", omit using conflicting ls options else ls will not print the sparse file size.

$ truncate --size=50GB ./test.udf

Create/Format the UDF Filesystem

NOTE: Do not use "mkudffs --media-type", explicitly specifying standard optical media 2048 block size seems best!

Create/format the image file with a UDF filesystem, using a typical block size for use with optical media, with a basic volume name typically displayed when using automatic mounting software.

NOTE: Volume Name/ID has a 16 or 30 characters?

$ mkudffs --utf8 --blocksize=2048 --lvid="VOLUME NAME" test.udf

4GB DVD+R 4700372992 bytes

4GB DVD+RW 4700372992 bytes

25GB BD-R 25025314816 bytes (not formatted or no defect management)

50GB BD-R 50050629632 bytes (not formatted or no defect management)

The growisofs tool will format and use defect management, reducing available disc size.

The tools cdrecord, libburn, cdrskin, by default, will not typically format or use defect management.

Make a Temporary Mount Point, Mount Image File, and Change Ownership/Permissions

NOTE: This process typically requires "sudo" or root privilages.

The following will, create a temporary mount folder location and change ownership/permissions for viewing by the user and/or the general public.

# mkdir /mnt/tmp # chmod -R a+rwX /mnt/tmp

Mount the created truncated/sparse file with UDF filesystem temporary /mnt/tmp location for direct editing."

$ sudo mount -t udf -o uid=forget,gid=forget,dmode=777,mode=777 test.udf /mnt/tmp

Another more manual/rudimentary method of mounting the image file:

# mount -oloop,rw ./test.udf /mnt/tmp/
# chown -R user_name.group_name /mnt/tmp
# chmod -R a+rX /mnt/tmp

Copy Files

Freely copy over and edit your files to your mounted UDF filesystem temporary mount point.

$ cp -rf /some_folder/some_files /mnt/tmp/

Or preferably,

$ rsync --copy-links --omit-dir-times --recursive --times --verbose ./some_files/ /mnt/tmp/

NOTE: Omitting directory times seems to be required for omitting setting directory times on the top directory, even though there are adequate permissions set. Shrugs, bug?

Unmount the Filesystem Image File

NOTE: This process typically requires "sudo" or root privilages.

Unmount the filesystem image file

# umount /mnt/tmp

For Bluray Media: Disable Spare Defect Space Usage

Bluray optical media uses additional (invisible to the user) space for defect management while writing. Defect management can be disabled for bluray media when needing to use the maximum available size/space of the optical media at a slight risk of not having defect management for faulty writes.

dvd+rw-format -ssa=none /dev/sr0

If using growisofs for writing the UDF image file, can perform this step during the growisofs image writing process with the additional "growisofs -use-the-force-luke=spare:none" paramenter/argument.

Write the UDF Image File

Write the UDF image file to your optical media.

cdrecord speed=4 dev=#,0,0 driveropts=burnfree ./test.img

NOTE: Substitute "#" with your optical media writer's device number, via "cdrecord -scanbus", using caution not to overwrite your root filesystem!

NOTE: I've had lots of problems with bluray media's maximum stated write speed and my many LG optical writer devices. Although plausible the SATA bus maybe being overly saturated or using maximum bandwidth, I've always had to specify the next lesser maximum write speed of the optical media for successful recording sessions. Use " cdrecord -prcap |grep peed" for finding your inserted optical media's maximum write speed. The maximum speed is used by default by cdrecord."