41

Several time recently I've seen UDF suggested as the solution to a cross platform format for a drive used on Linux, Mac OS X and Windows XP and above.

I've searched here and not found the same suggestion (most are suggesting ntfs-3g which seems to cost money and isn't preinstalled on a Mac).

So my question is: how is this done right, and has anyone done this? Have you then filled up the drive and deleted some files to make space finding that everything works like a real r/w format even though it seems to have been primarily a write once format?

Call me crazy but I'd really like it if the UDF system would also automount and be writable by the logged in user. What I've tried so far (udftools formatting as mentioned by kicsyromy) doesn't address this wish.

dlamblin
  • 857

3 Answers3

23

Someone did some research into how to format a flash drive with udf so it can be used on as many operating systems as possible. Here are his findings (used to be there, now offline):

  • Windows 7 have full support up to UDF v2.6, but the UDF block size must match the block size of the underlying device (which for USB-sticks and most disks is 512 bytes; "advanced format" disks are 4096 bytes). Apparently the disk must be partitioned.

  • Linux 2.6.30 and up supports UDF fully at least up to version 2.5.

  • Mac OS X 10.5 supports UDF fully up to UDF 2.01, but only when used on a full disk, so not partitioned.

As explained above, for USB harddisks, Windows requires the disk to be partitioned. On the other side, UDF only works in OS X when it is used on a full disk (unpartitioned). Rather surprisingly, there is a solution which works for both: having the disk partitioned and unpartitioned at the same time.

DOS partition tables are stored in bytes 446-510 of the master boot record. This master boot record is stored in the first sector on disk, sector 0. Typically, the first partition specified will start some kilobytes further. However, it seems possible to construct a partition table whose first partition starts at sector 0, so the result is a partition which contains the partition table itself. Partition editor programs seem to refuse to create such a table, but at least recent Linux and Windows kernels don’t seem to bother.

The nice thing is that UDF does not (I suppose deliberately) use the first few kilobytes of the partition or disk it is placed on, so this place can really be used to store a legacy partition table, referring to a partition that spans the whole disk. Some testing shows that this really works on Linux, Windows and Mac OS X:

  • Mounts automatically read-write in Linux 2.6.30+, Mac OS X 10.5+, Windows Vista+
  • Can be used read-only in Windows XP, and be used after a command line mount in Linux 2.6.0+
  • Supports large files, UNIX permissions, Unicode filenames, symlinks, hardlinks, etc.

Script to format the disk properly: Perl script or Bash script

phuclv
  • 760
19

No.

We're in 2015 at the time of this reply. I am using OSX Yosemite, Ubuntu 14.10, and the Windows 10 technical preview for enterprises on a Mactel machine (Macmini 7,1).

I tried both UDF and exFat. I use Ubuntu for development and do need Unix-style permissions.

All former guides do not apply anymore: UDF drivers have evolved and all operating systems will accept a UDF partition, with more problems and instabilities than I can name.

  • UDF drive formatted on Mac OS: can't be mounted on Windows 10.
  • UDF drive formatted on Linux: can't be mounted on Windows 10.
  • UDF drive formatted on Windows 10: mounts read/write on Linux, read-only on OSX.

However, Windows doesn't allow you to specify a block size when formatting a UDF volume, and as a result, your logical block size might differ from the physical block size for the partition.

I am unclear whether this has to do with the difficulties I had mounting it read/write on OSX, but after deleting a certain number of files using Linux, I was never able to mount the drive again on OSX.

The system goes into kernel panic and crashes disgracefully.

This, and a variety of answers on the subject, indicate inconsistent support for this format at this point.

It would seem there are ways I can use a NTFS volume to achieve a balance between the features of a modern file system, Unix-style permissions - I might be able to set them - and read/write mount on all operating systems.

14

I just tested this out in a VM. It seems that you need to (re)create your partition in Windows assign it a drive letter but don't format it to any filesystem. After that boot into Ubuntu and just follow the directions and it should work for read/write.

Remember to backup all your data!

First off install UDF tools:

sudo apt-get install udftools

Replace the first block with nothing on the partition you wish to format to UDF^:

sudo dd if=/dev/zero of=/dev/sdxN bs=512 count=1

And finally format to UDF^:

sudo mkudffs --media-type=hd --blocksize=512 /dev/sdxN

^where by:

  • x is a placeholder for the letter curently assigned to your hardisk

  • N is a placeholder for the partition number

Best of luck and let me know if it worked out for you.

kicsyromy
  • 790