mount linux disk to path permanently #
If you add a disk to your Linux server, you should manually attach the disk to the path you want your k8s cluster to use, for example /var/lib/docker if you use Docker, or /var/lib/containerd if you use containerd. Note that if you use a storage class, you should have a SEPARATE disk for that.
From my example, I will mount the disk to /var/lib/containerd, you can change it to your desired path.
Steps to Mount a Disk to /var/lib/containerd permanently #
1. Find your disk: #
Example output:
2. Format the disk (if new), use ext4 format if you like it :) #
WARNING: FORMAT WILL LOSE ALL DATA IN the disk, only do ONCE
3. Backup existing containerd data (if needed) #
sudo systemctl stop kubelet
sudo systemctl stop containerd
sudo mv /var/lib/containerd /var/lib/containerd.bak
# NOTE THAT IF PATH EXISTS -> cannot mount,
# so you can backup or remove it if you want.
4. Get the disk UUID #
Example:
5. Edit /etc/fstab in root user #
Add line:
6. Mount and restore data #
sudo mkdir -p /var/lib/containerd
sudo systemctl enable --now containerd
sudo mount -a
# if you backup the containerd above, use this
# if not just skip, the path will auto init on reboot
# sudo rsync -a /var/lib/containerd.bak/ /var/lib/containerd/
7. Restart services #
IMPORTANT: reboot the linux server to make sure everything is working fine,
Then check lsblk -f to see if the disk is mounted successfully or not. If the disk is not mounted, review the steps above to ensure all configurations are correct. If issues persist, consider checking the system logs for any error messages related to the mounting process.