The assemblage is best made in a ceramic, high-heat container where one can best glaze the onion. Arrange whole onion slices and the garlic at the bottom of the casserole and cover with a few dashes olive oil. Glaze/char onion at high heat, 10-15 minutes with a turn midway through for the onions.
Remove casserole from heat and allow to cool sufficiently to allow layering of spaghetti, sauce, mushroom, and cheeses. Bake at 350F for 15-20 minutes or until bubbling.