Automating NFS Mounts with Autofs on Raspberry Pi for Docker Swarm

When managing a Docker Swarm on a fleet of Raspberry Pis, ensuring consistent and reliable access to shared storage across your nodes is crucial. This is where Autofs comes into play. Autofs is a utility that automatically mounts network file systems when they’re accessed, making it an ideal solution for managing persistent storage in a Docker Swarm environment. In this blog post, we’ll walk through the process of installing and configuring Autofs on a Raspberry Pi to use with an NFS server for shared storage.

Step 1: Setting Up the NFS Server

Before configuring Autofs, you need an NFS server that hosts your shared storage. If you haven’t already set up an NFS server, you can do so by installing the nfs-kernel-server package on your Raspberry Pi designated as the NFS server:

sudo apt install nfs-kernel-server -y

Then, configure the NFS export by editing the /etc/exports file and adding the following line to share the /data directory:

/data 192.168.0.0/24(rw,sync,no_subtree_check,no_root_squash)

Restart the NFS server to apply the changes:

sudo /etc/init.d/nfs-kernel-server restart

Verify the export with:

sudo exportfs

Step 2: Installing Autofs on Client Raspberry Pis

On each Raspberry Pi client that needs access to the NFS share, install Autofs:

sudo apt update -y
sudo apt install autofs -y

Reboot the Raspberry Pi to ensure all updates are applied:

sudo reboot

Step 3: Configuring Autofs

After installing Autofs, you’ll need to configure it to automatically mount the NFS share. Edit the /etc/auto.master file and add a line for the mount point:

/-    /etc/auto.data --timeout=60

Create and edit /etc/auto.data to specify the NFS share details:

/data -fstype=nfs,rw 192.168.0.220:/data

This configuration tells Autofs to mount the NFS share located at 192.168.0.220:/data to /data on the client Raspberry Pi.

Step 4: Starting and Testing Autofs

Enable and start the Autofs service:

sudo systemctl enable autofs
sudo systemctl start autofs

Check the status to ensure it’s running without issues:

sudo systemctl status autofs

To test, simply access the /data directory on the client Raspberry Pi. Autofs should automatically mount the NFS share.

cd /data
ls

If you see the contents of your NFS share, the setup is successful. Autofs will now manage the mount points automatically, ensuring your Docker Swarm has seamless access to shared storage.

Conclusion

By leveraging Autofs with NFS on Raspberry Pi, you can streamline the management of shared volumes in your Docker Swarm, enhancing both reliability and efficiency. This setup minimizes the manual intervention required for mounting shared storage, making your Swarm more resilient to reboots and network changes. Happy Swarming!




Setting Up NTP on Raspberry Pi “Bookworm” for Accurate Timekeeping

Introduction

Accurate timekeeping is essential for various applications, from logging to scheduling tasks. While there are numerous public NTP servers, setting up your own NTP server offers more control and can be quite satisfying. In this blog post, we’ll explore how to configure a Raspberry Pi, affectionately named “Bookworm,” to sync time using an NTP server.

Why Raspberry Pi?

The Raspberry Pi is a versatile and affordable piece of hardware that can handle a variety of tasks, including acting as an NTP client. Its low power consumption and ease of use make it an ideal choice for this purpose.

Prerequisites

  • A Raspberry Pi running a compatible Linux distribution (e.g., Raspbian)
  • Basic knowledge of Linux commands and vi text editor
  • Access to an NTP server (In this example, we use 192.168.0.1)

Step-by-Step Guide

  1. Check Current Time Sync Status
   timedatectl show-timesync --all

This command will display detailed information about the current time synchronization status on your Raspberry Pi.

  1. Edit the Configuration File
   sudo vi /etc/systemd/timesyncd.conf

Open the timesyncd.conf file using the vi text editor with superuser permissions.

  1. Set the NTP Server
   NTP=192.168.0.1

Add this line to the timesyncd.conf file to specify the NTP server you want to use. Save and exit the file.

  1. Restart the Time Sync Service
   sudo systemctl restart systemd-timesyncd

Restart the systemd-timesyncd service to apply the changes.

  1. Verify the Changes
   timedatectl show-timesync --all

Run this command again to confirm that the NTP server is now set to 192.168.0.1.

  1. Check the System Time
   date

