One of my projects entails running (and developing) network monitoring software on a private uplink. I could use my laptop as a server, but it has a constant energy consumption of about 60 watts which I find a bit much. Enter the SheevaPlug.
The SheevaPlug is a neat little plug computer from GlobalScale Technologies that serves as a development kit. It comes with a 1.2 GHz ARMv5 CPU, 512 MB RAM and integrated 512 MB NAND flash storage. It also features a 1 Gbit/s ethernet port, USB 2.0 connection and an MMC slot. The basic premise is that you take the thing, ram it into the nearest outlet and bask in its glorious Linux-running presence. And it does all that for a whopping 3 (idle) to 7 (load) watts! I quite liked the idea so a few years ago, I bought two of ’em.
Unfortunately, 512 MB RAM is not a lot and 512 MB of internal storage is even less when you consider the storage requirements of a modern Linux distribution. Now, I could have gone for a small distribution like DSL, but I wanted to have a bit of consistency between my servers so I wouldn’t have to make a context switch in my head every time I log in into the SheevaPlug.
Debian is my favorite go-to Linux distribution. It’s stable, pretty lightweight by default and I like its configuration system. Also, it officially supports the SheevaPlug as a target device, which is nice. The default install of a standard system plus SSH requires about 512 MB of disk storage, which is a bit much for the poor SheevaPlug. So I dusted off an old 2 GiB USB flash drive that now serves as the primary drive.
Install Debian on a SheevaPlug
The goal is to install Debian Wheezy 7.7 on a SheevaPlug with a USB flash drive connected to it. Martin Michlmayr has a lot of resources on the SheevaPlug, which I’ll use in the installation steps below.
- Power on the SheevaPlug.
- Connect the device to your computer using the supplied USB cable. This will create a new serial device and on Windows you might need to install the device drivers for it. You can find those on the disc that came in the box. See this guide by Mike Levin for more information about connecting to the SheevaPlug.
- Connect your SheevaPlug to your LAN with access to internet using an ethernet cable. The Debian (net) installer requires a working internet connection.
- Connect your USB drive using the USB connector on the front of the device.
- Once fully connected, reboot the device by pressing the reset button on the side through the pin hole. Press [any key] as soon as you see the text “Hit any key to stop autoboot”.
versionto see the currently installed boot loader version. For example:
Marvell>> version U-Boot 2011.12 (Mar 11 2012 - 18:59:46) Marvell-Sheevaplug - eSATA - SD/MMC gcc (Debian 4.6.3-1) 4.6.3 GNU ld (GNU Binutils for Debian) 2.22
If the version you see is anything other than “U-Boot 2011.12”, you need to follow this guide in order to upgrade your SheevaPlug’s boot loader.
- Run the Debian installer using Martin’s excellent guide. I can recommend using TFTP but MMC should work equally fine. Just walk through the installation steps like you normally would. For a minimal installation, only select the “Standard system utilities” and “SSH server” tasks.
- Log in onto your newly installed Debian-powered SheevaPlug using SSH!
Improve SheevaPlug performance
My USB flash drive gives me pretty low read and write speeds of about 7 MiB/s when reading or writing sequentially. But for random I/O, it really shines in being a worthless heap of junk. Both U-Boot and Debian really show their I/O hunger in a number of places. Additionally, in the current Debian Linux kernel (version 3.2.0-4-kirkwood), the MMC modules are keeping a kworker thread busy whenever a SD card is not present in the slot by polling it periodically. Fortunately for us, these issues can be alleviated!
- Log in as root into your SheevaPlug device.
- Greatly decrease the size of your initrd file by modifying two settings in /etc/initramfs-tools/initramfs.conf:
# Set MODULES to 'dep' so update-initramfs will try to limit itself to modules actually used MODULES=dep # xz compresses much better than gzip, and is only somewhat slower COMPRESS=xz
Usually, your boot loader spends most of its time reading the initrd file (/boot/uInitrd) which can sometimes take up to 60 seconds! By making these changes, the initrd will shrink in size from an obese 7 MiB to a lean 1.6 MiB making your boot process a whole lot faster.
- If you want to disable MMC support altogether (like I do), create a file /etc/modprobe.d/mmc.conf and add these lines:
blacklist mvsdio blacklist mmc_core
This will prevent the MMC modules from being loaded by your kernel and will lower your base CPU usage significantly.
- If you do not want to use IPv6, disable the module by faking the modprobe install. Create a file /etc/modprobe.d/ipv6.conf with this line:
install ipv6 /bin/true
This will trick modprobe and the initramfs tools into thinking ipv6 is installed and loaded correctly. Disabling IPv6 will probably only lower your memory usage slightly.
depmod -aeto update your module dependencies.
update-initramfs -uto generate a new /boot/uInitrd file. Note that your previous initrd gets backed up to uInitrd.bak, so mistakes are easily reverted.
- Edit /etc/rsyslog.conf and comment the log lines not pertaining to syslog:
# # First some standard log files. Log by facility. # #auth,authpriv.* /var/log/auth.log *.*;auth,authpriv.none -/var/log/syslog #cron.* /var/log/cron.log #daemon.* -/var/log/daemon.log #kern.* -/var/log/kern.log #lpr.* -/var/log/lpr.log #mail.* -/var/log/mail.log #user.* -/var/log/user.log
This will help with keeping logging I/O to a minimum. The downside is that you’ll need to wade through /var/log/syslog from now on.
- Replace exim4 with ssmtp if you only want simple outbound emails through a smarthost:
apt-get install ssmtp
Ssmtp is lightweight and does not run as a daemon – like exim4 – but is executed inline as
- Want to trim some more fat off of your installation? Why don’t you install debfoster and run it to discover all the things you don’t need in a minimal Debian install:
apt-get install debfoster debfoster
This tool enumerates all packages that are not dependencies of other packages (“foster” packages). Using [p] you can delete the package and all its dependent packages. I recommend purging nfs-common, installation-report, task-english, db5.1-util and eject. This will probably result in two less daemons running on your device.
- Do a
rebootand enjoy all your new found performance!
Have fun with this plug computer, and please contact me if you found this guide useful or have any remarks.