https://web.archive.org/web/20160528234959/https://wiki.freebsd.org/IPv6Only discusses a FreeBSD image that supported only IPv6, not IPv4. That page is no longer live, though (hence my archive link), and I can't find anything more recent about this. My question: is it possible today, on any modern UNIX or Linux system, to support only IPv6 and not IPv4, just like that old FreeBSD image did? It's okay if the way to do this requires a custom kernel or similar work.
Just build FreeBSD.
It's possible today, because FreeBSD continues to provide the mechanism used.
It is a set of kernel configuration and makefile options to turn off or exclude IPv4. The basic one is
nooptions INET, but observe what else
/usr/src/sys/conf/makeLINT.mk does. Also observe what
/usr/src/sys/conf/NOTES says about the knock-on effects of not having both IPv4 and IPv6 enabled.
Yes, of course. One way is simply not to configure any (public) IPv4 address or service on the host. More extreme would be to (if the OS supports that) remove IPv4 support, but that's more complicated, may not be possible, and if it is may break (usually older) services. Details will vary by OS as they are all very different in exactly how the network gets configured.
For example on macOS one might run
sudo ipconfig set en0 NONE sudo ipconfig set en0 AUTOMATIC-V6
to disable IPv4 and enable IPv6 on
lo0 might still have IPv4, but other systems need not know about that.)
This however may not be very useful as many things do not support or are not available on IPv6, and it's not like someone can call for a flag day like they did for the switch to TCP/IP a few years ago...
It's certainly possible on Linux. Networking protocols in the kernel are configurable, you can remove all IPv4 stuff. However, most distros will expect IPv4 and try to use it, so you'll have to customize this part of your distro, too (and if only to get rid of the error messages).
Though of course the question is what do you gain from doing it that way. Yes, the kernel will be a bit smaller without IPv4 protocols. But it's a lot simpler to just use a stock kernel, and configure everything not to accept IPv4 addresses, or not to have IPv4 in the first place.