Finally, use the date command to display the current system time, ensuring that it is accurate.

Conclusion

Configuring your Raspberry Pi “Bookworm” to use a specific NTP server is a straightforward process that ensures accurate timekeeping. This setup is particularly useful for networks where precise time is crucial. With these simple steps, you can achieve better control and reliability in time synchronization.

I hope you find this guide useful for setting up NTP on your Raspberry Pi “Bookworm.” Feel free to adapt these steps according to your specific needs.




How to Upgrade from Debian Bullseye to Bookworm on Raspberry Pi Without Reinstalling

Upgrading your Raspberry Pi’s operating system doesn’t always require a complete reinstallation. If you’re running Debian Bullseye and want to move to the newer Bookworm version, you can do so with a few simple steps. Before proceeding, make sure to back up all important data.

Step 1: Backup Your Data

First and foremost, backup all your important files. This ensures that you can recover your data in case something goes wrong during the upgrade.

Step 2: Update Current System

Open a terminal and run the following commands to update your existing Bullseye system:

sudo apt update
sudo apt upgrade
sudo apt dist-upgrade

Step 3: Change Repositories

Edit the /etc/apt/sources.list file and any files in /etc/apt/sources.list.d/ to replace ‘bullseye’ with ‘bookworm’. You can use the nano text editor for this:

sudo nano /etc/apt/sources.list

Step 4: Update Package List

After updating the repositories, run the following command to fetch the new package list:

sudo apt update

Step 5: Upgrade Packages

Execute the following commands to perform the upgrade:

sudo apt upgrade
sudo apt dist-upgrade

Step 6: Clean Up

Remove any obsolete packages to free up space:

sudo apt autoremove
sudo apt clean

Step 7: Reboot

Finally, reboot your Raspberry Pi to complete the upgrade:

sudo reboot

And there you have it! You’ve successfully upgraded from Debian Bullseye to Bookworm on your Raspberry Pi without a complete reinstallation. Always remember to read the specific release notes and upgrade instructions for your situation.


Feel free to use or modify this blog post as you see fit!




Optimizing Raspberry Pi Performance: Managing Connectivity with rfkill

Raspberry Pi, the credit-card-sized computer, has found its way into a multitude of projects and use cases, from DIY home automation to industrial applications. While its compact size and versatility make it a favorite among enthusiasts, managing certain aspects of its performance can enhance its capabilities. One such aspect is connectivity, specifically Wi-Fi and Bluetooth, which can be controlled using the rfkill utility. In this blog post, we’ll delve into what rfkill is, how to use it on your Raspberry Pi, and whether disabling Wi-Fi and Bluetooth when not in use can truly boost device performance.

What is rfkill?

rfkill is a command-line utility that allows you to interact with the wireless devices on your system, controlling their radio frequency (RF) state. This utility can be incredibly useful when dealing with Raspberry Pi, as it enables you to manage the state of Wi-Fi and Bluetooth modules easily.

Getting Started: Installation and Basics

To begin utilizing the rfkill utility, you’ll need to install it on your Raspberry Pi if it isn’t already present. Open a terminal and type the following command:

sudo apt install rfkill

Once installed, you can start manipulating the Wi-Fi and Bluetooth modules with simple commands.

  • To block Wi-Fi:
sudo rfkill block wifi

  • To block Bluetooth:
sudo rfkill block bluetooth

Conversely, if you want to unblock these modules to re-enable them, you can use:

  • To unblock Wi-Fi:
sudo rfkill unblock wifi

  • To unblock Bluetooth:
sudo rfkill unblock bluetooth

Performance Boost: To Block or Not to Block?

A common question that arises is whether disabling Wi-Fi and Bluetooth when they’re not in use can truly enhance Raspberry Pi’s performance. The answer isn’t straightforward and largely depends on your specific use case.

While it’s true that turning off these modules can free up system resources and reduce potential electromagnetic interference, the impact on overall performance might not be substantial for most projects. If your Raspberry Pi is performing tasks that do not heavily rely on internet connectivity or Bluetooth devices, you might not notice a significant difference.

However, in scenarios where every ounce of performance matters, such as real-time data processing or high-demand computing tasks, disabling Wi-Fi and Bluetooth could provide a marginal advantage.

Verifying the Status

