How I prepared my RaspberryPi2, cause the images didn't work :-)

VolkerVolker Member Posts: 1
Hi team(s),

I thought I provide the community with this as a doc/tutorial, how I got RaspberryPi2 working with GETH.

Of course, first I tried downloading NOOBS, attached it to a monitor, eventually got RASPBIAN running, and was unhappy. The flavour of Debian doesn’t feel right for me, I wanted to have my SuSE on the RP2. I downloaded several „JEOS“ images, and failed. The JEOS SuSE images would be „just enough OS“, so a minimal installation. That would fit the needs here, but I couldn’t get it working… I looked up [1], but the link from Christoph did not work. So ARCH Linux - let’s see…

One more hint: you know, you need a (micro-) SD Card for your RP2. I had an older 2 and 4 Gig SD card, that worked in my Mac and Linux, but they don’t in the RP2 - RP2 really requires fairly modern SD cards!

The ArchLinuxARM image comes as a single file, and contains all necessary files for a „/root“ and „/boot“ directory. This means, the SD Card has to be prepared in a way, that two partitions are available, that will be mounted on your Linux system. On the Linux box you extract the file, and copy contents to the (mounted) SD card. I have a 16Gig and a 32Gig SD Card in an adapter, plugged into my Linux system. I had them connected via an USB port adapter. You’ll need to check the device names thoroughly! This is different from system to system, depending on how many devices are already connected.

So let’s go… where is my SD Card?
Usually a Linux system (Debian, SuSE, ArchLinux, Ubuntu…) finds these SD cards as sdb, sdc, sdd, sde and so on. I did a
sudo fdisk -l /dev/sdb
fdisk: /dev/sdb: No such file or directory

ok, it’s not /dev/sdb, so we check sdc:
sudo fdisk -l /dev/sdc
Disk /dev/sdc: 15.1 GiB, 16172187648 bytes, 31586304 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
oh, cool, that’s what we want. You really want to make sure, that this is your SD card, if not, you might corrupt your system…
I formatted my SD card with 200 MB for /boot and vfat file system. The second partition is /root and uses the rest of the SD card, as ext4 file system. That is a good setup to start with, and will quickly work. If you are more sophisticated, use „only“ 3 Gig for /root, and create a third partition with the remaining space. Call it say „/Data“, use ext4 as well. Later on you just copy the .ethereum folder to /Data, set some links, and your root can never run full :-)
Let’s create two partitions with fdisk:
sudo fdisk /dev/sdc

Press „m“ for a menu of available commands, basically you’ll create partitions via keyboard:
Type o		clear any partitions on the SD Card
Type p list partitions - there shouldn’t be any
Type n this is for a new partition
Type p create a primary partition
Type 1 for the first partition on the drive
Press ENTER to accept the default first sector
Type +200M for the last sector
Press ENTER to create partition
Type t to change type of partition
Type c to change partition to type W95 FAT32 (LBA), also called VFAT sometimes
the second partition will go similiar, like this:
Type n		this is for a new partition
Type p for primary
Type 2 for the second partition
Press ENTER two times to accept the default first and last sector
Type w which writes the partition table and exits

Cool, done, partitions created. Do a „sudo fdisk -l /dev/sdc“ again, to see what you have:
sudo fdisk -l /dev/sdc
Disk /dev/sdc: 15.1 GiB, 16172187648 bytes, 31586304 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x292a4711

Device Boot Start End Sectors Size Id Type
/dev/sdc1 2048 104447 102400 50M c W95 FAT32 (LBA)
/dev/sdc2 104448 31586303 25190400 15G 83 Linux
So now we need to format the partitions:
mkfs.vfat /dev/sdc1
mkfs.ext4 /dev/sdc2

I created a „raspberry root (rroot)“ and a „raspberry boot (rboot)“ directory, which will mount the partitions of the SD card.
cd ~
mkdir rboot
mkdir rroot
sudo mount /dev/sdc1 rboot
ls -l rboot/
sudo mount /dev/sdc2 rroot
ls -l rroot/

Then I downloaded the ArchLinuxArm compressed file:
wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz

And extracted the root filesystem to the mounted partition (aka the SD card):
sudo tar xzf ArchLinuxARM-rpi-2-latest.tar.gz -C rroot
sync

