Excerpt: How to move k3s data to another partition or disk

Excerpt: How to move k3s data to another partition or disk

The default locations for k3s data are the following directories on the host machine:

  • /run/k3s

  • /var/lib/kubelet/pods

  • /var/lib/rancher

If the hard disk on which the standard directories are located is too small and you do not have the option of enlarging the hard disk, then move the k3s data to another hard disk. These instructions show the necessary steps. It is recommended that you create a snapshot of the virtual machine before making the changes.

  1. stop all k3s services

    sudo systemctl stop k3s sudo /usr/local/bin/k3s-killall.sh
  2. create variable with mount path to your new disk

    newLocation=<path to your large disk> # alter this to the correct mount point of the disk to use
  3. Copy files to the new location (change location in line 1)

    sudo mv /run/k3s/ $newLocation/k3s/ sudo mv /var/lib/kubelet/pods/ $newLocation/k3s-pods/ sudo mv /var/lib/rancher/ $newLocation/k3s-rancher/
  4. Create symbolic links

    sudo ln -s $newLocation/k3s/ /run/k3s sudo ln -s $newLocation/k3s-pods/ /var/lib/kubelet/pods sudo ln -s $newLocation/k3s-rancher/ /var/lib/rancher
  5. Start k3s service again

    sudo systemctl start k3s