To check the status of wireless modules, you can use the following command:

rfkill list all

This command will display a list of all wireless devices and their corresponding status (blocked or unblocked).

Conclusion

In conclusion, the rfkill utility offers a straightforward way to manage the connectivity of Wi-Fi and Bluetooth modules on your Raspberry Pi. While there might be a slight performance benefit in certain use cases when disabling these modules, the difference is unlikely to be noticeable for most projects. However, it’s always a good practice to know how to control various aspects of your Raspberry Pi’s functionality, as it might come in handy when working on diverse projects with varying requirements.




Creating Your Own Omada Controller for TP-Link Omada Access Points

Managing multiple TP-Link Omada access points can be a breeze when you have your very own Omada Controller set up. In this guide, we’ll walk you through the process of creating your Omada Controller using a Raspberry Pi, giving you the power to effortlessly handle your access points. Let’s dive in!

Preparing Your Raspberry Pi

To start, make sure your Raspberry Pi is up to date:

sudo apt update && sudo apt upgrade -y
sudo reboot

Installing MongoDB

The Omada Controller relies on MongoDB. Let’s install it:

wget https://repo.mongodb.org/apt/ubuntu/dists/focal/mongodb-org/4.4/multiverse/binary-arm64/mongodb-org-server_4.4.18_arm64.deb
sudo apt install /home/pi/mongodb-org-server_4.4.18_arm64.deb

Ensure MongoDB is running:

sudo systemctl daemon-reload
sudo systemctl enable mongod
sudo systemctl start mongod

Installing Dependencies

You’ll need a few more tools. Install them:

sudo apt install curl autoconf make gcc openjdk-11-jdk-headless
sudo apt remove jsvc

Compiling and Installing JSVC

Download and install JSVC:

wget https://dlcdn.apache.org/commons/daemon/source/commons-daemon-1.3.4-src.tar.gz
tar -xzf commons-daemon-1.3.4-src.tar.gz
cd commons-daemon-1.3.4-src/src/native/unix
sh support/buildconf.sh
./configure --with-java=/usr/lib/jvm/java-11-openjdk-arm64
make

ln -s /home/pi/commons-daemon-1.3.4-src/src/native/unix/jsvc /usr/bin/

sudo mkdir /usr/lib/jvm/java-11-openjdk-arm64/lib/aarch64
sudo ln -s /usr/lib/jvm/java-11-openjdk-arm64/lib/server /usr/lib/jvm/java-11-openjdk-arm64/lib/aarch64/

Installing Omada Controller

Now, let’s get the Omada Controller on your Pi:

cd /home/pi
wget https://static.tp-link.com/upload/software/2023/202303/20230321/Omada_SDN_Controller_v5.9.31_Linux_x64.deb
sudo dpkg --ignore-depends=jsvc -i Omada_SDN_Controller_v5.9.31_Linux_x64.deb

Accessing the Controller Interface

You can now access the Omada Controller’s web interface through your browser using:

  • HTTP: http://192.168.0.4:8088
  • HTTPS: https://192.168.0.4:8043

Keeping Things Updated

Keep your system and MongoDB updated:

apt list --upgradable
sudo apt-mark hold mongodb-org mongodb-org-server mongodb-org-shell mongodb-org-tools mongodb-org-mongos mongodb-org-database-tools-extra

Final Checks

Ensure everything is running smoothly:

sudo tpeap status
sudo tpeap start

If you need to stop the Omada Controller:

sudo tpeap stop

And always double-check MongoDB’s status:

service mongod status

With your very own Omada Controller up and running on your Raspberry Pi, you’re now equipped to effortlessly manage and optimize your TP-Link Omada access points. Enjoy the convenience of centralized control and efficient network management!




Booting Raspberry Pi via PXE: A Guide to Network Booting

Title: Booting Raspberry Pi via PXE: A Guide to Network Booting

Introduction

Raspberry Pi, with its versatility and affordability, has become a favorite among tech enthusiasts for various projects. One of the most intriguing applications is using PXE (Preboot Execution Environment) to boot Raspberry Pi devices over the network, eliminating the need for local storage. This method can simplify management and deployment in various scenarios. In this guide, we’ll walk you through the steps to set up PXE boot for your Raspberry Pi.

Prerequisites

