Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zaherg/6e2b3b787ffbf4dbcfc37fdb85498f36 to your computer and use it in GitHub Desktop.
Save zaherg/6e2b3b787ffbf4dbcfc37fdb85498f36 to your computer and use it in GitHub Desktop.
Set up persistent storage for K3s (via USB drive)

Set up persistent storage for K3s (via USB drive)

  1. Get root: ssh pi-k3s-master.local -t sudo su
  2. Find your disk via fdisk -l (e.g. /dev/sda1)
  3. Erase drive by repartitioning: mkfs.ext4 /dev/sda1
  4. Mount drive:
    mkdir /mnt/pi-k3s-storage
    chown -R ericboehs:ericboehs /mnt/pi-k3s-storage
    mount /dev/sda1 /mnt/pi-k3s-storage
    
  5. Configure auto-mount:
    echo "UUID=$(blkid -s UUID -o value /dev/sda1) /mnt/pi-k3s-storage ext4 defaults 0 0" >> /etc/fstab
    
  6. Install nfs server on master:
    apt-get install -y nfs-kernel-server
    echo "/mnt/pi-k3s-storage *(rw,no_root_squash,insecure,async,no_subtree_check,anonuid=1000,anongid=1000)" >> /etc/exports
    exportfs -ra # Start nfs
    
  7. Install nfs client on nodes:
    ssh pi-k3s-node1.local -t "sudo su"
    mkdir /mnt/pi-k3s-storage
    chown -R ericboehs:ericboehs /mnt/pi-k3s-storage
    mount 10.0.1.90:/mnt/pi-k3s-storage /mnt/pi-k3s-storage
    echo "10.0.1.90:/mnt/pi-k3s-storage /mnt/pi-k3s-storage nfs rw 0 0" >> /etc/fstab
    reboot
    df -h /mnt/pi-k3s-storage
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment