Home‎ > ‎Dabbles‎ > ‎RaspberryPi‎ > ‎

Getting Started - Building the Template Image

posted Nov 3, 2014, 4:47 PM by Joshua ‎(Admin)‎   [ updated Dec 7, 2014, 12:07 PM by Joshua S ]
This is the first post about the RaspberryPi.  The eventual goal is to set up a home thermostat, but along the way I'm going to set up an authentication server, a VPN server, a database server, a web server, etc.  

Most of these steps can be performed in any order, but if you follow the order outlined here it will all definitely work.  I've found a number of guides to help me, but many have partial documentation, skip key steps, etc.  The goal is to build out a guide with everything you need to complete each step, but let me know if I miss something or it isn't clear.

This all starts with building the Template Image.  This will automate the creation of the basic configurations and setup so that the steps don't need to be repeated before building each additional Pi.  Note, this is the first step which is performed before building the Authentication server -- a second step will be integrating central authentication into the template.  This does assume you are running Windows, but these steps can also be completed on virtually any platform.

For the template, I used an 8GB memory card.  With the B+, the image you back up will be the full size of the card whether you expand the file system or not.  For the actual projects, I use a mix of card sizes -- generally 32GB, but I like my templates to be 8GB to reduce the storage size of my backups.

Supply List:
  • AngryIP Scanner  A network utility (sometimes considered a hacking tool by AntiVirus programs) used to scan the network and identify live hosts.  If this is a one time use, you may want to simply use the portable version, but I find, now that I have it, that I use it frequently.
  • MicroSD Card  A digital memory card, initially designed for media (think a camera) but which will serve as the hard drive for the RaspberryPi.  All tutorials will focus on the 8GB size, but you can easily use this process for a larger format also.  
  • PuTTY  A free SSH client which is excellent for working at the command line.  I know, I know, no one loves the Command Line any more, but the more you use the RaspberryPi the more you will quickly learn that CommandLine > GUI.
  • RaspberryPi B+  The actual RaspberryPi hardware this will all be built around.  
  • Raspbian  The Debian Linux based Operating System (OS) designed for the RaspberryPi.  Download the latest version from the website.  Note, other OS's are also on this page, including a version of Fedora and a port of XBMC, but my projects all work with the Raspbian distro.
  • Win32 Disk Imager  A Free Open Source Software (FOSS) utility to write of image (.IMG) files to various flash card media (SD, MicroSD, etc.).  Download the software from the website.

  • I know I said this guide was going to be comprehensive and not skip any steps, so what better way to start this off than by skipping steps.  I am not writing out instructions for the following (and illustrating from XKCD):
    • Buying a MicroSD Card
    • Buying a RaspberryPi B+
    • Downloading & Extracting PuTTY
    • Downloading & Extracting Raspbian
    • Downloading & Extracting Win32 Disk Imager
  • Note -- you will notice throughout this guide, we will use the 192.168.84.X IP address ranges.  This was done intentionally to support the VPN project later (if you use the same IP range you are currently connected to, some traffic may leak out -- or so I'm told).  Another great illustration from XKCD.
  • Insert the MicroSD card into your computer's reader.  Run Win32 Disk Imager and select the Raspbian image file (downloaded & extracted).  Ensure the drive letter selected is that of the MicroSD card and select the "Write" button.
  • Remove the card from your computer's reader and insert it into the RaspberryPi.  Hook the RaspberryPi up to power and ethernet.  Then scan the IP range using AngryIP scanner to locate your new RaspberryPi.
  • When the scanner completes, look for the result with a MAC vendor of "Raspberry" -- this should be the RaspberryPi.  Note the IP address of the Pi.
  • Using PuTTY (or whatever SSH client you prefer) connect to the IP address you identified in the previous step.
  • Once connected, log onto the Pi using:
    • UserID:  pi 
    • Password:  raspberry
  • Enter the RaspberryPi configuration menu by typing the command:
    • sudo raspi-config

  • First, we are going to enable SSH.  It appears to already be enabled, but we will confirm the setting in the event this is an initial setup setting.  Select #8, advanced options, followed by #A4, SSH, the enable option, and finally OK.

  • Next, we are going to enable the local locale.  Select #4, internationalization options, followed by I1.  Scroll down to en_US.UTF-8 UTF-8 and press the spacebar to select.  When prompted for the default locale, select en_US.UTF-8 and say OK.

  • Next, we are going to enable the local timezone.  Select #4, internationalization options, followed by I2 change timezone.  The next set of options will depend on your location, but I chose US and Eastern.

  • Finally, let's expand the file system.  With the B+, images will be the full size of the memory card you use, but this will tell the Pi that all of the space is available.  Select #1 expand filesystem, 

  • We're done with configuration for now -- select Finish followed the "sudo reboot" command to restart the RaspberryPi with the new settings.

  • Raspbian uses Advanced Package Tool (APT) to manage and install software.  First, we need to update the tool using:
    • sudo apt-get -y update
  • Now let's update the software currently loaded.  There are several ways to do this, but if we issue the dist-upgrade command it will intelligently add software, update packages, and remove unneeded packages.
    • sudo apt-get -y dist-upgrade
  • Finally, let's upgrade the Pi Kernel:
    • sudo rpi-update

  • Let's reboot now that the upgrades are complete:
    • sudo reboot

  • OK, good!  Now that everything is updated, let's install the following packages using this command:
    • sudo apt-get -y install chromium clamav epiphany-browser filezilla iceweasel p7zip-full perlbrew screen xrdp 
      • chromium  Chromium Browser, essentially this is the open source version of Google Chrome.
      • clamav  Anti-virus utility for Unix - command-line interface.
      • epiphany-browser  Intuitive GNOME web browser.
      • filezilla  Full-featured graphical FTP/FTPS/SFTP client.
      • iceweasel  Web browser based on Firefox.
      • p7zip-full  7z file archiver with high compression ratio.
      • perlbrew  Script to manage perl installations in your $HOME.
      • screen  Terminal multiplexer with VT100/ANSI terminal emulation.
      • xrdp  Remote Desktop Protocol (RDP) server.
  • Power off the RaspberryPi and pull out the MicroSD card.  Insert it into your computer's card reader and run Win32 Disk Imager.  Create a new image file you name as your template and select the "Read" button.
  • Mission accomplished!  You created a template image for your RaspberryPi!