How to Format a USB Stick or SD card with UDF Filesystem on OS X and its Advantages

My internal SSD was getting a bit full so I decided to offload some media onto large SD cards as my MacBook has a built in reader, SD cards are more portable than hard drives and less likely to snap off than a USB stick. I had a problem, however, when I tried to put a bigger than 4GB film onto the card as FAT32 doesn't support larger files. Obviously I'd need to use a different filesystem format, but what? I looked into the common options most often mentioned:

When I say support, I mean built in without installing drivers and full read and write capability. There are drivers and 3rd party solutions, but I want to be able to stick this card in any machine and have it just work.

What is UDF and why should I use it?

In searching threads I found a casual comment mentioning UDF and a few thumbs up. I'd never heard of it, is this really the answer? Well, Wikipedia has a nice table showing that UDF is supported by basically every operating system, even ones you've probably never heard of. It's an ISO standard, so no nasty licensing like ExFAT. And it has no 4GB file size limit. So what's the catch?

I have no idea. None of my twitter followers seemed to know about it, Googling didn't turn up many relevant results. It seems nobody knows what UDF is or uses it, despite being a well supported standard and better than FAT32. I feel like there must be a catch, but I haven't found it yet. There's no journalling so be careful to safely remove and you might have to defray occasionally, but that's no worse than FAT32.

So, it looks like the perfect filesystem format for removable media sharing. Now, how to actually format a drive as UDF…

Existing info… into the void

On a Mac I'd normally use Disk Utility.app, but it will only format HFS, FAT32 and ExFAT. So to format as UDF requires another solution.

Here's a post that started me off, but it's for Linux, and another Linux answer. This question briefly mentions how to do it on Windows. After reading these and more I formulated a way to format a drive as UDF on OS X.

The Process

Make sure you have all data you want to keep backed up as this process will wipe the drive!

First you need to find out the identifier of the disk you wish to format. Run the command below then look through the output for a drive with the right name and size, e.g. "My USB Drive" "16GB" and note the drive identifier and partition identifier, e.g. /dev/disk3 and /dev/disk3s1. Make sure you get the right identifier or you could wipe another disk by mistake!

diskutil list

Next we need to find the block size of the device. It's probably 512 but check anyway. In the command below you need to replace x with your drive number e.g. diskutil info /dev/disk3 | grep "Block Size"

diskutil info /dev/rdisk{x} | grep "Block Size"

Before we can do anything with the disk it needs un-mounting (again replace the xs):

diskutil unmount /dev/rdisk{x}s{x}

Now we need to wipe the disk. If we don't the old format identifier might still be picked up by the OS preventing the drive from working. This will take a while.

diskutil secureErase 0 /dev/rdisk{x}

Ah for the good part. This bit actually formats the drive. Replace block size as well with what you found earlier—probably 512—e.g. sudo newfs_udf -b 512 /dev/disk3

sudo newfs_udf -b {block size} /dev/rdisk{x}

And we're done… almost. To use the disk it needs mounting again, then it should show up in Finder as usual but with the new UDF format.

diskutil mount /dev/rdisk{x}

You may finally rename the disk in Finder.