The Montgomery Guards, commanded by Captain John O'Connor, became Company B, 21st Alabama Infantry in the fall of 1861. It spent most of the war as artillery in forts guarding Mobile Bay. Williams developed a fondness for the Montgomeries, of whom he wrote that they "stood heroically by my side in the battle of Shiloh."