Because both Gandalf and the Balrog are Maia, they share much of the same past. They came from the same place at roughly the same time. Though their lives took... different paths, wouldn't they already know each other? Like living for a Millennium in a small town, everyone knows everyone.

I think I've always taken it for granted that the Balrog, when we saw it in Moria, looked very different from whatever its appearance had been thousands of years earlier, "in the good old days." So even if Gandalf knew any given Balrog had to be "a fellow Maia gone bad," he wouldn't necessarily be able to tell which one he was meeting that day. And Gandalf too may have looked very different from how he used to appear in "the good old days." So I'm not surprised that they didn't greet each other by name as soon as they saw each other in Moria.
– LorendiacNov 19 '16 at 3:29

1 Answer
1

It's possible...

There's really no way of knowing if Olórin and the Balrog had met early in their lives; precious few writings focus on the Maiar at all, and basically none set in a period of time where these two might have interacted. It's certainly possible that they did, in the same way some of the Valar knew each other in the Timeless Halls, but we can't say for certain.

...But Gandalf may not have remembered anyway

It's never entirely clear how much Gandalf remembers of his life as Olórin; Unfinished Tales tells us:

[I]t is said indeed that being embodied the Istari had needs to learn much anew by slow experience, and though they knew whence they came the memory of the Blessed Realm was to them a vision from afar off

Unfinished Tales Part 4 Chapter II: "The Istari"

It's not impossible that Gandalf would have remembered, but it seems unlikely. Of all the things for him to remember, I wouldn't think a single co-worker from aeons ago would top the list.