<?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>Kubernetes on inetshell</title><link>https://inet.sh/en/tags/kubernetes/</link><description>Recent content in Kubernetes on inetshell</description><generator>Hugo</generator><language>en</language><lastBuildDate>Thu, 20 Aug 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://inet.sh/en/tags/kubernetes/index.xml" rel="self" type="application/rss+xml"/><item><title>Move k3s data to another disk</title><link>https://inet.sh/en/posts/k3s/migrate-data/</link><pubDate>Thu, 20 Aug 2026 00:00:00 +0000</pubDate><guid>https://inet.sh/en/posts/k3s/migrate-data/</guid><description>How to move /var/lib/rancher, kubelet pods, and /run/k3s to another disk or partition: stop, mv, symlink, start. /run tmpfs traps and the --data-dir alternative.</description><content:encoded><![CDATA[<h2 id="tldr">TL;DR</h2>
<p>Stop k3s → <code>mv</code> <code>/run/k3s</code>, <code>/var/lib/kubelet/pods</code>, <code>/var/lib/rancher</code> → symlinks to the new disk → start. <code>/run</code> is tmpfs.</p>
<p>k3s keeps state on the system disk. When <code>/</code> fills up or you want faster storage, the short path is: <strong>stop → <code>mv</code> → symlink → start</strong>.</p>
<p>The destination (<code>/datadrive</code> here) must exist and be mounted <strong>first</strong>. Root or sudo.</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">sudo systemctl stop k3s
</span></span><span class="line"><span class="cl">sudo systemctl stop k3s-agent   <span class="c1"># only if this node is an agent</span>
</span></span><span class="line"><span class="cl">sudo /usr/local/bin/k3s-killall.sh
</span></span></code></pre></td></tr></table>
</div>
</div><div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">sudo mv /run/k3s/ /datadrive/k3s/
</span></span><span class="line"><span class="cl">sudo mv /var/lib/kubelet/pods/ /datadrive/k3s-pods/
</span></span><span class="line"><span class="cl">sudo mv /var/lib/rancher/ /datadrive/k3s-rancher/
</span></span></code></pre></td></tr></table>
</div>
</div><div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">sudo ln -s /datadrive/k3s/ /run/k3s
</span></span><span class="line"><span class="cl">sudo ln -s /datadrive/k3s-pods/ /var/lib/kubelet/pods
</span></span><span class="line"><span class="cl">sudo ln -s /datadrive/k3s-rancher/ /var/lib/rancher
</span></span></code></pre></td></tr></table>
</div>
</div><div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">sudo systemctl start k3s
</span></span><span class="line"><span class="cl">sudo systemctl start k3s-agent   <span class="c1"># agents only</span>
</span></span></code></pre></td></tr></table>
</div>
</div><div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">kubectl get nodes
</span></span><span class="line"><span class="cl">kubectl get pods -A
</span></span></code></pre></td></tr></table>
</div>
</div><h2 id="what-moves">What moves</h2>
<table>
  <thead>
      <tr>
          <th>Source</th>
          <th>Example destination</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>/run/k3s/</code></td>
          <td><code>/datadrive/k3s/</code></td>
      </tr>
      <tr>
          <td><code>/var/lib/kubelet/pods/</code></td>
          <td><code>/datadrive/k3s-pods/</code></td>
      </tr>
      <tr>
          <td><code>/var/lib/rancher/</code></td>
          <td><code>/datadrive/k3s-rancher/</code></td>
      </tr>
  </tbody>
</table>
<p>Working state lives there: containerd, manifests, pods. A half-finished <code>mv</code> or a start against empty paths breaks the cluster.</p>
<h2 id="traps">Traps</h2>
<p><strong><code>/run</code> is tmpfs.</strong> After a reboot the <code>/run/k3s</code> symlink is gone. Recreate it from a unit <code>After=local-fs.target</code>, or leave <code>/run/k3s</code> on RAM and do not move it.</p>
<p><strong><code>k3s-agent</code> does not exist on a server-only node.</strong> <code>systemctl stop k3s-agent</code> failing is not a migration failure.</p>
<p><strong>Create the destination parent</strong> (<code>mkdir -p /datadrive</code>) and confirm the mount (<code>findmnt /datadrive</code>) <strong>before</strong> <code>mv</code>. A <code>mv</code> onto an unmounted path leaves the data on the old disk under a new name.</p>
<p><strong>containerd and kubelet sometimes reject a symlink.</strong> If the node never goes Ready, switch to a bind mount in <code>/etc/fstab</code>:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-gdscript3" data-lang="gdscript3"><span class="line"><span class="cl"><span class="o">/</span><span class="n">datadrive</span><span class="o">/</span><span class="n">k3s</span><span class="o">-</span><span class="n">rancher</span>  <span class="o">/</span><span class="k">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">rancher</span>  <span class="n">none</span>  <span class="n">bind</span>  <span class="mi">0</span>  <span class="mi">0</span>
</span></span></code></pre></td></tr></table>
</div>
</div><h2 id="cleaner-alternative---data-dir">Cleaner alternative: <code>--data-dir</code></h2>
<p>The official k3s path is <code>--data-dir</code> (default <code>/var/lib/rancher/k3s</code>). On a <strong>new</strong> node, install with the data-dir already on the large disk. On an <strong>existing</strong> node, <code>mv</code> + symlink (or bind) of <code>/var/lib/rancher</code> is the shortcut; do not rewrite the unit mid-cluster without a plan.</p>
<p>Write-up of this <code>mv</code> + symlink sequence: <a href="https://devopskit.tech/en/posts/migrate-k3s-data/">How to Move K3s Data to a New Location</a>.</p>
]]></content:encoded></item></channel></rss>