S-21′s keel was laid down on 19 December 1918 by the Bethlehem Shipbuilding Corporation's Fore River Shipyard at Quincy, Massachusetts.
[3] The expedition set out from Hampton Roads, Virginia, on 4 October 1928 and followed a route that took it to Key West, Florida; Galveston, Texas; Guantanamo Bay, Cuba; the United States Virgin Islands; and Puerto Rico, with a return to Hampton Roads on 30 November 1928.
The gravity measurements were accompanied by a sonic depth sounding with results published on a chart produced by the U.S. Navy Hydrographic Office.
Departing New London on 22 October 1930, S-21 transited via the Panama Canal and California to Pearl Harbor, Hawaii, arriving there on 7 December 1930.
Departing Pearl Harbor on 15 October 1938, S-21 transited via California and the Panama Canal to Philadelphia, Pennsylvania, arriving on 11 December 1938.
The United States entered World War II with the Japanese attack on Pearl Harbor on 7 December 1941.
Arriving on 19 December 1941, she conducted defensive war patrols in the Pacific Ocean approaches to the Panama Canal through May 1942, although her second such patrol, scheduled for 24 January to 7 February 1942, was cancelled to allow her to participate in search and rescue operations for the submarine USS S-26, which had sunk on the night of 24 January after the submarine chaser PC-460 accidentally rammed her when the vessels were operating without navigation lights to avoid detection by the enemy.