Note to self: If you've done this once before, instead of re-installing, why not restore from your backup?
Buy a Raspberry Pi "kit" from someone like Amazon. Although you can buy a bare Pi for less, the kit should include:
In addition to your Pi, you'll need an SD card reader. Many laptops include a full-size SD card reader. You can use these if you get an adapter/sleeve which makes a Micro SD card fit the full size slot. If you have to buy a USB-based SD reader, expect to spend about $10.
The slowest piece of a kit will be the SD Card, and not the Pi. If you can afford it, spring for a really fast UHS-II U3 SD card or a not quite as fast UHS-I Class 10 SD Card. While this will cost more than your Pi, it will save you a boatload of time when writing to it.
Note that the Pi can't actually drive UHS-I or UHS-II voltages, but getting the U3 speed rating will help on the Pi and your laptop will take advantage of UHS-II when it writes the OS image. The Class 10 card will be just as fast in your Pi, but maybe a little slower on your laptop. It is definitely cheaper. I'm using one of these.
You'll need a PC or Mac to load Linux onto the SD card. I'm going to assume you are using a laptop. If you're using a desktop, substitute 'desktop' wherever I say 'laptop.'
Here are the basic steps, after you assemble your Pi:
If you are in Eastern Time, append this to your ~/.profile. If you're in another time zone, choose a value more suitable for your locale:
Run these ONE AT A TIME to avoid X problems. Even tiny variations have messed up xterm:
sudo apt-get update sudo apt-get install vnc4server sudo apt-get install openbox vnc4server
Stop the VNC server and install one which works well with Mac and Windows clients:
vnc4server -kill :1 sudo apt-get install tightvncserver
tightvncserver -geometry 1920x1080 -depth 24
tightvncserver -kill :1
Set up things so that running 'vncserver' will run tightvncserver. (The old /usr/bin/vncserver was a link to /etc/alternatives/vncserver.)
sudo mv /usr/bin/vnc4server /usr/bin/vnc4server-hideme-kpk sudo rm /usr/bin/vncserver sudo ln /usr/bin/tightvncserver /usr/bin/vncserver
Allow root (superuser) to run X gui programs. Add this line to /etc/profile:
You're going to want to grow your file system to fill the SD Card:
Check to ensure the resize worked. Connect via VNC. Then use the GUI tool gparted:
sudo apt-get install gparted sudo gparted
Configure your router so that it always assigns the same IP address to your Pi. I can't tell you how to do this (unless you have the same router that I do) because it is different on every model of router. Your router probably has a web-based interface for doing this. On my router, it lives under LAN >> DHCP Server. If your router permits, you can also tell it that your Pi is named "raspi", and then you can connect to "raspi" when you use SSH, instead of connecting to something like 192.168.1.136.
Update all packages (does not upgrade the OS to a next release) and reboot. Note: I got a big notice about updated certificates, and it asked me to press "q" to quit. I did. I assumed it was just to quit displaying the notice.
sudo apt-get dist-upgrade sudo reboot
This next bit is optional. You've spent a lot of time building your Raspbian installation. If you ever need to re-install, you can save yourself from having to do all of this again by making an image of your drive as it is now. Then, when you need it, you can re-load that image instead of having to load the generic image and apply all of these updates. I'm going to tell how to do this for Mac. You can figure out how to do similar operations if you use Windows or Linux. Windows users see this Lifehacker guide.
Back up your SD card:
On the Pi, make as much of that image contain zeros as possible (to maximize compressiong in a following step). Note that zeroing your SD card will be slow if you have a large card. Also note that on a Mac, you use "4m" as the block size, but on many Linux systems it is "4M". If you get "dd: bs: illegal numeric value", try switching the upper/lowercase of your BS.
sudo dd if=/dev/zero of=/boot/tmp-zero sudo rm /boot/tmp-zero dd if=/dev/zero of=/tmp/tmp-zero bs=4m rm /tmp/tmp-zero sudo shutdown -h now
Move the SD card to your Mac, and use the following, to figure out what disk number has been assigned. I'll refer to the disk number with the place-holder '#'.
Create an image using dd. Note that if you have installed pigz, it will compress faster than gzip (by using multiple cores). This takes about 1.3 hours for my 32 GB SD Card. You might want to try using /dev/rdisk# for the dd. It is reportedly faster, but I haven't checked it to see whether it works.:
diskutil unmountDisk /dev/disk# sudo dd bs=4m if=/dev/disk# | gzip > ~/raspi-backup-image-yyyy.mm.dd.gz
When you need to restore that image (BE SURE TO REPLACE TOKENS IN THE LINE BELOW). Note: If it tells you the disk is busy, try also unmounting its partitions:
diskutil list diskutil unmountDisk /dev/disk# sudo su gunzip -c ~kevin/jumbo/raspi-backup-image-yyyy.mm.dd.gz | dd bs=4m of=/dev/rdisk# ^d diskutil unmountDisk /dev/disk#
Note that writing to /dev/rdisk# took about 35 minutes. Writing to /dev/disk# took over 3 hours.