In a small saucepan over medium-high heat, melt the butter. Add the garlic and stir until fragrant, about 30 seconds. Do not let it burn. Add the flour, salt, and pepper, and stir until smooth.
Slowly whisk in the milk, a little at a time, then add the ground mustard and thyme. Bring to a boil, stirring often, until the sauce thickens, about 2 minutes. Remove from the heat and stir in 1 cup of cheddar cheese until melted.
Coat a 9x13-inch baking dish with cooking spray. Spread half of the sliced potatoes in the dish, top with half of the onions, and pour half of the cheese sauce over them.
Repeat with the remaining potatoes, onions, and cheese sauce. Sprinkle the top with ¼ cup cheddar cheese and the parmesan cheese.
Cover the dish with foil and bake for 45 minutes. Remove the foil and bake for 15 to 20 minutes more, until the top is golden and the potatoes are tender.