How to fix ethernet connection drop on Pidora

Raspberry Pi and Fedora Linux

If you’re looking to try something different on Raspberry Pi, Pidora is an OS for the tiny Pi built on the Linux software distribution Fedora. It contains software packages from the Fedora Project (specifically, the Fedora ARM architecture project) compiled specifically for the ARMv6 architecture used on the Raspberry Pi, packages which have been specifically written for or modified for the Raspberry Pi, and software provided by the Raspberry Pi Foundation for device access.

Pidora has a slightly different look and feel than Raspbian, it comes with a handful of different software and it’s a wonderful Fedora based alternative because the Fedora ARM version only runs on the Raspberry Pi 2 (ARMv7).

You can download Pidora and take a look at the Pidora Wiki to configure your system on the Raspberry Pi device. You can also use NOOBS that has Pidora on board ready to be installed on your Pi. Sadly, Pidora distribution isn’t actively maintained at the moment. The latest version is based on Fedora 20, which support ended already in June 2015, but the systemis fully working, stable and the repositories are active and maintained.

The amazing world of the Raspberri Pi

I did a small torrent server machine with my Raspberry Pi (first model, B type) and with Pidora distribution. Put on it Transmission Server and run his daemon to have a headless server with web interface.

Install the transmission daemon, so will allow the software to run as a system service:

yum install transmission-daemon

Edit config file to allow remote access:

nano /var/lib/transmission/.config/transmission-daemon/settings.json

change "rpc-whitelist": "127.0.0.1", to "rpc-whitelist": "*.*.*.*",

Save the settings and enable the service to get it running:

systemctl enable transmission-daemon.service

systemctl start transmission-daemon.service

In my case (I used a static IP for my Pi), I can connect with:

http://192.168.0.140:9091/

Transmission Web

All works fine and it’s amazing because I can finally turn off my PC and leave the tiny Raspberry Pi downloading Torrent with no noises and without high electricity consumption. And I can also access to it from all my devices such as smartphones, tablet and laptop, just put that address in a browser.

The ethernet connection drop issue

My Raspberry Pi is connected to my LAN with a cable and it’s using the ethernet connection. This is the best way for my goals because usually it’s more stable and has more speed than a wireless connection. Sadly, the ethernet connection of my Raspberry Pi drops randomly. When this happens, I must turn off and on the Pi and wait it restarts. One time, two times, some times, it has become boring and boring.

I googled a lot but it seems a unsolved issue, but I also found a geek with the same problem with Raspbian. Ok, it’s a Debian distribution, but he solved the issue!!!

I followed his instructions and I changed something to make it working on Fedora. Ehm… Pidora.

So, take a look at the solution.

First, make a folder for scripts:

mkdir ~/bin

Then edit our script:

nano bin/network-monitor.sh

And put this inside it. Be sure to change cialu with your home folder name.

#!/bin/bash

LOGFILE=/home/cialu/network-monitor.log

if ifconfig eth0 | grep -q "inet" ;
then
        echo "$(date "+%m %d %Y %T") : Ethernet OK" >> $LOGFILE
else
        echo "$(date "+%m %d %Y %T") : Ethernet connection down! Attempting rec$
        sudo ifup eth0 --force
        OUT=$? #save exit status of last command to decide what to do next
        if [ $OUT -eq 0 ] ; then
                STATE=$(ifconfig eth0 | grep "inet addr:")
                echo "$(date "+%m %d %Y %T") : Network connection reset. Curren$
        else
                echo "$(date "+%m %d %Y %T") : Failed to reset ethernet connect$
        fi
fi

Make the script executable with: chmod +x ~/bin/network-monitor.sh
Open ~/.bashrc and add this line to the end:

PATH=$PATH:~/bin

The shell normally reads ~/.bashrc when you log in, but we can tell it to parse it now using this command to that the changes take effect:

source ~/.bashrc

Now, you should be able to run the script with: network-monitor.sh
And you can check if it’s working with: cat ~/network-monitor.log

Last, but not least, set crontab to run the script every 5 minutes.

sudo nano /etc/crontab

And put this line at the end of the file:

*/5 * * * * root bash /home/cialu/bin/network-monitor.sh

Also here, change cialu with your home folder name.

That’s all and the Pi now is fully working 24/7.
No more stops by ethernet connection drop.