K3S Change Data Storage Path
k3s
data storage
path modification
services
copy data
daemon reload
K3S_DATA_DIR
This article explains how to change the data storage path of K3S, a lightweight and minimal Kubernetes distribution, by utilizing the `K3S_DATA_DIR` environment variable. It also guides users through stopping services, copying data, modifying service files with the new path, and restarting k3s using a daemon reload.
you can configure K3S_DATA_DIR
environment variable during installation
first, stop all k3s services
# run with root
systemctl stop k3s # k3s-agent otherwise
k3s-killall.sh
copy the data to new location
rsync -avh --progress /var/lib/rancher/k3s <path_to_store_data>
then modify the service file under /etc/systemd/system/k3s.service
or /etc/systemd/system/k3s-agent.service
, add one additional flag --data-dir <path_to_store_data>
to the commandline
restart the service after done
systemctl daemon-reload
systemctl start k3s