Pages: Welcome | Projects

Raspberry Setup

2016/7/8
Tags: [ Hacking ] [ GNU/Linux ]

I've got a Raspberry Pi. I would like to have it running with a Pidora, and run something cool on it. I'm taking some notes in the process.

DHCP on my machine

For starters, let's have it running. I could attach it to the ADSL router, but where's the fun in this? So I learned a number of things. My local machine is going to act as DHCP server on the Ethernet NIC, where I'll attach the Raspberry.

Setup of the local machine:

My Ethernet configuration

After editing with nmcli a new connection named dhcp_serve, I obtained the following network script:

$ cat /etc/sysconfig/network-scripts/ifcfg-dhcp_serve

TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=dhcp_serve
UUID=2dddede7-15e8-4a6c-a3ef-2299f4bc6f00
DEVICE=eno1
ONBOOT=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
ZONE=internal
IPADDR=192.168.128.1
PREFIX=24

Some comments and gotchas:

  1. I had to manually set BOOTPROTO=none in order to disable the DHCP server to run automatically on this connection. This is because we are offering DHCP, but I noticed that TCP was reporting my machine's attempts to do it.

  2. If you want your DNSMasq to actually work, it's a put that /24 on your network. Here the PREFIX was added by the nmcli editor when I specified 192.168.128.1/24 as address. By default it goes with /32.

  3. The firewall will be in the way. I'm doing this on a Fedora, where the configuration is not linear IMHO. iptables -L gives me kind of a maze. I'm not (yet) expert with IP Tables, thus I need to go for firewall-config:

    • The dhcp port must be enabled in the firewall configuration. This is going to affect the internal Zone as consequence of the previous point.

    • The Zone of the Ethernet connection is going to be internal. This was set with the mentioned firewall-config tool, and got reflected on this network script. The fact is: we want to enable the DNS Masquerade (NAT) later on!

  4. Of course, enable IP forwarding: echo 1 > /proc/sys/net/ipv4/ip_forward

Apparently it works, but how do I prevent NM to automatically reset everything if (say) the Raspberry goes down or I detach the Ethernet cable? TODO think of this.

Fresh login in Pidora

After the DHCP is set, it's simply a matter of ssh to the correct IP address. Something you get from the logs.

The default password is just raspberrypi, as mentioned in the online documentation.

Fix the SD Card

The default installation will just use 2 of the N available gigabytes. In my case I've got 4 Gigabytes. The graphic installation application however shows a resize root filesystem option.

There must be a program for this.

$ rpm -qa | grep resize
rootfs-resize-3.0-7.rpfr20.noarch

Yup. Sounds like we found it. How does it work?

$ rpm -ql rootfs-resize
/.nofsresize
/.rootfs-repartition
/.rootfs-resize
/.swapsize
/usr/lib/systemd/system/rootfs-resize.service
/usr/sbin/rootfs-resize
/usr/share/doc/rootfs-resize
/usr/share/doc/rootfs-resize/COPYING
/usr/share/doc/rootfs-resize/README.md

It's fairly easy: the rootfs-resize program is a python script. It requires certain files in place as parametrization. Everything is clearly described in the script in form of comments.

Just run and claim all your space.