This happens with me many times that I find my boss talking to my colleagues in door ways or in smoking zone and I am also going that way. Situation is that from what I see, he is not noticing me and continuing with his conversation, at this point should I greet my boss and disturb the conversation?
What do others do?
It comes down to the culture at the company, which among numerous factors depends on country, business sector, company size, the age and personality of people - and other factors such as how close you are to the boss and the 'seriousness' of the conversation.
Another approach could be taking the opposite view: What is the consequence of you NOT greeting the boss? Would it be considered polite and non-interrupting or weird an unapproachable?
In a Danish context, I always greet when not doing so would seem weird.
As you described it, it's a quite awkward situation, so just keep an eye on him while you get closer to him. If he doesn't look at you, or seems too busy to talk to you, don't interrupt him, handshake or anything. Just keep walking and say "hi" or "good morning" as you're passing by him. This way if he hears you, he won't think you ignored him, and if he wants to talk with you, he will be the one who will have to call you. If he doesn't hear you, at least you won't interrupt him and you won't risk looking impolite.
If he sees you, depending on your culture, just smile and nod/wave him/whatever is a quick salutation