Cut about 1/4 inch off 7 of the heads of garlic to expose the cloves and place in a small baking dish. Drizzle 2 tablespoons of the olive oil over the garlic and cover tightly with aluminum foil. Bake until the garlic skins are golden and the cloves are soft, 45 minutes to 1 hour.
While the garlic is roasting, peel and coarsely chop the remaining head of garlic. Add the remaining 2 tablespoons of olive oil to the saucepan and heat over medium heat. Add the onions, potatoes, and garlic to the pan, season lightly with salt, and cook until the vegetables soften and begin to brown slightly, 5 to 10 minutes.
Add the water or chicken broth, thyme, salt, and pepper and bring to a boil.
Reduce the heat to a simmer, and cook until the potatoes are very tender, about 15 to 20 minutes.
Once the garlic has roasted and is soft, use a spoon to scoop the garlic from the skins, or simply squeeze it out of the skins, and add it to the saucepan.
Using an immersion blender, puree the soup in the saucepan until smooth. Alternatively, using a blender, puree the soup in batches until thick and smooth, then return to the saucepan and reheat. Taste and add salt and pepper, if needed.