(n.) the foam that forms the head of a glass of beer
According to the Oxford English Dictionary, barm is “the froth or head of beer when poured out.”
The more usual meaning of barm, however, is the thick, yeasty froth that forms on top of malt liquors as they ferment, which is often potent enough to be siphoned off and used to start the fermentation process in other malts (or even to make bread). In that original sense, the word dates all the way back to the Old English period, but it’s been in use more loosely since the thirteenth century in reference to the foam or ‘head’ of a pint of beer.
One question remains, though: is this barm related to the adjective barmy? Well yes, you clever thing, it is.
When it first emerged in the language in the early 1500s, the adjective barmy just meant precisely that: full of froth, foam, or barm. But before long a figurative meaning had developed, so that by the early seventeenth century people who were just as excitably lively or as full of ferment as a pint of beer’s foaming barm were being described in equivalent terms. It’s from there that the more recent use of barmy to mean ‘unhinged’, ‘deranged’, or generally ‘not thinking straight’ emerged—the latter of which, at least, you could always blame on consuming a bit too much barm.