Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ansible/secrets.yml
.TODO
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"background.windowBackgrounds": [
"https://i.ibb.co/xYkFskM/space-colorful-waves-abstract-4k-36.jpg"
],
"background.autoInstall": true,
"background.smoothImageRendering": true
}
3 changes: 3 additions & 0 deletions COMMON_COMMANDS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
df -h - Check mount points
utop - system activity
lsblk
36 changes: 18 additions & 18 deletions MAINTENANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,39 @@ To update k3s on your Raspberry Pis, you can follow these steps:

2. **Drain the node**: If you're updating one node at a time in a cluster, drain the node to safely remove it from the cluster during the update.

```bash
kubectl drain <node-name> --ignore-daemonsets --delete-emptydir-data
```
```bash
kubectl drain <node-name> --ignore-daemonsets --delete-emptydir-data
```

3. **Stop k3s service**: Before updating, stop the k3s service on the node.

```bash
sudo systemctl stop k3s
```
```bash
sudo systemctl stop k3s
```

4. **Update k3s**: Download and install the latest version of k3s on the Raspberry Pi. You can use the installation script provided by k3s for updating it as well.

```bash
curl -sfL https://get.k3s.io | sh -
```
```bash
curl -sfL https://get.k3s.io | sh -
```

5. **Start k3s service**: After the update, start the k3s service again.

```bash
sudo systemctl start k3s
```
```bash
sudo systemctl start k3s
```

6. **Uncordon the node**: If you drained the node earlier, make it schedulable again by uncordoning it.

```bash
kubectl uncordon <node-name>
```
```bash
kubectl uncordon <node-name>
```

7. **Verify the update**: Check the version of k3s to confirm the update was successful.

```bash
k3s --version
```
```bash
k3s --version
```

8. **Repeat for other nodes**: If you have multiple Raspberry Pis, repeat these steps for each node.

Expand Down
134 changes: 134 additions & 0 deletions MOUNT_AND_FORMAT_THE_DRIVE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
To **reformat and recreate a partition** (in your case, **`sda1`**) using **`fdisk`** on Linux, you can follow the steps outlined below. These instructions will guide you through deleting the existing partition, creating a new one, and then formatting it properly.

Since you're working with an external device and the partition appears to be large (**931.5GB**), I assume it's an external hard drive or SSD attached via USB.

### ⚠️ **Important!** Before proceeding:
1. **Backup Data**: Formatting and deleting the partition will erase all data on it, so ensure you have backed up any important data currently stored on **`sda1`**.
2. **Unmount the Partition**: If the partition is currently mounted, you’ll need to unmount it before working on it.

---

### Steps to Format and Recreate **`sda1`** Using `fdisk`:

#### **1. Unmount the Partition**
Before modifying the partition, unmount it if it's mounted:
```bash
sudo umount /dev/sda1
```

#### **2. Launch `fdisk` to Edit the Partition Table**
Run `fdisk` for the target device (`/dev/sda` in your case):
```bash
sudo fdisk /dev/sda
```

This will start the interactive **`fdisk`** utility on the entire **`/dev/sda`** disk.

#### **3. Delete the Existing Partition**
Once inside the `fdisk` tool, list the partitions to verify:
```bash
p
```

This should display your existing partition table, showing the **`sda1`** partition (`/dev/sda1`).

To delete the existing partition **`sda1`**:
1. Press `d` (to delete a partition).
2. If there is only one partition (`sda1`), it will automatically choose `1`. Otherwise, you may be asked to specify the partition number (enter `1` to select **`sda1`**).

Confirm that **`/dev/sda1`** has been deleted by pressing `p` again to view the partition table—it should now list no partitions.

#### **4. Create a New Partition**
Now, create a new partition by doing the following:

