Preheat the oven to 400°. Position 1 rack in the middle of the oven and 1 in the lower third. Put the onions on a rimmed baking sheet, drizzle with 2 tablespoons of the olive oil and season with salt and pepper. Put the shallots in a large roasting pan and drizzle with 2 tablespoons of the oil. Season with salt and pepper. Roast the onions and shallots for about 50 minutes, tossing occasionally, until soft and lightly browned. Let the shallots cool slightly, then peel them. Pour any juices from the onions and shallots into a bowl and reserve. Return the shallots to the roasting pan and add the onions.