Showing posts with label Raspbian. Show all posts
Showing posts with label Raspbian. Show all posts

16 February, 2020

Rebuild my docker lab setup

Background

Over the last few weeks, I have rebuilt my Docker lab and Home Assistant set up a few times.  The heart of the setup is a Raspberry 4. Finally, all the hardware I ordered has arrived and I have a bit of time to rebuild my setup. Hopefully, I won't need to rebuild for a while.

Plan

This time I want to set up a Rasberry Pi 4 Model B (2GB) with Raspbain Buster then configure the Pi to use a 1 TB SSD. Since the Rasberry Pi 4 doesn't currently support booting from an SSD, I will use the workaround from James Chambers. Once the Rasberry Pi is set up and a basic configuration is done, I will then install IOTstack from Graham Garner. This will help me set up Docker, HASS.io, Portainer, Mosquitto, and Tasmoadmin.

What I am hoping to get out of this is a stable platform for learning and experimenting with Docker,  Home Automation, Internet of Things, and electronics.

Notes

Setting up the Raspberry Pi

  • Used balenaEtcher to flash Raspbian Buster with desktop to an 8 Gig SD Card
  • Used balenaEtcher to flash Raspbian Buster with desktop to a 1 TB SSD
  • Plugged in a monitor, keyboard, mouse, network cable and applied power
    • I waited for about 5 minutes for the system to run through its first-time power-up.
  • created an empty file named ssh and placed it the boot folder for both SD and SSD
    • created the file wpa_supplicant.conf and placed it in the boot folder for both SD and SSD
    • Set basic config values for keyboard
    • changed the pi default password
    • skipped the update
  • sudo fdisk /dev/sda
    • set the SSD PARTUUID to d34db33f
  • sudo blkid
  • made backup of /boot/cmdline.txt
  • edited /boot/cmdline.txt to use the PARTUUID that was set earlier
  • sudo reboot
  • verified the SSD is being used
    • findmnt -n -o SOURCE /
  • updated /etc/fstab 
    • changed the PARTUUID to d34db33f
  • sudo reboot
  • resizing filesystem
    • delete the partition /dev/sda2
    • create a new partition with a first sector at 532480
    • sudo resize2fs /dev/sda2
      • This takes a while
    • df -h 
      • verify /dev/root shows a size value close to the size of the drive
  • sudo reboot

Configuring the Raspberry Pi

  • set Hostname
  • boot to CLI
  • auto login: uncheck mark
  • sudo reboot
  • verified Raspberry Pi configuration
  • verified that I can ssh into the raspberry pi
  • sudo apt update
  • sudo apt upgrade

Install IOTstack

  • ensure git is installed
    • sudo apt install git
  • clone IOTstack
    • git clone https://github.com/gcgarner/IOTstack.git ~/IOTstack
  • run menu
    • cd IOTstack
    • ./menu.sh
      • installed docker
      • installed Hass.io
      • installed Portainer
      • installed Mosquitto
      • installed tasmoadmin
  • docker-compose up -d




References

Github gcgarner / IOTstack







26 January, 2020

Setting up Home Assistant on Raspberry Pi using generic Linux host method



Recently my installation of Home Assistant died. It appears that I burned up the SD card. I can no longer read the SD Card. When I run gparted against the SD card, the card mounts in read-only mode. After a bit of research, I came up with a plan.

Rough Plan


  • Install the latest Raspbian Buster image
  • Reconfigure the Pi to run from a hard drive
  • Install Home Assistant using the generic Linux host method

Steps

  • Downloaded Raspbian Buster with desktop from the Raspberry Pi website
  • Using balenaEtcher to flash Buster to an SD card (8GB)
  • Booted the Pi for the first time
  • Setup the language, keyboard, and timezone. 
    • Changed the pi user's password
    • Selected the WiFi network
    • Updated the software
  • Updated the packages
    • sudo apt update
    • sudo apt upgrade
    • sudo reboot
  • Followed the directions from the blog post 'Quick SD to SSD on the pi 4'
    • use the utility 'SD Card Copier' to copy the SD card to the hard drive
    • run 'sudo blkid' to get the UUID of the SD sard and the hard drive
    • backup the file /boot/cmdline.txt
    • edit the file /boot/cmdline.txt. Change the partuuid from using the SD card to the hard drive
    • reboot
    • Note: must leave the SD card in the Raspberry Pi
  • Changed the hostname of the Pi
  • Enabled SSH on the Pi
  • Setup ssh key on my main PC
    • ssh-keygen
    • ssh-copy -i ~/.ssh/key-name pi@ip.address
    • ssh-add
  • Disable Password Authentication on the Pi
    • sudo nano /etc/ssh/sshd_config
      • Uncommented the line 'PasswordAuthentication yes'
      • changed yes to no
  • Set a static IP for the Pi
    • edit /etc/dhcpcd.conf
      • added
        • interface wlan0
        • static ip_address=XXX.XXX.XXX.XXX
        • static routers=XXX.XXX.XXX.XXX
        • static domain_name_servers=XXX.XXX.XXX.XXX
    • reboot
  • Changed Pi Configuration to boot to cli
  • Followed the directions from the blog post 'Install Docker and Docker Compose on Raspberry pi 4(Raspbian Buster)'
    • curl -sSL get.docker.com | sh
    • sudo usermod -aG docker pi
    • sudo apt-get install libffi-dev libssl-dev
    • sudo apt install python3-dev
    • sudo apt-get install -y python3 python3-pip
    • sudo pip3 install docker-compose
  • Followed installer for a generic Linux system
    • sudo apt install bash
    • sudo apt install jq
    • sudo apt install curl
    • sudo apt install avahi-daemon
    • sudo apt install dbus
    • sudo apt install apparmor-utils
  • curl -sL https://raw.githubusercontent.com/home-assistant/hassio-installer/master/hassio_install.sh | bash -s -- -m raspberrypi4-64
  • Setup Home Assistant
There was an issue with Home Assistant connecting to the internet. I removed the changes to /etc/dhcpcd.config. This seems to have helped. 

01 February, 2017

Keeping Raspbian Current

The other day, I decided to update Raspbian OS on my Raspberry Pi. The process was rather straightforward. After logging into the Raspberry Pi using ssh.

I updated the system's package list using the command:
sudo apt-get update  

To upgrade the installed packages without updating dependencies, I used the command:
sudo apt-get upgrade  

Alternatively, I could have used the following to upgrade the installed packages and change dependencies.
sudo apt-get dist-upgrade  

Upgrade is used to install the newest version of all packages currently installed. Dist-upgrade performs the same functionality as upgrade does plus it changes dependencies.

It is worthwhile to cleanup the local repository. There are few commands to help with this.

sudo apt-get clean  
Clean clears out the local repository.

sudo apt-get autoclean  
Autoclean removes package files that can no longer be downloaded

sudo apt-get autoremove  
Autoremove cleans out dependencies that are not longer needed.

Recently, I got into chaining commands together. I started doing so that I would not have to keep track of which command I had already run and which command needs to be run.
To upgrade the installed packages and change dependencies, I used the command:
sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get clean

Challenging myself to learn something new

I have recently set a big challenge for myself. I want to know about Machine Learning . To add to the challenge, I am trying out usin...