Saturday, November 3, 2007

Not So Universal

Linux burns. When it comes to burning media, Linux is extremely proficient. Powerful command line tools such as growisofs, mkisofs, cdrecord, wodim and a multitude of others will come to your aid, along with intuitive GUI tools such as K3B or Nero for Linux. Even with this outstanding level of support, it looks like Linux does not have burning completely "down".

I needed to make a copy of a 6.5GB partition, hosting an array of files. All the files in this partition were in the kilobytes, however one weighed in at 6.3GB. No problem I thought, as I dusted off the old DVD+R Dual Layer disks that I've long been looking to fill. I fired up K3B and selected the partitions files to add and received an odd message:

Problems while adding files to the project. It is not possible to add files bigger than 4.0 GB.

Hmmm, this can't be the case. Feeling defiant I opened up Google and began to investigate. As always, I was suddenly barraged by the sheer volume of results, the majority relating either to a 1GB or 4GB UDF restriction. What is this "UDF" I asked myself, remembering it vaguely from my early CD-ROM burning days. Turns out its the Universal Disk Filesystem, a filesystem that can be found "on most authored optical discs in the market, and on almost all recordable DVD media that are used for video recording".

Advice for this issue was limited, however a few threads pointed to a solution which involved setting up a disk based UDF image and burning it to the media directly. For me, this involved:

  • Creating an empty image file of the right size with the following command:
dd if=/dev/zero of=/~/image.udf bs=1024 seek 7489799 count=1
  • The dd command is responsible for the "low-level copying and conversion of raw data".
  • The if operand represents the input file, in this case this is /dev/zero, a infinite source of zero fill data.
  • The of operand represents the output file, in this case the udf image.
  • The bs operand represents the block size for the file. 1024 for most operations.
  • The seek operand skips a certain number of blocks when writing to output. This means that we do not actually have to fill the image with 0s (which will only be replaced), and will result in a file creation time of milliseconds. Just think of them as virtual 0s.
  • The count operand dictates how many blocks will actually be written. In our case, our virtual 0s will suffice, and we can simply set count to 1.
  • We have our empty UDF image, the next step is to create the filesystem. We can use the mkudffs command to achieve this.
mkudffs /~/image.udf
  • Our new UDF image is now ready to be mounted. However slight tweaking is required to allow a file to be mounted. Previously I have used losetup to mount files, however the -o loop flag produces the same effect with little effort.
mount /~/image.udf /~/udf/ -o loop
  • The UDF filesystem is now mounted at /~/udf/ and ready to be written to.

0 comments: