[GH-ISSUE #2268] BUG: updating ollama per curl, overwrites the manually edited /etc/systemd/system/ollama.service #47815

Closed
opened 2026-04-28 05:24:43 -05:00 by GiteaMirror · 8 comments
Owner

Originally created by @BananaAcid on GitHub (Jan 30, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/2268

After updating using curl https://ollama.ai/install.sh | sh

the service file /etc/systemd/system/ollama.service gets overwritten.

Loosing all Environment=OLLAMA... changes.

Maybe check if it exists first, and not overwrite it.

-- there seems to be no notice about it overwriting in the docs.

Originally created by @BananaAcid on GitHub (Jan 30, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/2268 After updating using `curl https://ollama.ai/install.sh | sh` the service file `/etc/systemd/system/ollama.service` gets overwritten. Loosing all `Environment=OLLAMA...` changes. Maybe check if it exists first, and not overwrite it. **-- there seems to be no notice about it overwriting in the docs.**
Author
Owner

@mountaineerbr commented on GitHub (Feb 5, 2024):

This is a terrible approach. The Ollama project members seem to use MacOS which is a bad platform by defaults.

Keep in mind, MacOS uses launchd, which inspired the creation of systemd for Linux. FreeBSD still has not a better solution, still back in UNIX times.

What we do in Arch Linux is we don't overwrite modified configuration files, even if they are located in the system hierarchy. Stock configuration files that are different from already installed and modified user configuration files should be installed as a backup for future use, such as *.new or something.

<!-- gh-comment-id:1926171087 --> @mountaineerbr commented on GitHub (Feb 5, 2024): This is a terrible approach. The Ollama project members seem to use MacOS which is a bad platform by defaults. Keep in mind, MacOS uses launchd, which inspired the creation of systemd for Linux. FreeBSD still has not a better solution, still back in UNIX times. What we do in Arch Linux is we don't overwrite modified configuration files, even if they are located in the system hierarchy. Stock configuration files that are different from already installed and modified user configuration files should be installed as a backup for future use, such as *.new or something.
Author
Owner

@BananaAcid commented on GitHub (Feb 5, 2024):

I use fodora. And using the curl line, which seems to be favored (being the top option mentioned in the install area), following it results in the problem described above.

There seems to be no info on the best update path.

<!-- gh-comment-id:1926949787 --> @BananaAcid commented on GitHub (Feb 5, 2024): I use fodora. And using the curl line, which seems to be favored (being the top option mentioned in the install area), following it results in the problem described above. There seems to be no info on the best update path.
Author
Owner

@waldo323 commented on GitHub (Mar 8, 2024):

For those using systemd in Linux,
You can create an override file for the systemd script using:
sudo systemctl edit ollama
This opens an editor with a new file.
add the lines you want to override or add to the service script.
Save the override file, don't change the filename/path.
Then you can allow the service file to be updated during updates without losing the overrides. (If ollama has changed in ways that don't work with your overrides you may still have issues but it won't be the loss of your changes)

<!-- gh-comment-id:1986244341 --> @waldo323 commented on GitHub (Mar 8, 2024): For those using systemd in Linux, You can create an override file for the systemd script using: sudo systemctl edit ollama This opens an editor with a new file. add the lines you want to override or add to the service script. Save the override file, don't change the filename/path. Then you can allow the service file to be updated during updates without losing the overrides. (If ollama has changed in ways that don't work with your overrides you may still have issues but it won't be the loss of your changes)
Author
Owner

@bmizerany commented on GitHub (Mar 11, 2024):

Manually editing the unit files is not our recommended approach. Please see https://github.com/ollama/ollama/blob/main/docs/faq.md#setting-environment-variables-on-linux

Closing, but please reopen and update if issues persist.

<!-- gh-comment-id:1989532927 --> @bmizerany commented on GitHub (Mar 11, 2024): Manually editing the unit files is not our recommended approach. Please see https://github.com/ollama/ollama/blob/main/docs/faq.md#setting-environment-variables-on-linux Closing, but please reopen and update if issues persist.
Author
Owner

@ghost commented on GitHub (Jul 9, 2025):

Old post but in case someone wants the solution:

1- Create the directory where the conf file will be saved
sudo mkdir -p /etc/systemd/system/ollama.service.d
2- Create the conf file
sudo nano /etc/systemd/system/ollama.service.d/custom.conf
3- Set the environment variables of your choice in the conf file
[Service]
Environment="Your_first_custom_variables"
Environment="Your_second_custom_variables"
4- Save and close the file
5- Reload daemon
sudo systemctl daemon-reload
6- Restart the Ollama service
sudo systemctl restart ollama.service
<!-- gh-comment-id:3054196105 --> @ghost commented on GitHub (Jul 9, 2025): Old post but in case someone wants the solution: ##### 1- Create the directory where the conf file will be saved ``` sudo mkdir -p /etc/systemd/system/ollama.service.d ``` ##### 2- Create the conf file ``` sudo nano /etc/systemd/system/ollama.service.d/custom.conf ``` ##### 3- Set the environment variables of your choice in the conf file ``` [Service] Environment="Your_first_custom_variables" Environment="Your_second_custom_variables" ``` ##### 4- Save and close the file ##### 5- Reload daemon ``` sudo systemctl daemon-reload ``` ##### 6- Restart the Ollama service ``` sudo systemctl restart ollama.service ```
Author
Owner

@BananaAcid commented on GitHub (Jul 10, 2025):

@CybergNetwork Can you explain how your solution works? Don’t you need to tell Ollama to use the new config file?

<!-- gh-comment-id:3057127689 --> @BananaAcid commented on GitHub (Jul 10, 2025): @CybergNetwork Can you explain how your solution works? Don’t you need to tell Ollama to use the new config file?
Author
Owner

@ghost commented on GitHub (Jul 10, 2025):

@CybergNetwork Can you explain how your solution works? Don’t you need to tell Ollama to use the new config file?

Why this works:

  • systemd always looks for [service-name].service.d/ directories
  • It's a built-in feature, not something Ollama needs to be "aware of"
  • The main service file and drop-in files are merged at runtime
  • Drop-in files override or extend the main service file

This is a standard systemd feature used across many Linux distributions and services. Ollama doesn't need to know about your drop-in files - systemd handles the merging automatically when it starts the service.

Ollama team could add that feature by just adding following to their install script:

sudo mkdir -p /etc/systemd/system/ollama.service.d
echo "[Service]" | sudo tee /etc/systemd/system/ollama.service.d/custom.conf

Then users would just have to add their Environment="Your_first_custom_variables" Environment="Your_second_custom_variables" to the custom.conf file.

The custom.conf file could be renamed ollama_custom_env_var.conf if it were to be included in the official script.

This way, it survives an update.

<!-- gh-comment-id:3057433499 --> @ghost commented on GitHub (Jul 10, 2025): > [@CybergNetwork](https://github.com/CybergNetwork) Can you explain how your solution works? Don’t you need to tell Ollama to use the new config file? Why this works: - systemd always looks for [service-name].service.d/ directories - It's a built-in feature, not something Ollama needs to be "aware of" - The main service file and drop-in files are merged at runtime - Drop-in files override or extend the main service file This is a standard systemd feature used across many Linux distributions and services. Ollama doesn't need to know about your drop-in files - systemd handles the merging automatically when it starts the service. Ollama team could add that feature by just adding following to their install script: ``` sudo mkdir -p /etc/systemd/system/ollama.service.d echo "[Service]" | sudo tee /etc/systemd/system/ollama.service.d/custom.conf ``` Then users would just have to add their Environment="Your_first_custom_variables" Environment="Your_second_custom_variables" to the custom.conf file. The custom.conf file could be renamed ollama_custom_env_var.conf if it were to be included in the official script. This way, it survives an update.
Author
Owner

@ZEROF commented on GitHub (Jan 26, 2026):

Just:

sudo systemctl edit ollama

and add what you need below mentioned line, like:

[Service]
Environment="OLLAMA_HOST=0.0.0.0"
Environment="OLLAMA_ORIGINS=*"
Environment="OLLAMA_PORT=11434"

### Edits below this comment will be discarded

And reload daemon:

sudo systemctl daemon-reload
sudo systemctl restart ollama

<!-- gh-comment-id:3798935528 --> @ZEROF commented on GitHub (Jan 26, 2026): Just: `sudo systemctl edit ollama` and add what you need **below** mentioned line, like: ``` [Service] Environment="OLLAMA_HOST=0.0.0.0" Environment="OLLAMA_ORIGINS=*" Environment="OLLAMA_PORT=11434" ### Edits below this comment will be discarded ``` And reload daemon: `sudo systemctl daemon-reload` `sudo systemctl restart ollama`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#47815