Where did last names originate?

In earlier times your last name was usually just your trade, for example "Harry the blacksmith" would just become "Harry Smith", last names were originally just a way of distinguishing certain people.

Other last names like "Williamson" come from son of William, Jake o' rilley means Jake son of rilley