Cook the spaghetti in boiling salted water until al dente. Grate the cheeses while the pasta is boiling. Drain the pasta, reserve 4 tbsp of the cooking water.
Put the reserved water and the butter back into the hot pan and simmer gently over a low heat. Stir until the butter melts.
Remove from the heat and stir in half the cheese. Add the spaghetti and toss to coat thoroughly. Serve with more of the cheese.