Don’t ask why. I just though it might be a cool idea.

So what’s the catch? Packet writing over CD/DVD-/+RW media is pretty much the same as writing to a block device. The only bad thing is that:

  • Writes MUST be aligned
  • Writes must be of a fixed packet size
  • Before reading you must issue a flush command.

To hide this from the upper level pktcdvd module exists that assembles packets and sends them to the media. Well, this whole pktcdvd machinery reminded me of a NAND device actually, so I wondered if we could actually make an MTD device out of a CD or DVD. AND run UBIFS on top of it. (Or yaffs2. whatever). Details&code under the cut

I took block2mtd driver as a starting point and added a few hacks. Whever we do a write or erase a ‘flush’ command is issued before the following read to follow the spec.
I also added the ability to set the writesize from the command line. The erase size should be some multiple of write-size, 32k minimum for ubifs. Basically, this is the minimal stuff that is needed to run ubifs ontop of DVD+RW media. Ubifs proved to be quite fast and reliable for that, and gave me less issues than UDF  (apart from being totally incompatible with anything but linux. But, who cares?) on-the-fly compression is also a nice bonus.

This is only a proof-of-concept implementation, so it has some drawbacks.

  • No drive/media speed setting whatsoever.
  • No autodetection of suitable writesize nd disc size. (use dvd+rw-mediainfo to get a hint, very little sanity checks)
  • DVD-RW/CD-RW might need extra magic. May not work. Only DVD+RW tested.
  • Erasing slows down things and wears out media. This can be achieved by keeping a clean block table in ram and freeing it afterwards.
  • No bad block detection or handling whatsoever. Yet. Needs a proper BBT like NAND (from file?)
  • ubimkvol/ubiformat take ages to complete.

Find the patched block2mtd module here: https://github.com/nekromant/ubi2pkt

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.