I have a checklist for setting up a Raspberry Pi, which I run through
before I do any task-specific customisation. It occurred to me that
people might find this useful.
I don't remember whether I've ever actually plugged a Pi into a
monitor; everything gets controlled over ssh. If you're stuck with
Windows the commands will differ and you will probably want to do
things differently.
I start with a Raspbian image, downloaded from
the Raspberry Pi site. I copy
this to the SD card with dd, then sync and remove it.
The SD card and network cable are inserted into the Pi; then I power
on. This first boot takes a little while, as (among other things) ssh
moduli are generated.
I have a DHCP server which interacts with the local DNS, so as soon as
the Pi has booted and performed DHCP there is a DNS name "raspberrypi"
pointing to it. If you are not so blessed, you'll need to look at the
lease list on your network's DHCP server to find out the Pi's IP
address and use that rather than the DNS name.
I connect to the Pi with
ssh -o UserKnownHostsFile=/dev/null pi@raspberrypi
(Ignoring the hosts file means that I don't have to worry about other
Pis that have shared that hostname.)
On the Pi:
sudo su -
which brings up a menu: I expand the filesystem to fill the SD card,
then finish and reboot. This can also take a little while. Later
reboots are quicker.
Once the Pi has rebooted, I ssh in again, as above, and:
sudo su -
passwd
to set a root password for the Pi. (I know, the kids today don't use
root shells, they run everything through sudo. Tough. If a root shell
scares you, that just means you're doing it right.)
Then:
aptitude purge vim-common vim-tiny nano
apt-get update && apt-get dist-upgrade
apt-get install rsync nvi
The first line gets rid of some packages I never want to see. (One
could probably add the graphical stuff here, but it takes a while and
since it's not started automatically all it consumes when idle is
space on the SD card.)
The second line will take a while, and is optional: it gets the system
up to the latest versions of everything.
The third line installs my preferred lightweight text editor (if you
don't speak vi, you may want to keep nano instead) and a
synchronisation program that ends up on everything I build.
From the Linux host:
rsync -e 'ssh -o UserKnownHostsFile=/dev/null' -Pvaz home-pi/ pi@raspberrypi:~/
My "home-pi" directory contains all the files I want by default: my
preferred .bash_profile
and .bashrc
, and my SSH key so that I
don't have to keep retyping passwords (.ssh/authorized_keys
). If you
have no preferences here, you can omit this step.
Back on the Pi, at the root prompt:
cp -a ~pi/.ssh ~/
chown -R root.root ~/.ssh
vi /etc/hostname /etc/default/rcS
shutdown -r now
The first line copies that ssh key to root; the second sets the
permissions. You can now log in as root with the ssh key rather than
using the password.
Changing hostname is mostly useful because the Pi will register on the
DHCP server with that name, so if you have multiple Pis running at
once you need be in no doubt as to which one you're talking to.
/etc/default/rcS
needs to have its last line changed to
FSCKFIX=yes
, so that if errors are found during boot the Pi will
attempt to repair them and keep going.
Finally, you reboot the machine ready for installation of specific
programs, or if you prefer shut it down (shutdown -h now
).
Comments on this post are now closed. If you have particular grounds for adding a late comment, comment on a more recent post quoting the URL of this one.