Put the potatoes, onions, salt, and pepper in the pan and cook over medium-to-low heat until the potatoes are soft but not brown. Stir to prevent them from sticking.
Drain the potato mixture. Pour the eggs over the potatoes.Let it stand for 5 minutes.
Wipe out the frying pan. Heat the 2 tablespoons of olive oil. Add the egg-potato mixture. Cook on medium-to-low heat until the bottom is set and golden brown. While cooking, shake the pan so that the mixture does not stick.
Flip the tortilla by putting a plate that is larger than the pan over the pan and turning the pan over. If any parts of the tortilla stick to the skillet, remove and flip them with a spatula. Slide the tortilla back into the pan, add any parts that were flipped with the spatula, and cook another 3 minutes.