then moved boot files to the first partition:
ll rroot/
ls -la rroot/boot/
sudo mv rroot/boot/* rboot/
sudo umount /dev/sdc1
sudo umount /dev/sdc2

Unplug the SD card from your Linux host, put it into the SD Card slot of your RaspberryPi2, connect a network cable and the mini-USB (power) cable, and watch the one light go red, then the green light go flickering. After 15 seconds my RP2 was booted, and I could ping it. The default ArchLinuxARM install is using DHCP as default, so you will have to „find“ you RP2 in your network. You may want to look onto your router, what IP has been given to your RP2. Alternativly you lookup your current IP address, and try to ping „some numbers up or down“, or you use a tool like nmap. Once you found you RP2, connect to it via ssh:
ssh [email protected]

The default install has two users, root and alarm (sounds frightening, but is an abbreviation for Arch Linux ARM). Cool, now get it a bit updated, and then prepare to install go and geth. Feel free to add your own user, never work with root „per default“ (this is my special hint to users coming from WINDOWS world). You’d always go via sudo for security reasons. Remember, your system is connected to the internet, and contains your wallet. You don’t want a compromised system, steeling your Ethers :-)

Let’s bring the system up to latest level, and get some software:
sudo pacman -Syu
sudo pacman-db-upgrade
sudo pacman -Sc
sudo pacman -S make
sudo pacman -S lynx

As I am based in Switzerland, I choose my timezone:
cat /etc/localtime
ls -l /etc/localtime
sudo rm /etc/localtime
sudo ln -s /usr/share/zoneinfo/Europe/Zurich /etc/localtime

And do some „mini“ fixes:
sudo systemctl disable systemd-readahead-collect
sudo systemctl disable ntpd
sudo systemctl disable systemd-random-seed

And we are ready to get the stuff to make it an ethereum system:
sudo pacman -S git go gcc gmp

Checkout that go works:
go version
go version go1.5.2 linux/arm

and get some more…
go get golang.org/x/tour/gotour

sudo git clone https://github.com/ethereum/go-ethereum
cd go-ethereum/
sudo make geth

takes some minutes, then we properly link it:
cd /usr/local/bin
sudo ln -s ~/go-ethereum/build/bin/geth .

and launch:
geth console

At this point we are done. You’ll see lot’s of data flowing over your screen… It’s fetching blocks and synching :-)
Type „exit“ to quit console. The better way to start geth is:
geth --verbosity=0 &

Then you have the terminal free. You can verify disk space, or space consumption of your blockchain via these commands (as of writing, I have 6.3 Gig used):

df
df -h -s
du -h -s .ethereum/chaindata/

And my RP2 is heavily working, with load average going above 3:
top

If things don’t work out, and you want to examine your system, you can stop the geth process this way:
ps aux
sudo kill -SIGHUP

When done, restart:
geth --verbosity=0 &

You can go into the console this way (and leave it with „exit“):
geth attach

or try these commands:
geth --exec "eth.blockNumber" attach
geth --exec "admin.chainSyncStatus" attach
geth --exec "eth.syncing" attach

geth --exec "personal.listAccounts" attach
geth --exec "admin.chainSyncStatus" attach
geth --exec "admin.nodeInfo" attach
geth --exec "admin.datadir" attach

geth account help
geth account list

You’d go back to the ethereum docs, once you arrived her :-)
The syncing of the blockchain on the RaspberryPi2 took 3 days!!!
So if you are able to get this done on your host, you are better off. Once your host has copied the blockchain, you can copy it to your RP2. Effectivly the little RP2 has to verify each block of the chain, before storing it on the drive (or SD Card), and that takes so much time. This also explains, why you don’t want to mine with the RP2.

oh, you want to save the image, that you can re-install later on, without going through all steps? I took it from [2]:

sudo sh -c "dd if=/dev/sdc1 bs=4m | gzip > RP2_boot-last-updated_on_16Jan2015.img.gz"
sudo sh -c "dd if=/dev/sdc2 bs=4m | gzip > RP2_root-last-updated_on_16Jan2015.img.gz"
The gzip is not working too good with very large files, so if you have „xzcat“ (man xzcat), try this one!
Happy RP2 and ethereuming' and of course thanx to the ArchLinux and Ethereum team(s)!

[1] https://github.com/ethereum/wiki/wiki/Raspberry-Pi-instructions
[2] https://smittytone.wordpress.com/2013/09/06/back-up-a-raspberry-pi-sd-card-using-a-mac/

Comments

  • brenzibrenzi Member Posts: 2
    Thanks a lot for this, Volker.
    I've successfully set up the GO client on my OSMC on a Rapberry PI 2.
    However, The blockchain is synching at an average of 3k blocks per hour. So it will take me about two weeks to synch. And even worse: the client crashes from time to time. And geth attach is "not very reactive", meaning it takes about 5min to get the latest eth.blockNumber.

    kodi is running all the time and I can smoothly listen to music or watch videos in spite of geth synching
Sign In or Register to comment.