Your visa does not determine how long you may stay in the United States. However, to reenter the U.S. in valid F-1 or J-1 status you must have a valid F-1 or J-1 visa (except when traveling to countries that offer Automatic Revalidation). You can obtain a visa ONLY from a U.S. consulate outside the U.S.
If you need to renew your visa you should follow the same visa application procedures that you did when you originally applied for your F-1 or J-1 student visa. However this time you will not be required to pay the SEVIS fee.
If you are applying for an F-1 or J-1 visa for the first, for example after having received a Change of Status in the United States, you should follow the visa application procedures that new students follow including paying the SEVIS fee.
Whether or not you receive a new or renewed visa is at the discretion of the Consular Official. We cannot guarantee that all requests for student visas will be approved even if you are in the middle of your degree.