paultclark.com

Raspberry Pi

Ok you heard about a $35 computer. Well depends on how many spare parts you have lying around. So technically, its $35 and some parts.

Notes:

  • Identify how you are going to use it. You may need a 32 GB Class 10 SDHC. The SD card is your hard drive (HDD), unless you mount an external via USB.
  • You will have to understand another operating system (OS). This is not Windows or Ubuntu. You will have to use command line interface.
  • You may have to install the OS more than once. Persistance wins. This is a do it yourself project.


Parts for Model B:

  • The raspberry pi. I bought the Raspberry Pi Model B Programmers Kit from Micro Center, If they were in stock I would have bought the Raspberry Pi Model B Starter Kit. Both are above the $35 but you will need a power supply and a SDHC card.
  • SD card. Don't buy any 8GB, use this list. You will want a Class 10 and I recommend 16GB.
  • Power supply, make sure it is at least 700mA at 5V.
  • USB wired keyboard. You can go wireless, results may vary.
  • USB wired mouse. You can go wireless, results may vary.
  • Display / monitor.
  • Cable to connect your display to the HDMI input on the pi.
  • Speakers, if you need sound.
  • Cable to connect your speakers to the 3.5mm input on the pi.
  • Network cable.
  • If you do not have all of these parts lying around, then you may want to consider Raspberry Pi HDMI Cable Accessory Kit
  • USB Powered Hub, depending on what you are going to plug into it. You may wnat to use this list.

What to do:

  • Don't plug it in, not yet.
  • Skip this step if you have a SDHC card with the OS on it. Install OS on the SD card using a non-pi computer. I was unable to get their formatting tool to work, so I used Microsoft's. I chose NOOBS Lite.
  • Assemble the parts.
  • Plug it in.
  • I chose Raspbian. The install will take a while.
  • Once you get to the configuration screen
    I recommend leaving the Boot to Desktop alone.
    Set the time zone in internationalisation options.
    Set the hostname in Advanced Options.
  • Default username and password.
  • Should be at command line.


Datadog - How to
Your mileage may vary. This is how I did it.


DDNS - How to
Your mileage may vary. This is how I did it. This is a no pay solution.

  • You need Apache and PHP
  • You need SSH
  • You need a mail server. You can use the SMTP solution below.
  • You need your WAN IP. I use http://ipecho.net/plain
  • cd /var/www/, assuming that is where your DocumentRoot is located
  • touch wan.txt, this is a placeholder to keep track of the wan ip. I use it for something else besides this.
  • echo "0.0.0.0" > wan.txt, this will allow us to test the email gets sent once we run the script
  • You need to copy the script
  • rename wan.phps to wan.php
  • edit wan.php
    • Update the timezone, if you do not live in the east coast US.
    • Update the $headers value. This is the sender.
    • Update the $recipient value. This may be your gmail account.
      If so, Let less secure apps use your account must be set.
    • Remove the comment in front of the mail statement towards the bottom
  • Copy wan.php to your DocumentRoot
  • php wan.php
  • sudo crontab -e
    • Assuming you want to check every 5 minutes and DocumentRoot is /var/www/. Add "* /5 * * * php /var/www/wan.php" without the quotes
  • The script could be improved. This is a down and dirty.


Remote Desktop Connection


SMTP - How to
Your mileage may vary. This is how I did it.

  • sudo apt-get update
  • sudo apt-get install ssmtp
  • sudo apt-get install mailutils
  • sudo vi /etc/ssmtp/ssmtp.conf
      root=postmaster
      mailhub=smtp.gmail.com:587
      hostname=rasppi2
      AuthUser=YourGmailUserName@gmail.com
      AuthPass=YourGmailPassword
      FromLineOverride=YES
      UseSTARTTLS=YES
                  
  • Let less secure apps use your account
  • echo "Hello world email body" | mail -s "Test Subject" recipientname@recipientdomain.com


SNMP - How to
Your mileage may vary. This is how I did it. If you follow the attached links, you will see they did it slightly different.

  • sudo apt-get update
  • sudo apt-get install snmpd
  • sudo apt-get install snmp
  • sudo apt-get install snmp-mibs-downloader
  • sudo download-mibs
  • sudo vi /etc/snmp/snmpd.conf
    • agentAddress udp:161
      ipv4 only, dont turn on ipv6 instance unless you have installed ipv6 already
    • rocommunity public localhost
      gives localhost read access using a password of \"public\" w/o quotes
    • rocommunity something 10.0.0.0/8
      gives anyone on 10 network read access using a password of \"something\" w/o quotes
  • sudo vi /etc/snmp/snmp.conf
    • #mibs
      add # symbol to mibs line as file states
  • sudo service snmpd restart
  • ps -A | grep snmp
    • should yield pid and snmpd
      if not, view /var/log/syslog for errors
  • snmpwalk -v1 -c public localhost sysName.0
    • assumes the password is public
    • assumes you are on localhost
    • returns your hostname, e.g. rasppi2


Commands:

  • df -h
    Show in human readable format my disk usage.
  • sudo fdisk -c /dev/mmcblk0
    p
    This displays how your SD card is formatted.
    For example: Disk /dev/mmcblk0: 4012 MB, 4012900352 bytes. Pi reports this a 4GB card.
  • sudo shutdown now
    A proper way to turn it off.
  • startx
    This starts your graphical user interface (GUI).
  • uname -a
    Linux raspberrypi 4.1.19-v7+


Safe mode / Recovery mode
Technically, there is no safe mode for Raspbian. However, use these steps and you may recover your OS without wiping your existing one.

  • Identify what is broken. It may be there right on the screen during the boot sequence. You may have to search on the www for an answer. If you cannot identify what needs fixed, then you really don't need to go into safe mode to fix it.
  • During bootup, you should see a screen which states, \"Hold down shift to run recovery mode\". Do it.
  • Press the edit config (e) icon. A popup occurs.
  • Choose cmdline.txt in the Config editor.
    • Example: dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p5 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
  • Add "init=/bin/bash" without the quotes to the end of the line.
    • Example: dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p5 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait init=/bin/bash
  • Press OK
  • Press Exit
  • After boot sequence, you may need to press enter to get a command prompt. I did.
  • bash
  • mount -o remount,rw /dev/mmcblk0p5
  • Go fix whatever is broke. In my case it was /etc/fstab.
  • Reboot.
  • Go back into Recovery mode like you did above.
  • Remove "init=/bin/bash" from cmdline.txt.
  • After boot sequence, if you fixed it, you will get in. Otherwise, you may need to repeat some of the previous steps.


Useful links: