Skip to content

Instantly share code, notes, and snippets.

@caseyanderson
Last active October 17, 2022 16:38
Show Gist options
  • Save caseyanderson/396f94678cccda35dcd4d5a2a91fd69b to your computer and use it in GitHub Desktop.
Save caseyanderson/396f94678cccda35dcd4d5a2a91fd69b to your computer and use it in GitHub Desktop.

Materials

  • laptop
  • internet access
  • Raspberry Pi
  • USB cable
  • microSD card
  • SD card reader

Write OS .img to SD card

SD Card Image Setup

  1. Download the Raspberry Pi Imager from the Raspberry Pi Foundation's website. Install and run the Imager
  2. Click on Choose OS. Identify and select your desired image. For example: click Raspberry Pi OS (other) and select Raspberry Pi OS Lite (64-bit)
  3. Click on Choose Storage. Identify and select your microSD card
  4. Click on the gear icon
  5. Click the button labeled Set hostname. Enter a unique hostname for your RPi, for example: videolooper
  6. Click the button labeled Enable SSH. Beneath Enable SSH make sure to select Use password authentication
  7. Click the button labeled Set username and password, set a username and password for your RPi and write it down somewhere
  8. Click the button labeled Configure wireless LAN, add the SSID (Network Name) and Password (Network password)
  9. Set Wireless LAN country to US
  10. Click the button labeled Set locale settings, set Time zone to wherever you are (for example: America/Los_Angeles) and Keyboard layout to US
  11. Double check your settings and then click Save
  12. Click Write

Flight Check

  1. Put microSD card into the RPi
  2. Give the RPi power
  3. Note the ACT light, it should be flashing green
  4. Connect to USERNAME via ssh: ssh USERNAME@HOSTNAME.local (Note: sometimes this shortcut fails on institutional WIFI networks like the ones at ArtCenter College of Design. If you cannot connect via HOSTNAME.local try connecting a conventional monitor and keyboard to the RPi and continue or try this)
  5. Enter the PASSWORD for USERNAME when prompted
  6. Get actual IP address of RPi: hostname -I
  7. Write down output from the previous step somewhere
  8. Exit the RPi: exit
  9. Log in once more with the real IP to confirm:ssh USERNAME@IPADDRESS

Backup OS .img to CPU

  1. Shut down your RPi: sudo shutdown now
  2. Remove the microSD card from the RPi, insert it into an SD card adapter, plug the microSD into your laptop
  3. MAC Get the formatted microSD card's address: diskutil list
  4. MAC unmount the disk: diskutil unmountDisk /dev/rdisk2 (replace 2 in /dev/rdisk2 with whatever number you got in step 3.)
  5. MAC Pipe the output of dd to gzip, archiving and compressing the image in one line, with the following: sudo dd bs=10m if=/dev/rdisk[DISK# FROM DISKUTIL] | gzip > rasbian.img.gz (this takes a VERY LONG TIME, so go get a cup of coffee or take a walk or something)

Restoring/Cloning from Backup .img

  1. Insert the microSD card into an SD card adapter, plug the adapter into your laptop
  2. Get the microSD card's address (identified by size): diskutil list
  3. unmount the microSD card so we can write our .img to it: diskutil unmountDisk /dev/disk2 (replace 2 in /dev/disk2 with whatever number you got in step 3.)
  4. The following will extract and restore a backup .img to another microSD card: gunzip --stdout rasbian.img.gz | sudo dd bs=4m of=/dev/rdisk2 (replace 2 in /dev/rdisk2 with whatever number you got in step 3. of microSD prep) (this takes a VERY LONG TIME, so go get a cup of coffee or take a walk or something)
  5. Remove microSD from laptop, insert into RPi, confirm successful startup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment