ollama记录
ollama version is 0.12.5
ubuntu 24.04 64bit
问题:设置OLLAMA_MODELS=/home/username/ollama/models后,ollama服务无法启动,查看日志:ollama[779068]: Error: mkdir /home/username/ollama: permission denied: ensure path elements are traversable
说是权限问题,但是通过sudo chown +R 修改目录所有者为ollama,还是无效。后来在github上看到:
The issue, as also described in the post, is that ollama tries to create the entire directory structure which you specify in the OLLAMA_MODELS
environment variable. So even if you do a chown -R ollama:ollama /my/path/model_dir
ollama tries to do a mkdir /my/path
and errors out. The solution in the forum post is do a bind mount:
sudo mount --bind /my/path/model_dir /usr/share/ollama/.ollama/models
大概意思是ollama会创建整个目录结构。
后来我直接把/etc/systemd/system/ollama.service.d/override.conf里的用户名和组都改成自己用户名,再重启服务就可以了。