Many hours of random fighting, thinking that there's a bug in blkid?
There's nothing like that on the issue tracker, maybe I should ask on #util-linux IRC channel? Well ok, there was one pull request about detecting ISOs better, but it was about not giving label to a partition if the whole-disk already had that label... not relevant I guess.
Maybe something accidentally uses busybox's builtin blkid instead of the util-linux one?
Or maybe if I add a random `udevadm trigger` it'll fix itself (it does 50% of the time).
Wait a sec, that blkid in the udev rule is an udev buitlin, not an external command.
Found the source code, started reading it. It was all cryptic calls to libblkid that I had no idea what were doing. And something about reading properties inherited from parent device.
Anyway, could it be that it's a bug in libblkid?
Also, what is this "test" argument passed to the builtin? Maybe there's a way to dry-run it?
Sure there is!
udevadm test-builtin blkid /sys/class/block/sda2
Ok, prints some properties, but nothing about label.
So libblkid does the right thing.
Waait... udev properties are inherited from parent devices!
So /dev/sda2 inherits label from /dev/sda because it doesn't have its own label!
So if I add a label - any label - to my vfat image, eg. by adding "-n EFI" to mkfs.vfat's options...