<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>LLM on The Danesh Project</title>
    <link>https://thedaneshproject.com/tags/llm/</link>
    <description>Recent content in LLM on The Danesh Project</description>
    <image>
      <title>The Danesh Project</title>
      <url>https://thedaneshproject.com/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</url>
      <link>https://thedaneshproject.com/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</link>
    </image>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Sat, 25 Apr 2026 09:24:57 -0500</lastBuildDate>
    <atom:link href="https://thedaneshproject.com/tags/llm/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Changing the Default Ollama Models Directory</title>
      <link>https://thedaneshproject.com/posts/changing-the-default-ollama-models-directory/</link>
      <pubDate>Sat, 25 Apr 2026 00:00:00 -0500</pubDate>
      <guid>https://thedaneshproject.com/posts/changing-the-default-ollama-models-directory/</guid>
      <description>How to redirect Ollama&amp;#39;s model storage to a separate drive using a systemd drop-in, so models survive a full system rebuild.</description>
      <content:encoded><![CDATA[<p>I have a second drive mounted at <code>/mnt/data</code> that survives system rebuilds. Ollama models are large — pulling everything again from scratch after a reinstall is painful — so I wanted to move the model storage there. Ollama respects the <code>OLLAMA_MODELS</code> environment variable, and since it runs as a systemd service, the cleanest way to set that is with a drop-in override.</p>
<h2 id="creating-the-drop-in">Creating the Drop-in</h2>
<p>systemd drop-ins let you override parts of a unit file without touching the original. The convention is a directory named <code>&lt;unit&gt;.d/</code> under <code>/etc/systemd/system/</code>:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo mkdir -p /etc/systemd/system/ollama.service.d
</span></span><span style="display:flex;"><span>sudo nvim /etc/systemd/system/ollama.service.d/models_location_override.conf
</span></span></code></pre></div><p>Contents of <code>models_location_override.conf</code>:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ini" data-lang="ini"><span style="display:flex;"><span><span style="color:#66d9ef">[Service]</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">Environment</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;OLLAMA_MODELS=/mnt/data/ollama/models&#34;</span>
</span></span></code></pre></div><p>Make sure the path matches your actual mount point. I initially wrote <code>/data/ollama/models</code> (missing the <code>/mnt</code> prefix) and got this on the first restart:</p>
<pre tabindex="0"><code>Error: mkdir /data: permission denied: ensure path elements are traversable
</code></pre><h2 id="reloading-and-restarting">Reloading and Restarting</h2>
<p>Whenever a unit file or drop-in changes on disk, systemd needs to be told:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo systemctl daemon-reload
</span></span><span style="display:flex;"><span>sudo systemctl restart ollama.service
</span></span></code></pre></div><p>The service came up fine after fixing the path, but running <code>ollama list</code> still failed:</p>
<pre tabindex="0"><code>Error: mkdir /mnt/data/ollama/models/manifests: permission denied
</code></pre><h2 id="fixing-permissions">Fixing Permissions</h2>
<p>Ollama runs as the <code>ollama</code> user, so the target directory needs to be owned by that user. I had created <code>/mnt/data/ollama</code> as my own user earlier:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo chown -Rv ollama:ollama /mnt/data/ollama
</span></span></code></pre></div><p>Then a final restart:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo systemctl restart ollama.service
</span></span></code></pre></div><h2 id="verifying">Verifying</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo systemctl status ollama.service
</span></span></code></pre></div><p>The drop-in shows up in the status output confirming it&rsquo;s active:</p>
<pre tabindex="0"><code>Drop-In: /etc/systemd/system/ollama.service.d
         └─models_location_override.conf
Active: active (running)
</code></pre><p>Pulling a model confirms writes are going to the new location:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>ollama pull gemma4
</span></span></code></pre></div><h2 id="summary">Summary</h2>
<p>Three steps:</p>
<ol>
<li>Create <code>/etc/systemd/system/ollama.service.d/models_location_override.conf</code> with <code>Environment=&quot;OLLAMA_MODELS=&lt;your path&gt;&quot;</code></li>
<li><code>sudo chown -R ollama:ollama &lt;your path&gt;</code> — the ollama service user needs write access</li>
<li><code>sudo systemctl daemon-reload &amp;&amp; sudo systemctl restart ollama.service</code></li>
</ol>
]]></content:encoded>
    </item>
  </channel>
</rss>
