(This is a follow-up to "What is the partition id / filesystem type for UDF?")
I know two ways to format a hard drive as UDF:
- Windows Vista or later: "
format x: /fs:UDF
" (don't use/q
! ) - Linux: "
mkudffs --media-type=hd --blocksize=512 /dev/sdx
"
The problem is that the 'other' OS does not recognize the disk as formatted at all: it simply refuses to mount it, no matter what commands I try.
How can I format a hard drive as UDF so that both Windows and Linux will be able to use it?
EDIT: updated the commands, now the result should work in either OS.
It turns out that using the
/q
switch on Windows was the culprit: it enables 'quick format', i.e. the formatting process continues in background with every write made to the disk. Once it finishes, the drive is handled by Linux just fine.When formatting UDF, one thing that can't be underscored enough is how important it is to use the proper block size when formatting UDF. As explained here, using a configured block size that doesn't match the physical sector size likely means that some operating systems will not be able to detect the drive as valid UDF.
Inspired by the above-linked answer (and my other research/testing), I wrote a script to automate the process of formatting in UDF--using the properly detected sector size. See format-udf on GitHub. Notable features:
Because of the last point, this script I wrote cannot be used on Windows. However, the script will run on OS X and Linux. After doing so, Windows should be able to magically detect the newly formatted UDF drive.
To directly answer the questions posted, format-udf will:
mkudffs
on Linux)blocksize
)How did you reconcile your discovery in the previous question (that the UDF filesystem should be created on the whole disk, not a partition) with that Windows command ("format x: /fs:UDF")? In my attempts, Windows only gives drive letters to partitions.
As far as formatting for compatibility, I think the key is in the block size. Since most hard drives and USB flash sticks have a block size of 512 bytes, I've had the most compatibility when I create the FS that block size. I think format.com is using that block size, and mkudffs has a command switch for changing the block size. I could only get OS X and Windows to mount the filesystem when I used 512 byte blocks. Older versions of Linux assumed a block size of 2048, but you can always mount with "-o bs=512".
The whole disk vs partition issue still causes compatibility problems. Windows won't mount when I format the whole disk, and OS X doesn't look beyond the partition's type number when determining its filesystem, forcing me to mount it manually. Linux didn't care, as long as I gave it the appropriate device name (sda vs sda1).
In summary, the most compatible setup I've found is a singe partition of type 06(FAT16), formatted with UDF at block size 512. Works automatically on Windows, and a small bit of manual intervention on Linux and OS X.