Welcome to SubSim
As far as the mines are concerned there is no defence against them. As in real life if you hit one there is a high probability that you will die. As a rule of thumb try to follow these simple suggestions:
1. Always check the maps you have when you're leaving/entering a friendly port
2. Try not to sail (submerged) very close to the British coast as there are loads of mines there.
3. Always remember that the minefields evolve with the war and they get bigger.
4. When you're entering an enemy harbour or you approach enemy land try to think for yourself where you would have positioned the mines yourself. That's a simple way to stay alive.
5. You can also use SH3Gen to get some inteligence information concerning minefields but don't expect too much. Just a generic knowledge of their existance.
and finally.......
6. Whatever you do stay out of the British Channel. It is heavily mined