Preheat your oven to 400°F (200°C). Use butter to grease a medium casserole dish.
Use ½ of the potatoes to layer the bottom of the casserole dish. Add the onion slices on top, then add the rest of the potatoes on top of the onions. Add salt and pepper to taste.
Melt butter in a medium-sized saucepan on medium heat. Add the flour and salt, whisking constantly for one minute. Add the milk, stir, and cook until thickened. Add all of the cheese and stir for about 30 to 60 seconds or until melted.
Pour the cheese mixture over the potatoes and cover the casserole dish with aluminum foil. Bake for 90 minutes.