- Type `n` (to create a new partition).
- When asked for the partition type, press `p` to create a **primary partition**.
- When asked for the partition number, press `1` (to recreate it as **`sda1`**).
- Choose the **default starting sector** by just pressing `Enter` (this will typically start at sector 2048 if you're using a GPT or MBR partition scheme).
- You will be asked for the last sector — press `Enter` to choose the default and use the rest of the available space from the starting sector, effectively recreating a partition that spans the entire disk.

#### **5. Set the Partition's Filesystem (Optional)**
If you're partitioning for normal use (e.g., formatting to **ext4**), you can skip this step. But if you want to set a specific partition type (like Linux filesystem (`83`)), you'll be prompted to choose it. By default, **`fdisk`** will set it to **`83` (Linux Filesystem)** for most Linux machines.

To explicitly set it:
- Press `t` to change the partition type.
- Type `83` for Linux filesystem.

#### **6. Write the Partition Table**
Once satisfied with the changes, write the new partition table to the disk by typing:
```bash
w
```

This will save the changes and exit `fdisk`.

---

### 7. Format the New Partition (**ext4**)

Now that **`sda1`** has been recreated, you will want to format it with a filesystem. In your case, I recommend **ext4** unless you have a specific reason to use another filesystem type.

To format **`/dev/sda1`** as **ext4**:
```bash
sudo mkfs.ext4 /dev/sda1
```

This will begin formatting the newly created partition `sda1` as an **ext4** volume. The process will take some time, depending on the size of the partition.

---

### 8. Mount the New Partition & Check

Once the partition is formatted, you can mount it back for use:

1. Create a mount point (if it doesn’t exist yet):
```bash
sudo mkdir -p /mnt/mydisk
```

2. Mount the partition:
```bash
sudo mount /dev/sda1 /mnt/mydisk
```

3. Verify the mount:
```bash
df -h
```

You should now see the newly mounted **`sda1`** partition, and it should be available in **`/mnt/mydisk`**.

---

### 9. Add to `/etc/fstab` for Persistent Mounting (Optional)

If you want this disk to mount automatically at boot, add an entry to **`/etc/fstab`**:

1. Find the **UUID** of the partition:
```bash
sudo blkid /dev/sda1
```

You will see an output that looks something like this:
```bash
/dev/sda1: UUID="xxxx-xxxx-xxxx-xxxx" TYPE="ext4"
```

2. Open `/etc/fstab` in an editor:
```bash
sudo nano /etc/fstab
```

3. Add the following line to the end of the file to make the partition auto-mount at `/mnt/mydisk` on boot:
```bash
UUID=xxxx-xxxx-xxxx-xxxx /mnt/mydisk ext4 defaults 0 0
```

4. Save (`Ctrl + O`) and exit (`Ctrl + X`).

---

### **Conclusion:**
You’ve now successfully reformatted and recreated **`sda1`** using `fdisk` and formatted it as **ext4**. This partition is mounted and ready to store data. By adding the entry to **`/etc/fstab`**, it will automatically mount on boot.

Let me know if you run into any issues or need clarification!
91 changes: 91 additions & 0 deletions RAID_1_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
Using RAID (Redundant Array of Independent Disks) can help you achieve redundancy for data protection. For your requirements, you would use RAID 1, which mirrors data across both disks.

Here's how you can configure RAID 1 on your Raspberry Pi using `mdadm`, a software RAID utility:

### **1. Install mdadm**
First, you need to install `mdadm` if it's not already present.

```bash
sudo apt update
sudo apt install mdadm
```

### **2. Create the RAID Array**
Assuming your disks are `/dev/sda1` and `/dev/sdb1`, you can create a RAID 1 array like this:

```bash
sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
```

- `/dev/md0` is the virtual disk for the RAID array.
- `--level=1` specifies RAID 1.
- `--raid-devices=2` means you'll be using two devices for the array.

### **3. Verify RAID Array Creation**
Check the RAID status with the following command:

```bash
cat /proc/mdstat
```

This should show the RAID array's status, indicating that it's syncing, initializing, or active.

### **4. Create a Filesystem on the RAID Array**
Format the new RAID array with a filesystem, for instance, ext4:

```bash
sudo mkfs.ext4 /dev/md0
```

### **5. Mount the RAID Array**
Create a directory to mount the RAID array and mount it:

```bash
sudo mkdir -p /mnt/raid1
sudo mount /dev/md0 /mnt/raid1
```

### **6. Configure Auto-Mounting on Boot**
Edit the `/etc/fstab` file to auto-mount the RAID array on boot:

1. **Get the UUID of RAID Array:**
```bash
sudo blkid /dev/md0
```

2. **Add to fstab:**
- Open fstab:
```bash
sudo nano /etc/fstab
```
- Add the entry (replace `UUID=xxxx` with your actual UUID from the blkid command):
```
UUID=xxxx /mnt/raid1 ext4 defaults 0 0
```

### **7. Postgres Configuration**
You'll need to point PostgreSQL to use this RAID array for its data directory. Here's a basic outline:

1. **Stop PostgreSQL Service:**
```bash
sudo systemctl stop postgresql
```

2. **Move Data Directory:**
```bash
sudo rsync -av /var/lib/postgresql /mnt/raid1
```

3. **Adjust PostgreSQL Configuration:**
Open the PostgreSQL configuration file, usually located at `/etc/postgresql/*/main/postgresql.conf`, and update the data directory to `/mnt/raid1/postgresql`.

```bash
sudo nano /etc/postgresql/*/main/postgresql.conf
```

4. **Start PostgreSQL Service:**
```bash
sudo systemctl start postgresql
```

With these steps, your PostgreSQL database should be storing its data on the RAID 1 array, ensuring redundancy. Make sure to test and validate the setup to ensure everything is working correctly. Let me know if you need further assistance!
Loading