Lightly coat a 1-quart casserole dish with cooking spray.
In a large skillet, melt the butter and saute the onions until tender, then add the garlic and cook stirring constantly for about 30-45 seconds.
Whisk in the flour and mix well.
Pour in the milk, add the pepper and stir to combine
Continue cooking on medium heat, stirring occasionally until the sauce begins to simmer and just starts to thicken, about 5-6 minutes, then remove from heat and set aside.
Layer half the sliced potatoes on the bottom of the casserole dish.
Spread half the sauce on top of the layer of potatoes. Use a slotted spoon to remove some of the onion and layer those evenly across the layer of potatoes.
Sprinkle 1 cup of the Cheddar, 1/4 cup of the Gruyere, and all the Parmesan, evenly over the first layer of potatoes and sauce.
Top with the remaining potatoes and sauce.
Sprinkle the remaining cheese evenly over the top.
Cover the casserole dish with aluminum foil and bake at 400 degrees for 30 minutes.
Uncover the casserole dish, if the sauce is bubbly around the edges continue to cook uncovered for another 20 minutes or until the potatoes and fully cooked.
Notes
If making ahead, let cool completely and cover tightly then refrigerate. Reheat before serving.