Preheat oven to 350 degrees F. Coat a 13x9x2-inch baking pan with cooking spray. Add potatoes, onions, and garlic to prepared pan. Sprinkle with thyme, salt, and pepper. Cover with foil.
Bake for 50 to 55 minutes or until potatoes are tender when pierced with a fork, stirring once halfway through baking.
Meanwhile, in a large skillet cook pancetta over medium-high heat until crisp, stirring occasionally. Drain off fat.
Place half of the potato mixture in a 2-quart casserole. Sprinkle with half of the pancetta and half of the cheese. Repeat layers. Return to oven and bake 15 to 20 minutes more or until cheese is melted.