Before diving into the PXE boot setup, ensure you have the following:

  • Raspberry Pi board(s)
  • Network access
  • A NAS (Network-Attached Storage) or server for storing boot and root images
  • Basic knowledge of Linux commands

Setting Up PXE Boot for Raspberry Pi

  1. Find Serial Number for PXE Boot Begin by finding the serial number of your Raspberry Pi. Open a terminal and enter the following command:
   vcgencmd otp_dump | grep 28: | sed s/.*://g

  1. Install Necessary Software Install the nfs-common package on your Raspberry Pi by running:
   sudo apt install nfs-common

  1. Configure Network Booting Use raspi-config to enable network booting:
   sudo raspi-config

In the advanced boot options, enable network booting and set the boot order to boot from the network if the SD card boot fails.

  1. Create Directories On your Raspberry Pi, create a directory in /rpi-tftpboot using the serial number obtained earlier. On your PXE server, create a directory with the hostname of your Raspberry Pi.
   mkdir /nfs/boot /nfs/root

  1. Mount NAS Mount your NAS or server to the created directories:
   sudo mount -t nfs -o proto=tcp,port=2049 192.168.0.11:/volume1/rpi-tftpboot/8eb2f324 /nfs/boot
   sudo mount -t nfs -o proto=tcp,port=2049 192.168.0.11:/volume1/rpi-pxe/RPI4GB /nfs/root

  1. Copy Boot and Root Images Copy the boot image to the /nfs/boot directory and the root image to the /nfs/root directory:
   sudo rsync -av /boot/* /nfs/boot
   sudo rsync -av --exclude '/nfs' / /nfs/root

  1. Modify Command Line Edit the cmdline.txt file in the /nfs/boot directory to adjust the mount point and other parameters:
   sudo nano /nfs/boot/cmdline.txt

Modify the console, root, and nfsroot parameters to match your setup:

   console=serial0,115200 console=tty1 root=/dev/nfs nfsroot=192.168.0.11:/volume1/rpi-pxe/RPI4GB rw ip=dhcp elevator=deadline rootwait

  1. Update /etc/fstab Edit the /etc/fstab file on the Raspberry Pi to update the mount points for the boot and root directories:
   sudo nano /nfs/root/etc/fstab

Update the entries with the appropriate paths:

   192.168.0.11:/volume1/rpi-tftpboot/8eb2f324  /boot           nfs    defaults          0       2
   192.168.0.11:/volume1/rpi-pxe/RPI4GB  /               nfs    defaults,noatime  0       1

Conclusion

By following these steps, you’ve successfully set up PXE boot for your Raspberry Pi devices. Network booting offers flexibility, scalability, and centralized management for your projects. This method can be particularly valuable for large-scale deployments or when you want to minimize the reliance on physical storage. Enjoy the benefits of network booting and explore new possibilities for your Raspberry Pi projects!




Harnessing the Power of Python on Raspberry Pi: A Comprehensive Guide

Introduction

The Raspberry Pi, a versatile and affordable single-board computer, opens up a world of possibilities for tech enthusiasts, hobbyists, and programmers. Among the various programming languages available, Python stands out as the ideal choice due to its simplicity and extensive libraries. In this blog post, we will explore how to use Python on Raspberry Pi, from setting up the environment to executing basic scripts and creating exciting projects.

  1. Getting Started: Setting up Python on Raspberry Pi

Before diving into Python programming on your Raspberry Pi, ensure that you have the latest version of Raspbian or Raspberry Pi OS installed. Python is pre-installed on most Raspberry Pi operating systems, so you’re already halfway there. To check if Python is installed, simply open the terminal and type python --version.

  1. Running Python Scripts

To execute Python scripts on your Raspberry Pi, you need to create a new file with a .py extension. Use a text editor like Nano or Thonny, which comes pre-installed with Raspberry Pi OS. Write your Python code, save the file, and use the terminal to navigate to the file’s directory. Run the script by typing python your_script_name.py.

  1. GPIO Control with Python

One of the most exciting features of Raspberry Pi is its GPIO (General Purpose Input Output) pins, which allow you to interact with the physical world. With Python, you can easily control LEDs, motors, sensors, and more using the GPIO library. Explore the GPIO documentation to understand how to set up and use these pins in your projects.

  1. Accessing Python Libraries

Python’s extensive library ecosystem enhances the capabilities of your Raspberry Pi. Whether you want to work with images, handle sensors, or connect to the internet, Python libraries have you covered. Use pip, Python’s package manager, to install the necessary libraries and supercharge your projects.

  1. Creating Projects: The Sky’s the Limit

Once you’ve mastered the basics of Python on Raspberry Pi, it’s time to unleash your creativity and embark on exciting projects. Some popular ideas include creating a weather station, building a home automation system, setting up a security camera, or even developing a retro gaming console using Python.

  1. Troubleshooting and Learning Resources

As with any programming journey, you may encounter challenges along the way. Remember that the Raspberry Pi community is vast and incredibly supportive. Online forums, websites, and tutorials are readily available to help you troubleshoot issues and learn from experienced enthusiasts.

Conclusion

Python on Raspberry Pi is a match made in technology heaven, offering a simple yet powerful platform for programming and experimenting. By harnessing Python’s capabilities, you can create a wide range of exciting projects, from controlling physical components with GPIO to developing web applications and beyond.

The Raspberry Pi is more than just a computer; it’s a gateway to endless possibilities, where your creativity and technical skills can flourish. Embrace the Python language, explore its vast libraries, and embark on an enriching journey of innovation and discovery with your Raspberry Pi. Happy coding!




Unleashing NAS Potential: OMV on Raspberry Pi and ZimaBoard

Title: Unleashing NAS Potential: OMV on Raspberry Pi and ZimaBoard

Introduction

Network-Attached Storage (NAS) solutions have become increasingly popular as data storage needs continue to grow. While commercial NAS devices are available, they can be costly and might not fully cater to your specific requirements. In this blog post, we will explore two affordable and powerful options for building a versatile NAS: using OpenMediaVault (OMV) on the Raspberry Pi and the ZimaBoard. With these setups, you can create a feature-rich and cost-effective storage solution tailored to your needs.

  1. Raspberry Pi: A Budget-Friendly NAS Solution

The Raspberry Pi is a credit card-sized single-board computer that has captured the hearts of tech enthusiasts worldwide. Its low cost, energy efficiency, and flexibility make it an excellent choice for various projects, including NAS applications. By using OMV, an open-source NAS operating system, you can easily transform your Raspberry Pi into a capable storage server.

  1. Introducing OpenMediaVault (OMV)

OMV is a Linux-based operating system specifically designed for managing NAS setups. It offers a user-friendly web interface that simplifies the setup and configuration of various storage services, such as Samba, NFS, FTP, and more. OMV’s extensive plugin ecosystem allows you to expand its functionality effortlessly, making it a versatile NAS solution for home and small office use.

  1. Raspberry Pi NAS Setup with OMV

Setting up OMV on your Raspberry Pi is a straightforward process. All you need is a compatible Raspberry Pi board, a microSD card, and an internet connection. The OMV image can be easily flashed onto the microSD card using popular tools like Etcher. Once booted, you can configure OMV through its web interface, where you can manage disks, set up user permissions, and enable various services for seamless file sharing.

  1. ZimaBoard: Taking NAS Performance to the Next Level

While the Raspberry Pi is an excellent budget option for basic NAS needs, the ZimaBoard takes NAS applications to new heights. This single-board computer packs a quad-core processor, up to 8GB of RAM, and multiple SATA ports, allowing for higher data throughput and better performance for more demanding storage tasks.

  1. Building a NAS with ZimaBoard

Utilizing OMV on the ZimaBoard enhances the NAS experience significantly. With improved hardware capabilities, you can create a more robust RAID setup for data redundancy, implement advanced caching mechanisms, and support higher numbers of concurrent users accessing the NAS. Whether you need a central file server, a media streaming hub, or a backup repository, the ZimaBoard equipped with OMV can deliver top-tier performance.

  1. Combining Raspberry Pi and ZimaBoard for Scalability

For users seeking both scalability and cost-effectiveness, a combination of Raspberry Pi and ZimaBoard can be an ingenious solution. Use Raspberry Pi-based OMV setups for less demanding storage tasks or to set up distributed storage nodes in various locations. For the core NAS with higher performance requirements, deploy a ZimaBoard-based OMV server.

Conclusion

OMV on the Raspberry Pi and ZimaBoard opens up a world of possibilities for building your custom NAS solution. Whether you’re a DIY enthusiast on a budget or require a more powerful and expandable storage server, these options have you covered. The Raspberry Pi provides an affordable entry point into the world of NAS, while the ZimaBoard takes performance and versatility to new heights.

Regardless of your choice, OMV’s user-friendly interface and extensive plugin support ensure a smooth and seamless NAS setup experience. Embrace the power of OMV on Raspberry Pi and ZimaBoard, and unlock the true potential of Network-Attached Storage for all your data storage, sharing, and backup needs.




Installing and Configuring Unattended Upgrades on Raspberry Pi

Introduction:
Unattended Upgrades is a package that automates the process of installing security updates on your Raspberry Pi. In this guide, we’ll walk you through the steps to install and configure Unattended Upgrades, ensuring your Raspberry Pi stays up-to-date with the latest patches automatically.

Step 1: Install Unattended Upgrades

To install Unattended Upgrades on your Raspberry Pi, update the package list and install it with the following commands:

sudo apt-get update
sudo apt-get install unattended-upgrades -y

Step 2: Test Unattended Upgrades (Dry Run)

Before enabling Unattended Upgrades, it’s a good idea to test it with a dry run to see what updates would be applied. Use the following command:

sudo unattended-upgrade -d -v --dry-run

This will show you the pending updates without actually installing them.

Step 3: Enable Unattended Upgrades

To enable Unattended Upgrades, use the following command to reconfigure the package with priority set to low:

sudo dpkg-reconfigure --priority=low unattended-upgrades

Follow the prompts to enable automatic updates.

Step 4: Information

With Unattended Upgrades enabled, your Raspberry Pi will now automatically download and install security updates, keeping your system protected with the latest patches.

Conclusion:
By following these steps, you have successfully installed and configured Unattended Upgrades on your Raspberry Pi. This means your Raspberry Pi will now automatically update itself with security patches, ensuring that it remains secure and up-to-date without manual intervention.

Enjoy the peace of mind knowing that your Raspberry Pi is being kept secure and up-to-date automatically! Happy computing!




Configuring Power-On/Off Button for Raspberry Pi 4B

Introduction:
Adding a power-on/off button to your Raspberry Pi 4B can provide a convenient way to manage the device’s power state. In this guide, we’ll show you how to configure a power-on/off button using the GPIO pins on the Raspberry Pi 4B.

Step 1: Edit the /boot/config.txt File

To configure the power-on/off button, you need to edit the /boot/config.txt file on your Raspberry Pi. Open the file using the following command:

sudo vi /boot/config.txt

Step 2: Enable Shutdown Functionality

To enable the shutdown functionality of the power button (green LED turns off when shutting down), add the following line to the config file:

dtoverlay=gpio-shutdown

Step 3: Enable Power-Off Functionality

To enable the power-off functionality of the power button (both green and red LEDs turn off when powered off), add the following lines to the config file:

dtoverlay=gpio-shutdown,gpio_pin=3
dtoverlay=gpio-poweroff,gpio_pin=24,active_low=0

Explanation of options used:

  • dtoverlay=gpio-shutdown: Enables the GPIO shutdown overlay to manage the shutdown functionality.
  • gpio_pin=3: Specifies the GPIO pin (BCM numbering) to use for the shutdown function (default is GPIO3).
  • dtoverlay=gpio-poweroff: Enables the GPIO power-off overlay to manage the power-off functionality.
  • gpio_pin=24: Specifies the GPIO pin (BCM numbering) to use for the power-off function (default is GPIO24).
  • active_low=0: Sets the active_low parameter to 0, which means the GPIO pin is active high (low signal triggers the action).

Step 4: Save and Reboot

Save the changes to the /boot/config.txt file, and then reboot your Raspberry Pi for the changes to take effect:

sudo reboot

Conclusion:
By following these steps and editing the /boot/config.txt file, you can easily configure a power-on/off button for your Raspberry Pi 4B. The power button will provide you with convenient control over the device’s power state, allowing for a smooth and efficient experience in managing your Raspberry Pi.

For more detailed information and the source of this guide, you can visit the provided link: Reviving Borkin Power On/Off Button for the Raspberry Pi 4B.