First, I zeroed completely the drive before creating the UDF filesystem with:
dd if=/dev/zero of=/dev/sdx bs=512
This is to avoid any leftover superblocks or other metadata which could confuse the operating systems' filesystem type detection (at least zeroing the first sector should be needed, to obliterate the partition table; the first few sectors are not used by UDF, and a leftover partition table could really confuse things). You could also use the count=1
switch on the dd command, in order to more-quickly zero just the first 512 bytes of the drive (where the MBR usually is located within), though this was not tested.
To create the file system, the command I used was:
mkudffs --media-type=hd --blocksize=512 /dev/sdx
mkudffs
command will become available on Debian-based Linux distros (such as Ubuntu) after installing a udftools
package:
sudo apt-get install udftools
The default blocksize for mkudffs
is 2048, which is wrong for a USB flash drive (which uses 512-byte sectors). Since the block size is used to find the filesystem metadata, using a wrong block size can make it not be recognized as a UDF filesystem (since the anchor will not be where the filesystem driver is expecting). Note that the mkudffs
man page is wrong; 512 is a valid value for the block size (and the code explicitly accepts it).
I also used the whole drive instead of a partition; this should be more compatible.
The result of my testing so far:
- Linux with the most recent kernel (2.6.31, from Ubuntu 9.10): works.
- Linux with an older kernel: needs the
bs=512
option to mount
, because it incorrectly used 2048 instead of the device sector size (fixed in commit 1197e4d).
- Windows Vista: works.
- A brand-new Mac: works.
- Windows XP: can read fine, but gives "access denied" when trying to write; also seems to think the disk is full.
While I have not so far tried to create a file larger than 4G in it, I see no reason why it would not work.
Given that it worked perfectly on all recent operating systems (only having to mount manually on Linux, which will not be needed anymore as soon as Ubuntu 9.10 and Fedora 12 are out), and worked read-only in Windows XP (which was a surprise to me; I was expecting it to not recognize the filesystem at all), using UDF instead of FAT32 or NTFS in big USB flash drives seems a good idea.
The ext3 and ext4 family of filesystems reserve a portion of the disk to keep it from becoming truly "100% full", for stability reasons, and so that the FS can store metadata in some of that space.
You can directly tweak how much of the space is reserved:
tune2fs -m 1 /dev/sdXX
replacing "1" with the percentage (0 to 100) of the disk to reserve, and "XX" with the device node and partition number of the device node, so in your case "XX" would be "b2".
Analogy: you have a full bus, and the only remaining seat is next to a very large person who occupies a seat and a half by himself. A person who is very insistent on getting a seat walks up and demands to sit there. Although most people would consider the second seat taken, this person is insistent. So the large person goes, "Whoa, OK!" and squishes in to allow them to sit. But as soon as 1 person gets off the bus and opens up another seat, even if the passenger next to the large person moves into a seat, most people still consider the bus to be 100% full, because nobody wants to sit next to the large person.
Source
You can also check this to see Reserved Blocks count…
dumpe2fs -h /dev/sdb2
To quote the very intelligent user who nailed the issue in the source above:
You will see "Available" go positive when
"Used" is reduced to below 0.95*136236548 blocks = 129424720 blocks
roughly.
(we have to adjust the "0.95" to the reserved % in your specific case, and the 136236548 blocks to the total block size of your device).
Best Answer
The root directory on a FAT16 filesystem can store only a limited number of file entries
Your flash drive is 2 GB in size. This is the maximum filesystem size supported by FAT16. As such, it is likely that it was formatted with the FAT16 filesystem from the factory.
Due to a technical limitation in the FAT16 filesystem, only a limited number of file entries may be stored into the root directory. This limit is set when the filesystem is formatted (source). Directory entries (which may include long filename information), but not the contents of directories, count towards this limit.
To solve this problem, convert the filesystem to FAT32. On Linux, it may simply be best to move all files to a temporary location, unmount the drive, reformat to FAT32 with
mkfs.vfat -F 32 /dev/sde1
, and mount the drive and move the files back.