Skip to content

Instantly share code, notes, and snippets.

@ericboehs
Created April 14, 2022 00:57
Show Gist options
  • Save ericboehs/07f8e577f7761f44b10db0ba83a317b6 to your computer and use it in GitHub Desktop.
Save ericboehs/07f8e577f7761f44b10db0ba83a317b6 to your computer and use it in GitHub Desktop.

Revisions

  1. ericboehs created this gist Apr 14, 2022.
    31 changes: 31 additions & 0 deletions set-up-persistent-storage-for-K3s.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    # 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
    ```