For about five years now, this photo of a cannon aboard the SS Great Eastern has intrigued me.
Now, I understand that back in the day, civilian vessels had some artillery pieces to defend against piracy, but the SS Great Eastern was launched in 1858. This is at least 150 years after the decline of piracy in the Atlantic. So what purpose would mounting such a cannon aboard an ocean liner serve?
It's definitely not a cannon used for a gun salute, as it's too big.
I don't have a definite answer for you, but I've read insurance companies could require a minimum armament before they'd insure the cargo. A lot of these guns I've read about were 6 or 9 pounders, so pretty small. The two in your picture are definitely appear larger to me. I'm not sure if they're quite 32 pounder size though.
Cyrus Alger ran a foundry that produced military cannons and also cannons for civilians. Page 6 of this book has a blurb about how he can produce cannons for civilian ships in 1851.
"These will be furnished at short notice, and of the best quality. These Guns intended for Merchantmen or Steamers to give notice of arrival or departure, as well as for defense, if occasion should require, are of various calibers usually 4, 6 and 9 pounders. They are attached to carriages, and furnished with percussion locks."
So that's not too far from the Great Eastern's launch.
It's definitely not a cannon used for a gun salute, as it's too big.
Well everything about the Great Eastern was big, so I wouldn't totally rule that out.