Linux环境下Ollama安装报错: Error: xxx: permission denied
使用命令sudo chown -R ollama:ollama /usr/share/ollama
如果不行的话试下下面的:
情形1
Nov 26 21:30:04 gpuserver ollama[4092300]: Couldn't find '/usr/share/ollama/.ollama/id_ed25519'. Generating new private ke>
Nov 26 21:30:04 gpuserver ollama[4092300]: Error: open /usr/share/ollama/.ollama/id_ed25519: permission denied
Nov 26 21:30:04 gpuserver systemd[1]: ollama.service: Main process exited, code=exited, status=1/FAILURE
Nov 26 21:30:04 gpuserver systemd[1]: ollama.service: Failed with result 'exit-code'.
- 使用命令
ssh-keygen -t rsa -b 4096 -C "my.email@gmail.com"
创建一个id_ed25519
和id_ed25519.pub
文件 - 复制到
/usr/share/ollama/.ollama/
路径下:sudo cp /home/user/.ssh/id_ed25519 /usr/share/ollama/.ollama/ sudo cp /home/user/.ssh/id_ed25519.pub /usr/share/ollama/.ollama/
- 赋权
sudo chmod a+x /home/user/.ssh/id_ed25519 sudo chmod a+x /home/user/.ssh/id_ed25519.pub
情形2
Nov 26 21:32:32 gpuserver ollama[4094351]: Error: mkdir /usr/share/ollama/.ollama/models: permission denied
Nov 26 21:32:32 gpuserver systemd[1]: ollama.service: Main process exited, code=exited, status=1/FAILURE
Nov 26 21:32:32 gpuserver systemd[1]: ollama.service: Failed with result 'exit-code'.
- 使用命令
sudo mkdir /usr/share/ollama/.ollama/models
创建该文件夹 - 同样赋权
sudo chmod a+x /usr/share/ollama/.ollama/models
检验
sudo systemctl start ollama
journalctl -e -u ollama
- 看到
Nov 26 21:33:40 gpuserver systemd[1]: Started ollama.service - Ollama Service.
说明Ollama启动成功
情形3(拉取模型)
user@gpuserver:~$ ollama run qwen2.5-coder
pulling manifest
Error: open /usr/share/ollama/.ollama/models/blobs/sha256-60e05f2100071479f596b964f89f510f057ce397ea22f2833a0cfe029bfc2463-partial-0: permission denied
sudo chown -R ollama:ollama /usr/share/ollama
修改前
修改后
好像也可以选择更改模型保存位置
ollama修改模型的下载位置解决C盘空间不足问题_ollama修改模型位置-CSDN博客
参考
- ollama/docs/faq.md at main · ollama/ollama
- Error: pull model manifest: ssh: no key found · Issue #4901 · ollama/ollama
- Getting permission denied when attempting to create a model · Issue #613 · ollama/ollama
- Ollama Linux 使用指南 | Ollama 中文文档