Heat oven to 400° F. Cook the pasta according to the package directions. Drain it and return it to the pot.
Meanwhile, heat the oil in a large skillet over medium heat. Add the onion and garlic and cook, stirring occasionally, until they begin to soften, 4 to 5 minutes.
Add the beef, ¾ teaspoon salt, and ¼ teaspoon pepper and cook, breaking up the meat with a spoon until it’s no longer pink, 5 to 6 minutes.
Toss the pasta with the meat mixture, marinara sauce, spinach, ricotta, and ¼ cup of the Parmesan.
Transfer to a 9-by-13-inch baking dish or 4 large ramekins. Sprinkle with the mozzarella and the remaining ¼ cup of the Parmesan. Bake until the cheese melts, 12 to 15 minutes.