Last month I bought a bunch of Raspberry PI 2 and started playing with them.
I was a bit disappointed about the lack of modern tools in the standard Raspbian Wheezy distro, but I found out that Debian 8.0 (Jessie) is more advanced on that, but the process of downloading the image, modifying the files, and then upgrading was boring, and I needed a quick way to configure multiple raspberries with this configuration. Something faster than cloning memory cards, possibly.
After some tests, I found out that the unattended to be the fastest way to install a Raspberry Pi 2 with Jessie.
Installation
I’ll use Raspbian Unattended Netinstaller, an image that, with a minimal download will install a basic system. Please note that at the time of writing (March 31st 2015) you have to get the 1.0.7-beta version of the installer, which is the first version supporting the Raspberry PI 2.
Update (April 26th 2015): 1.0.7RC version of the Raspbian Unattended Netinstaller has been released, fixing the problem with bootsize parameter.
Grab an empty microSD card, and ensure it’s formatted as FAT32 (use this tool to format the card if unsure). In this test I’m using a Samsung 16GB Class 10 Evo MicroSDHC UHS-I Grade 1 Memory Cards, bought on Amazon for about 12 euro.
Unzip the files in the root of your card, and create a new installer-config.txt in the root directory, with this content:
mirror=http://mirrordirector.raspbian.org/raspbian/ release=jessie hostname=doctorwho rootpw=doctorwho bootsize=+128M
Of course, you can configure your hostname
and rootpw
fields as you prefer, but you really need to enlarge the boot partition size above the default level of 50M, or the setup will fail.
Once you connect an ethernet cable (connected to a network providing dhcp services) and plug in your power supply, your raspberry will start downloading all the packages and install the system. Although this should be an unattended process, it’s not a bad idea to connect a monitor and a keyboard during this process, to allow error messages to be displayed, and some interaction in case of failure.
Note that if something fail, the setup will restart from the beginning, but a different log file is produced at every iteration.
If everything goes well, after more or less half an hour (depending on your microSD card and your connectivity) you will have your Raspberry ready to be configured!
Configuration
From now on you can either use the console, or a ssh connection from another computer. To connect via SSH you must use a client (e.g. the console command ssh
for Mac and Linux, or putty.exe
for windows), and connect to the hostname you used before (mine was doctorwho
). Login as root
, providing the password you setup in the rootpw
field of your installer-config.txt
.
After login, you need to configure locale and timezone, by using dpkg-reconfigure locales
and dpkg-reconfigure tzdata
respectively. You can also add a line containing bcm2708-rng
to /etc/modules
to enable the hardware random generator kernel module.
Now you can use apt-get to install your first packages:
raspi-config
: raspberry configuration utilityraspi-copies-and-fills
: improved memory management performance.rng-tools
: hardware random number generation supportsudo
: if you’re brave enough, you might use this later
You can install the whole list by typing apt-get install <packages>
, where <packages> is one, some or all the items listed below (separated by a space in case of multiple items).
We have obtained a nice minimal system.
Installation
Here’s a list of additional packages I decided to install, and the reason why. In my installation, the complete list made my image occupy about 2GB. Again you can use apt-get to install them one by one, or all together, as you prefer.
Compilers and compiling tools:
build-essential
: basic build toolsmake
libtool
g++-4.9
: GNU C++ compiler 4.9 (the latest version, at the time of writing)gdb
: GNU debuggerclang-3.5
: CLang 3.5 compiler (NOT the latest version, but still a pretty good one)lldb-3.5
: debugger foc CLangcmake
: a tool for building make scriptscmake-qt-gui
: a nice gui for cmake
Environment:
lxde
: Desktop environmentlxpanel
: control panel for lxdeiceweasel
: Web browserxrdp
: Support for Microsoft Remote Desktopxterm
: terminal window
Tools:
samba
: Microsoft file sharing
Creating a user
The net install creates just the root user, and to make the setup completely unattended and usable later, it allows the root user to login from ssh, which is unsafe, and so we have to change this configuration
Let’s fix this by creating a new non-super user. Since you were logged in, use adduser command. We will make our user member of the groups netdev and sambashare to, respectively, allow running superuser commands, managing printers and file shares. We can eventyally add the sudo group, too.
root@doctorwho:~# adduser pi Adding user `pi' ... Adding new group `pi' (1000) ... Adding new user `pi' (1000) with group `pi' ... Creating home directory `/home/pi' ... Copying files from `/etc/skel' ... Enter new UNIX password: <type password here> Retype new UNIX password: <type password here> Changing the user information for pi Enter the new value, or press ENTER for the default Full Name []: Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n] Y
Now you have your user configured. You can start up another ssh session and test your credentials.
Make your user member of the sambashare group by entering adduser pi sambashare
from your root shell. Do the same for netdev
group.
To make things more secure, you could make your user member of the sudo group by entering adduser pi sudo
from your shell, and then enable sudo group in /etc/sudoers (sudo is handy, but explaining how to make it work is out of our scope). You’ll get some extra points if you disable the root login from ssh :)
Restart
After a restart you’ll find that your system in console will start with the graphic environment (LXDE) and is also accessible via RDP (microsoft’s remote desktop protocol). You should see your device on the network with the
That’s all to start testing g++ 4.9 and clang 3.5!