In 1945 "U-2540" was sunk by its own crew during the "Aktion Regenbogen". After lying on the bottom of the Flensburg Fjord for 12 years, the boat was salvaged in 1957 and transferred to the service of the German Navy 3 years later under the name "U-Wilhelm Bauer".
With the accession to NATO, submarines were again earmarked for the German Navy. Even if smaller submarines were to be built, "U-Wilhelm Bauer" was the ideal test boat due to its speed under water and high diving time.
From 1970, the submarine then sailed for another 10 years with a civilian crew before it was put up for sale in Wilhelmshaven after a 2-year rest period.