You might not have to lose your settings. One major step in not losing your settings is to make sure that when you upgrade or reinstall, always select the option to import previous settings and preferences. If that option is selected, you shouldn't have to rebuild everything.
But it’s always a good idea to make sure your last system backup is up to date before updating an application, so that if something goes wrong you can always restore the settings from your last backup.
Most Photoshop settings are under just a few parent folders; if you ever need to know where a specific settings file is on your operating system you can refer to this Adobe help article:
Preference file functions, names, locations | Photoshop