Ceci est une ancienne révision du document !
I recently replaced my aging MacBook Pro with a Dell XPS 15 (7590) with the intention of once again switching to one computer for both on-the-go and at my desk (via the use of an eGPU enclosure). Until now, my main computer was my Intel NUC with an i5 which was running ArchLinux and was on 90% of the time. It ran my local web apps, Plex installation, and acted as a Samba share for some files. For various reasons, I can’t always assume my laptop will be up and running, or connected to a wired network connection. As such, hosting internal tools like that seems kind of silly. Instead, I dusted off my Raspberry Pi (periodically used as a printer server and a test environment), and have pressed it into service as my internal tools host. This month’s article will run through some things I discovered in the new version of Raspbian, and a few tricks I’ve thought of along the way.
Initial Setup
Setup is pretty easy - follow the instructions for Raspbian and copy it to an SD card. Then boot it.
Configuration
Ask yourself a few questions for this next step:
Where will you be using the RPi most frequently? Will it have access to: • Wired internet? • The same IP/network (i.e. will you be moving it around)? • Keyboard/mouse/monitor? • External storage? • Airflow/cool environment? • A direct power connection (versus battery)?
What will you want to do with the RPi?
Depending on the answers to some of these questions, it may impact your decision on what model of RPi you want. If you’re worried about temperatures, you can find some small heatsinks to put on the RPi’s chips. It’s passive cooling, but will increase the surface area to dissipate heat.
In my scenario, my answers are as follows: • It’ll run on both wired and wireless networks. • The IP cannot be fixed (different interfaces, and I will use it in at least two separate networks with different IP ranges). • It will have minimal access to input and output devices. It must have SSH and/or VNC services running. • It will have access to external storage, but it will not always be the same drive. • Airflow shouldn’t be a problem (in both cases, it will run on a table, not tucked into a closet). • It’ll run directly from the A/C adapter. • It’ll run Plex, a ruby on rails app, an SSH service, a VNC service, and will most likely run more local web apps to be accessed on the local network.
The Problems
There were two big problems I saw with the requirements. One problem was the inconsistent external drive, and the other issue was the changing IP address.
One problem at a time - I set up my external drive using the UUID in my fstab file, and included the nofail flag. This will ensure that the RPi will boot even if the drive is unavailable. By default it will timeout after 90 seconds, which I deemed too long. Instead, I added “x-systemd.device-timeout=30” directly after the nofail flag. This sets the timeout to 30 seconds instead.
The other problem I still haven’t found an ideal solution for. I set up and enabled the avahi-daemon to allow an mDNS broadcast on the RPi (which should make it available under raspberrypi.local on the network). Unfortunately, this seems to work only sporadically. On a wired connection it seems to fail only in Chrome and Opera, but on a wireless connection it doesn’t work for anything. As long as I can manage to get ping to successfully find the local domain, I can at least ensure I’ll be able to discover the IP address it’s running on.
I also tried to set up static IP addresses for the 2 different networks and 3 connections modes (location 1 wired, location 1 wireless, location 2 wireless). While this seems to work more readily than avahi, it’s still not a guarantee. I’ve experienced the RPi still pulling in random IP addresses in both locations, or running on a static IP in the wrong network (causing a complete failure of connection, as an IP in one location is invalid in another). I’ve since then tweaked the settings, but haven’t yet thoroughly checked the results. That will happen later this summer.
Setting up a rails app
This part is pretty easy - just install ruby and ruby-devel. Then I cloned the git repository I stored my app in and run ‘bundle install’. It took a little while as a few items were compiled from source for the ARM architecture.
I then used the trick I wrote about in FCM#145 and created a systemd service for running the rails app. I also ensured it would bind to 0.0.0.0 so that I could access the site from other devices, regardless of what the IP address was.
Setting up Plex
This was also pretty easy - I just installed the service, configured it, and started it. The media for the plex library is stored on the external drive. While the drives can change, the locations should remain the same. On the smaller external drive the selection of media will also change.
One note here: the RPi took a long time processing all the files and loading the metadata. During this time it was frequently unresponsive and laggy. I feared at first that this might be too much for the device. However, once the initial scans and metadata loading was done, it’s been absolutely fine for streaming both on a wired and a wireless connection, as well as casting to a TV.
Connecting
I had to initially connect it to a monitor, keyboard and mouse – as I hadn’t booted the device in some time, and I couldn’t connect to it using the information I had stored. In this case, the IP address it was supposed to be using had been occupied by another device, and so it received a random one.
I then took the time to use the direct input methods to run the dist-upgrade I needed, and then rebooted after tweaking the fstab file.
After I knew the IP address the device was running (and avahi-daemon was working), I connected instead using VNC and SSH (VNC when I was trying to test the rails app and had to check in a local web browser, and SSH whenever I needed to quickly change a file or run a service). The RealVNC service I’m running is surprisingly good. I remember my last experience using VNC frequently were weird colors, artifacts, and a laggy interface. On this new laptop I’ve had no such issues.
I also took the time to set up a samba share on the RPi to share the external drive location on my local network. This way I can quickly and easily add media files to Plex if I need to. I didn’t need to do anything beyond the basic steps - install it, run it, and create a Samba share and password for the pi user.
Verdict
Is everything as fast and reliable as when it ran on my NUC? No. On the other hand, it’s portable, small, quiet, and doesn’t draw as much power. So far, I haven’t run into any showstoppers, and once the large Plex scans finished up, subsequent small scans have been fine.
So for any readers who are hoping to use their Raspberry Pi for more than just tinkering - I say go for it! To any readers out there who have found a good solution to always knowing the device’s IP address, please do let me know! As always, any questions, comments, or suggestions can be sent to me at lswest34+fcm@gmail.com.